Skip to content

Commit be56628

Browse files
authored
Merge pull request #19 from ibelem/update-wcg
Update WebNN Code Generator
2 parents f6b75b2 + a72e2b7 commit be56628

File tree

6 files changed

+12
-20
lines changed

6 files changed

+12
-20
lines changed

content/en/learn/tutorials/webnn/vanillajs.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ When building web-based ML applications, developers face a key trade-off:
2222
- **Vanilla WebNN JavaScript** provides minimal footprint but requires extensive manual coding
2323
- **Generated WebNN code** combines the best of both: automated development with optimized bundle size
2424

25-
Currently, the WebNN ecosystem provides three primary code generation approaches:
26-
2725
## Model-to-Code Conversion
2826

29-
These tools convert trained ML models directly into WebNN lean vanilla JavaScript:
27+
Currently, the WebNN ecosystem provides three primary code generation approaches, these tools convert trained ML models directly into WebNN lean vanilla JavaScript:
3028

3129
<Cards className="quick-start-card">
3230
<Cards.Card

content/en/learn/tutorials/webnn/webnn-code-generator.mdx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ The conversion process involves two complementary tools:
3434

3535
1. Navigate to [WebNN Netron](https://ibelem.github.io/netron/)
3636
2. Click the **"Open Model..."** button
37-
3. Select your model file (`.onnx`, `.tflite`, or other supported formats)
37+
3. Select your model file (`.onnx`, `.tflite`, or other supported formats with weights and computational graphs)
3838
4. Once loaded, download the required files:
39-
- Click **"Graph"** → Download `graph.json`
40-
- Click **"Weights"** → Download `weights.json`, `weights_nchw.bin` and `weights_nhwc.bin`
39+
- Click **"Graph and Weights"** → Download `graph.json`, `weights_nchw.bin` and `weights_nhwc.bin`
4140

4241
![WebNN Netron - Graph and Weights buttons](/learn/tutorials/webnn/code-generator-1.png)
4342

@@ -47,8 +46,8 @@ The conversion process involves two complementary tools:
4746

4847
1. Open [WebNN Code Generator](https://ibelem.github.io/webnn-code-generator/)
4948
2. Upload the extracted files:
50-
- Click **"Choose Graph"** → Select `graph.json`
51-
- Click **"Choose Weights"** → Select `weights.json`
49+
- Choose **"Graph"** → Select `graph.json`
50+
- Choose **"Weights NCHW"** and **"Weights NHWC"** → Select `weights_nchw.bin` and `weights_nhwc.bin`
5251

5352
![WebNN Code Generator - Choose Graph, Weights and Bin buttons](/learn/tutorials/webnn/code-generator-2.png)
5453

@@ -66,7 +65,7 @@ If your model contains symbolic dimensions, you'll see a **"Set free dimension o
6665

6766
1. Click **"Generate WebNN Code"**
6867
2. Click **"Download Code Files"** to receive:
69-
- Generated JavaScript file with WebNN implementation
68+
- Generated JavaScript files `*_nchw.js` and `*_nhwc.js` with WebNN implementation
7069
- `webnn.html` test file for validation
7170
3. Put the `weights_nchw.bin` and `weights_nhwc.bin` downloaded from [WebNN Netron](https://ibelem.github.io/netron/) together with `*_nchw.js`, `*_nhwc.js` and `webnn.html` in the same folder
7271

@@ -115,5 +114,4 @@ The [WebNN Code Generator](https://ibelem.github.io/webnn-code-generator/) is id
115114
## Related Resources
116115
- [WebNN Netron](https://ibelem.github.io/netron/) - Model visualization tool with enhanced features for WebNN API
117116
- [GitHub Issues - WebNN Code Generator](https://github.com/ibelem/webnn-code-generator/issues) - Report bugs and request features
118-
- [ONNX2WebNN](https://github.com/huningxin/onnx2webnn) - Command-line alternative
119117
- [WebNN API Specification](https://www.w3.org/TR/webnn/) - Official API documentation

content/zh/learn/tutorials/webnn/vanillajs.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ When building web-based ML applications, developers face a key trade-off:
2222
- **Vanilla WebNN JavaScript** provides minimal footprint but requires extensive manual coding
2323
- **Generated WebNN code** combines the best of both: automated development with optimized bundle size
2424

25-
Currently, the WebNN ecosystem provides three primary code generation approaches:
26-
2725
## Model-to-Code Conversion
2826

29-
These tools convert trained ML models directly into WebNN lean vanilla JavaScript:
27+
Currently, the WebNN ecosystem provides three primary code generation approaches, these tools convert trained ML models directly into WebNN lean vanilla JavaScript:
3028

3129
<Cards className="quick-start-card">
3230
<Cards.Card

content/zh/learn/tutorials/webnn/webnn-code-generator.mdx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ The conversion process involves two complementary tools:
3434

3535
1. Navigate to [WebNN Netron](https://ibelem.github.io/netron/)
3636
2. Click the **"Open Model..."** button
37-
3. Select your model file (`.onnx`, `.tflite`, or other supported formats)
37+
3. Select your model file (`.onnx`, `.tflite`, or other supported formats with weights and computational graphs)
3838
4. Once loaded, download the required files:
39-
- Click **"Graph"** → Download `graph.json`
40-
- Click **"Weights"** → Download `weights.json`, `weights_nchw.bin` and `weights_nhwc.bin`
39+
- Click **"Graph and Weights"** → Download `graph.json`, `weights_nchw.bin` and `weights_nhwc.bin`
4140

4241
![WebNN Netron - Graph and Weights buttons](/learn/tutorials/webnn/code-generator-1.png)
4342

@@ -47,8 +46,8 @@ The conversion process involves two complementary tools:
4746

4847
1. Open [WebNN Code Generator](https://ibelem.github.io/webnn-code-generator/)
4948
2. Upload the extracted files:
50-
- Click **"Choose Graph"** → Select `graph.json`
51-
- Click **"Choose Weights"** → Select `weights.json`
49+
- Choose **"Graph"** → Select `graph.json`
50+
- Choose **"Weights NCHW"** and **"Weights NHWC"** → Select `weights_nchw.bin` and `weights_nhwc.bin`
5251

5352
![WebNN Code Generator - Choose Graph, Weights and Bin buttons](/learn/tutorials/webnn/code-generator-2.png)
5453

@@ -66,7 +65,7 @@ If your model contains symbolic dimensions, you'll see a **"Set free dimension o
6665

6766
1. Click **"Generate WebNN Code"**
6867
2. Click **"Download Code Files"** to receive:
69-
- Generated JavaScript file with WebNN implementation
68+
- Generated JavaScript files `*_nchw.js` and `*_nhwc.js` with WebNN implementation
7069
- `webnn.html` test file for validation
7170
3. Put the `weights_nchw.bin` and `weights_nhwc.bin` downloaded from [WebNN Netron](https://ibelem.github.io/netron/) together with `*_nchw.js`, `*_nhwc.js` and `webnn.html` in the same folder
7271

@@ -115,5 +114,4 @@ The [WebNN Code Generator](https://ibelem.github.io/webnn-code-generator/) is id
115114
## Related Resources
116115
- [WebNN Netron](https://ibelem.github.io/netron/) - Model visualization tool with enhanced features for WebNN API
117116
- [GitHub Issues - WebNN Code Generator](https://github.com/ibelem/webnn-code-generator/issues) - Report bugs and request features
118-
- [ONNX2WebNN](https://github.com/huningxin/onnx2webnn) - Command-line alternative
119117
- [WebNN API Specification](https://www.w3.org/TR/webnn/) - Official API documentation
-141 Bytes
Loading
-3.11 KB
Loading

0 commit comments

Comments
 (0)