Skip to content

Commit 734eddc

Browse files
feat: Add json example
1 parent e0388ab commit 734eddc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

examples/json-saving.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { GPU } = require('../src');
2+
const gpu1 = new GPU();
3+
4+
const kernel1 = gpu1.createKernel(function(value) {
5+
return value * 100;
6+
}, { output: [1] });
7+
8+
const resultFromRegularKernel = kernel1(42);
9+
const json = kernel1.toJSON();
10+
console.log(resultFromRegularKernel);
11+
12+
// Use bin/gpu-browser-core.js to get "CORE" mode, which works only with JSON
13+
const gpu2 = new GPU();
14+
const kernel2 = gpu2.createKernel(json);
15+
const resultFromJsonKernel = kernel2(42);
16+
console.log(resultFromJsonKernel);
17+

0 commit comments

Comments
 (0)