sync 4385228f788d
Browse filesFiles changed (5)
36 unmodified lines373839404142434445464748495051525354555657585960616263646536 unmodified lines## Files- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, per-variant templates, provenance)- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](build/webgpu/test.json) — correctness cases- [`bench.json`](build/webgpu/bench.json) — benchmark cases- [`bitwise-binary-broadcast.wgsl.jinja`](build/webgpu/bitwise-binary-broadcast.wgsl.jinja)- [`bitwise-binary-vec4.wgsl.jinja`](build/webgpu/bitwise-binary-vec4.wgsl.jinja)## Use with `@huggingface/kernels````shnpm install --save-exact @huggingface/kernels@0.0.1-preview.3```Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.Replace each `*Data` placeholder with a typed array containing the corresponding input data.```jsimport { getKernel } from "@huggingface/kernels";const kernel = await getKernel("webgpu-kernels/ai.onnx.BitwiseOr", { version: 1 });const { c } = await kernel({ a: { data: aData, shape: [3] }, b: { data: bData, shape: [3] } });```36 unmodified lines3738394041424344454647484950515253545556575859606162636465666768697036 unmodified lines## Files- [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.BitwiseOr/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)- [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.BitwiseOr/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.BitwiseOr/blob/v1/build/webgpu/test.json) — correctness cases- [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.BitwiseOr/blob/v1/build/webgpu/bench.json) — benchmark cases- [`bitwise-binary-broadcast.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.BitwiseOr/blob/v1/build/webgpu/bitwise-binary-broadcast.wgsl.jinja)- [`bitwise-binary-vec4.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.BitwiseOr/blob/v1/build/webgpu/bitwise-binary-vec4.wgsl.jinja)## Use with `@huggingface/kernels````shnpm install --save-exact @huggingface/kernels@0.0.1-preview.4```Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.```jsimport { getKernel } from "@huggingface/kernels";const kernel = await getKernel("webgpu-kernels/ai.onnx.BitwiseOr", { version: 1 });const aData = Int32Array.of(-1, -2, 3);const bData = Int32Array.of(1, 0, 4);const { c } = await kernel({ a: { data: aData, shape: [3] }, b: { data: bData, shape: [3] } });console.log({ c });```
9 unmodified lines101112131415169 unmodified lineslet begin = invocation * {{ itemsPerInvocation }}u;let end = min(begin + {{ itemsPerInvocation }}u, params.count);for (var i = begin; i < end; i = i + 1u) {{%- endmacro %}{% macro flat_tail_close() %}}{% endmacro %}{% macro offset_fn(fn_name, opShape, opRank, op_same, op_numel, outShape, outRank, out_numel) %}9 unmodified lines101112131415169 unmodified lineslet begin = invocation * {{ itemsPerInvocation }}u;let end = min(begin + {{ itemsPerInvocation }}u, params.count);for (var i = begin; i < end; i = i + 1u) {{% endmacro %}{% macro flat_tail_close() %}}{% endmacro %}{% macro offset_fn(fn_name, opShape, opRank, op_same, op_numel, outShape, outRank, out_numel) %}
4 unmodified lines5678910111213141516171819204 unmodified lines// the result is masked to the low byte per lane. Same semantics as the scalar// broadcast kernel when A, B, C share a shape.{% macro flat_index_2d(workgroupSize, name="i", bound="params.count", guardInline=false) %}{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}// 2D-folded flat index: gid.y carries the high bits past the dispatch's// per-axis workgroup fold width.{% if bound == "" %}let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};{% else %}let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};if ({{ name }} >= {{ bound }}) {return;}{% endif %}{% endmacro %}{% if vec4PerThread > 1 %}const ITEMS: u32 = {{ vec4PerThread }}u;4 unmodified lines567891011121314151617181920214 unmodified lines// the result is masked to the low byte per lane. Same semantics as the scalar// broadcast kernel when A, B, C share a shape.{% macro flat_index_2d(workgroupSize, name="i", bound="params.count") %}{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}// 2D-folded flat index: gid.y carries the high bits past the dispatch's// per-axis workgroup fold width.let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};{% if bound != "" %}if ({{ name }} >= {{ bound }}) {return;}{% endif %}{% endmacro %}{% if vec4PerThread > 1 %}const ITEMS: u32 = {{ vec4PerThread }}u;
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273{"domain": "ai.onnx","name": "BitwiseOr","sinceVersion": 18,"inputs": { "a": { "onnx": "A", "dtype": "T" }, "b": { "onnx": "B", "dtype": "T" } },"outputs": {"c": { "onnx": "C", "dtype": "T", "rank": "max(ranks.a, ranks.b)", "shape": "broadcastShape(shapes.a, shapes.b)" }},"typeConstraints": { "T": ["uint32", "int32", "int16", "uint8", "int8"] },"tunables": { "WORKGROUP_SIZE": { "default": 256 } },"variants": [{"id": "same_shape_vec4","priority": 20,"when": ["tensorDtypes.a == tensorDtypes.b", "tensorDtypes.a == tensorDtypes.c", "sameShape(shapes.a, shapes.c)", "sameShape(shapes.b, shapes.c)", "numel(shapes.c) > 0", "numel(shapes.c) % 4 == 0"],"derive": { "vectorScalar": "\"vec4<\" ~ dtypes.T ~ \">\"" },"passes": [{"id": "main","name": "BitwiseOr.Vec4","shader": "bitwise-binary-vec4.wgsl.jinja","derive": {"cDtype": "tensorDtypes.c","vec4PerThread": "4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"},"bindings": ["a", "b", "c_bitwise", "params"],"dispatch": {"x": "min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)","y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)","z": 1}}]},{"id": "broadcast","when": ["tensorDtypes.a == tensorDtypes.b", "tensorDtypes.a == tensorDtypes.c", "ranks.a <= ranks.c", "ranks.b <= ranks.c"],"derive": { "logicalDtype": "tensorDtypes.c" },"passes": [{"id": "main","name": "BitwiseOr","shader": "bitwise-binary-broadcast.wgsl.jinja","derive": {"aShape": "shapes.a","bShape": "shapes.b","cShape": "shapes.c","aRank": "ranks.a","bRank": "ranks.b","cRank": "ranks.c","itemsPerInvocation": 4},"bindings": ["a_2_bitwise", "b_2_bitwise", "c_2_bitwise", "params_count"],"dispatch": {"x": "min(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)","y": "ceilDiv(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)","z": 1}}]}],"bindings": {"a": { "elementType": "$vectorScalar" },"b": { "elementType": "$vectorScalar" },"c_bitwise": { "elementType": "$vectorScalar", "name": "c" },"params": { "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.c) / 4" }] },"a_2_bitwise": { "name": "a", "elementType": "$T" },"b_2_bitwise": { "name": "b", "elementType": "$T" },"c_2_bitwise": { "name": "c", "elementType": "$T" },"params_count": { "name": "params", "struct": [{ "name": "count", "type": "u32", "value": "numel(shapes.c)" }] }}}1{"domain":"ai.onnx","name":"BitwiseOr","sinceVersion":18,"inputs":{"a":{"onnx":"A","dtype":"T"},"b":{"onnx":"B","dtype":"T"}},"outputs":{"c":{"onnx":"C","dtype":"T","rank":"max(ranks.a, ranks.b)","shape":"broadcastShape(shapes.a, shapes.b)"}},"typeConstraints":{"T":["uint32","int32","int16","uint8","int8"]},"tunables":{"WORKGROUP_SIZE":{"default":256}},"when":["tensorDtypes.a == tensorDtypes.b","tensorDtypes.a == tensorDtypes.c"],"variants":[{"id":"same_shape_vec4","priority":20,"when":["sameShape(shapes.a, shapes.c)","sameShape(shapes.b, shapes.c)","numel(shapes.c) > 0","numel(shapes.c) % 4 == 0"],"derive":{"vectorScalar":"\"vec4<\" ~ dtypes.T ~ \">\""},"passes":[{"id":"main","name":"BitwiseOr.Vec4","shader":"bitwise-binary-vec4.wgsl.jinja","derive":{"cDtype":"tensorDtypes.c","vec4PerThread":"4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1"},"bindings":["a","b","c_bitwise","params"],"dispatch":{"x":"min(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((ceilDiv(numel(shapes.c) / 4, 4 if numel(shapes.c) * dtypeBytes(tensorDtypes.c) <= 16777216 else 1)), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]},{"id":"broadcast","when":["ranks.a <= ranks.c","ranks.b <= ranks.c"],"derive":{"logicalDtype":"tensorDtypes.c"},"passes":[{"id":"main","name":"BitwiseOr","shader":"bitwise-binary-broadcast.wgsl.jinja","derive":{"aShape":"shapes.a","bShape":"shapes.b","cShape":"shapes.c","aRank":"ranks.a","bRank":"ranks.b","cRank":"ranks.c","itemsPerInvocation":4},"bindings":["a_2_bitwise","b_2_bitwise","c_2_bitwise","params_count"],"dispatch":{"x":"min(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((ceilDiv(numel(shapes.c), 4)), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]}],"bindings":{"a":{"elementType":"$vectorScalar"},"b":{"elementType":"$vectorScalar"},"c_bitwise":{"elementType":"$vectorScalar","name":"c"},"params":{"struct":[{"name":"count","type":"u32","value":"numel(shapes.c) / 4"}]},"a_2_bitwise":{"name":"a","elementType":"$T"},"b_2_bitwise":{"name":"b","elementType":"$T"},"c_2_bitwise":{"name":"c","elementType":"$T"},"params_count":{"name":"params","struct":[{"name":"count","type":"u32","value":"numel(shapes.c)"}]}}}
12345678910111213141516171819202122232425{"name": "ai.onnx.BitwiseOr","id": "_ai_onnx_bitwiseor_webgpu_4aacf5f","version": 1,"license": "Apache-2.0","backend": { "type": "webgpu" },"digest": {"algorithm": "sha256","files": {"bench.json": "mERKODQEQmulEut7roCKqmrmyS+N1AQRVcIWVUTpnwc=","bitwise-binary-broadcast.wgsl.jinja": "8Kpsu5+j9W4G5daZWs9Qt7p8btm35ZTZ+bCb3n6u4Fs=","bitwise-binary-vec4.wgsl.jinja": "mvuU+HilQUkhsL6C1zSIZNYXwhB008hau9kKUoaHKKc=","manifest.json": "adG6Jvfbrpp1JMSdDng3XWQuoqCBcxkWipnf73O0qto=","test.json": "fpTB2xj4oqysAwu5FTEzIpD5VBFBDkhdAg6W5jvQ7J0="}},"provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } },"webgpu": {"manifestSpec": "2.1","variants": {"same_shape_vec4": ["bitwise-binary-vec4.wgsl.jinja"],"broadcast": ["bitwise-binary-broadcast.wgsl.jinja"]}}}1{"name":"ai.onnx.BitwiseOr","id":"_ai_onnx_bitwiseor_webgpu_cd005ef","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"mERKODQEQmulEut7roCKqmrmyS+N1AQRVcIWVUTpnwc=","bitwise-binary-broadcast.wgsl.jinja":"jcsA/StBeLSadM7TmSVisLRJMxTvp4aWSp1dtPxqjeM=","bitwise-binary-vec4.wgsl.jinja":"vucYB2lDiMV9v4nqYlg6amYyWfqJ//JpBbXOZsv29PU=","manifest.json":"6Q8mesFMHFj6iH9MVsFAqkd8HWJ0tz94U7HHdPQfaeA=","test.json":"fpTB2xj4oqysAwu5FTEzIpD5VBFBDkhdAg6W5jvQ7J0="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}
README.md+14-9
build/webgpu/bitwise-binary-broadcast.wgsl.jinja+1-1
build/webgpu/bitwise-binary-vec4.wgsl.jinja+5-4
build/webgpu/manifest.json+1-73
build/webgpu/metadata.json+1-25