sync 4385228f788d
Browse filesFiles changed (6)
55 unmodified lines565758596061626364656667686970596061626374757677787980646566676869707172737485757677787980818283849394858687888990919293949596979855 unmodified lines
One implementation is selected per call from the device capabilities, the request shapes and the dtypes; these notes say what each one covers.
- `dp4a_pointwise_1x1_tail` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_tail_x_zero_point_only` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_tail_w_zero_point_only` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_tail_no_zero_points` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_x_zero_point_only` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_w_zero_point_only` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_no_zero_points` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_tail_per_channel` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_tail_per_channel_w_zero_point_only` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_per_channel` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_pointwise_1x1_per_channel_w_zero_point_only` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile resources and dispatch eligibility follow device limits.- `dp4a_im2col_scalar_zero_points` — Materializes widened int8 im2col columns for an ungrouped 2D or 3D convolution with scalar zero points, then multiplies them with packed DP4A dots.- `dp4a_pointwise_1x1`, `dp4a_pointwise_1x1_per_channel` — Exact tiled pointwise convolution for one or two spatial dimensions. Native packed dots or exact integer-vector dots share zero-point specialization; tile and dispatch sizes stay within device limits.
## 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- [`conv-int-accumulate-spatial.wgsl.jinja`](build/webgpu/conv-int-accumulate-spatial.wgsl.jinja)- [`conv-int-im2col-spatial.wgsl.jinja`](build/webgpu/conv-int-im2col-spatial.wgsl.jinja)- [`quant-dp4a-matmul.wgsl.jinja`](build/webgpu/quant-dp4a-matmul.wgsl.jinja)- [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.ConvInteger/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)- [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.ConvInteger/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.ConvInteger/blob/v1/build/webgpu/test.json) — correctness cases- [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.ConvInteger/blob/v1/build/webgpu/bench.json) — benchmark cases- [`conv-int-accumulate-spatial.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.ConvInteger/blob/v1/build/webgpu/conv-int-accumulate-spatial.wgsl.jinja)- [`conv-int-im2col-spatial.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.ConvInteger/blob/v1/build/webgpu/conv-int-im2col-spatial.wgsl.jinja)- [`quant-dp4a-matmul.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/ai.onnx.ConvInteger/blob/v1/build/webgpu/quant-dp4a-matmul.wgsl.jinja)
## Use with `@huggingface/kernels`
```shnpm install --save-exact @huggingface/kernels@0.0.1-preview.3npm 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`.
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.ConvInteger", { version: 1 });
const xData = Uint8Array.of(2, 5);const wData = Uint8Array.of(3);
const { y } = await kernel({ x: { data: xData, shape: [1, 1, 2, 1, 1] }, w: { data: wData, shape: [1, 1, 1, 1, 1] },});console.log({ y });```29 unmodified lines3031323333343536373838394041424344424546444748464950515211 unmodified lines646566646768697029 unmodified lines return 0; {% endif %}}{% endmacro %}{% macro flat_index_2d(workgroupSize, name="i", bound="params.count", guardInline=false) %}{% 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 ({{ name }} >= {{ bound }}) { return; }{% endmacro %} if ({{ name }} >= {{ bound }}) { return; }{% endmacro %}{{ env.wgsl.resourceDeclarations }}
fn read_x(index: u32) -> i32 { {% if xUnsigned %}{% if xUnsigned %} return i32(x[index]); {% else %}{% else %} return x[index]; {% endif %}{% endif %}}
fn read_w(index: u32) -> i32 {11 unmodified lines
@compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})fn main(@builtin(global_invocation_id) gid: vec3<u32>) {{{ flat_index_2d(tunables.WORKGROUP_SIZE, "index", guardInline=true) }}{{ flat_index_2d(tunables.WORKGROUP_SIZE, "index") }} let ow = index % params.outW; var t = index / params.outW; let oh = t % params.outH;4 unmodified lines56789101189104 unmodified lines * Optional extra K rows contain the raw input zero point to align the DP4A * reduction. */{{ env.wgsl.resourceDeclarations }}{% set kernelDSpec = kernelDSpec | default(1) %}{% set strideDSpec = strideDSpec | default(1) %}{% set dilationDSpec = dilationDSpec | default(1) %}{% set padFrontSpec = padFrontSpec | default(0) %}{% macro spatial_constants() %}{% if spatialRankSpec == 3 %}
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818821{ "domain": "ai.onnx", "name": "ConvInteger", "sinceVersion": 10, "inputs": { "x": { "dtype": "TX" }, "w": { "dtype": "TW" }, "x_zero_point": { "dtype": "TX", "optional": true }, "w_zero_point": { "dtype": "TW", "optional": true } }, "outputs": { "y": { "dtype": "TY", "rank": "ranks.x", "shape": "[dim(shapes.x, 0), dim(shapes.w, 0), expectedOutputWidth] if ranks.x == 3 else ([dim(shapes.x, 0), dim(shapes.w, 0), expectedOutputHeight, expectedOutputWidth] if ranks.x == 4 else [dim(shapes.x, 0), dim(shapes.w, 0), expectedOutputDepth, expectedOutputHeight, expectedOutputWidth])" } }, "attributes": { "auto_pad": { "default": "NOTSET" }, "group": { "default": 1 }, "dilations": {}, "kernel_shape": {}, "pads": {}, "strides": {} }, "attributeConstraints": { "auto_pad": { "values": ["NOTSET", "SAME_UPPER", "SAME_LOWER", "VALID"] } }, "typeConstraints": { "TX": ["uint8", "int8"], "TW": ["uint8", "int8"], "TY": ["int32"] }, "tunables": { "WORKGROUP_SIZE": { "default": 256 } }, "derive": { "inputDepth": "dim(shapes.x, 2) if ranks.x == 5 else 1", "inputHeight": "dim(shapes.x, 3) if ranks.x == 5 else (dim(shapes.x, 2) if ranks.x == 4 else 1)", "inputWidth": "dim(shapes.x, ranks.x - 1) if ranks.x >= 3 else 1", "outputDepth": "dim(shapes.y, 2) if ranks.y == 5 else 1", "outputHeight": "dim(shapes.y, 3) if ranks.y == 5 else (dim(shapes.y, 2) if ranks.y == 4 else 1)", "outputWidth": "dim(shapes.y, ranks.y - 1) if ranks.y >= 3 else 1", "kernelDepth": "dim(shapes.w, 2) if ranks.w == 5 else 1", "kernelHeight": "dim(shapes.w, 3) if ranks.w == 5 else (dim(shapes.w, 2) if ranks.w == 4 else 1)", "kernelWidth": "dim(shapes.w, ranks.w - 1) if ranks.w >= 3 else 1", "spatialRank": "ranks.w - 2", "kernelShapeLengthOk": "not has(attrs, \"kernel_shape\") or (attrs.kernel_shape | length) == spatialRank", "stridesLengthOk": "not has(attrs, \"strides\") or (attrs.strides | length) == spatialRank", "dilationsLengthOk": "not has(attrs, \"dilations\") or (attrs.dilations | length) == spatialRank", "padsLengthOk": "not has(attrs, \"pads\") or (attrs.pads | length) == 2 * spatialRank", "kernelD": "attrs.kernel_shape[0] if kernelShapeLengthOk and has(attrs, \"kernel_shape\") and spatialRank == 3 else 1", "kernelH": "attrs.kernel_shape[spatialRank - 2] if kernelShapeLengthOk and has(attrs, \"kernel_shape\") and spatialRank >= 2 else 1", "kernelW": "attrs.kernel_shape[spatialRank - 1] if kernelShapeLengthOk and has(attrs, \"kernel_shape\") and spatialRank >= 1 else 1", "strideD": "attrs.strides[0] if stridesLengthOk and has(attrs, \"strides\") and spatialRank == 3 else 1", "strideH": "attrs.strides[spatialRank - 2] if stridesLengthOk and has(attrs, \"strides\") and spatialRank >= 2 else 1", "strideW": "attrs.strides[spatialRank - 1] if stridesLengthOk and has(attrs, \"strides\") and spatialRank >= 1 else 1", "dilationD": "attrs.dilations[0] if dilationsLengthOk and has(attrs, \"dilations\") and spatialRank == 3 else 1", "dilationH": "attrs.dilations[spatialRank - 2] if dilationsLengthOk and has(attrs, \"dilations\") and spatialRank >= 2 else 1", "dilationW": "attrs.dilations[spatialRank - 1] if dilationsLengthOk and has(attrs, \"dilations\") and spatialRank >= 1 else 1", "padFront": "attrs.pads[0] if padsLengthOk and has(attrs, \"pads\") and spatialRank == 3 else 0", "padTop": "attrs.pads[spatialRank - 2] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 2 else 0", "padLeft": "attrs.pads[spatialRank - 1] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 1 else 0", "padBack": "attrs.pads[spatialRank] if padsLengthOk and has(attrs, \"pads\") and spatialRank == 3 else 0", "padBottom": "attrs.pads[2 * spatialRank - 2] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 2 else 0", "padRight": "attrs.pads[2 * spatialRank - 1] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 1 else 0", "autoPadSame": "attrs.auto_pad == \"SAME_UPPER\" or attrs.auto_pad == \"SAME_LOWER\"", "autoPadValid": "attrs.auto_pad == \"VALID\"", "samePadDepth": "max(0, (outputDepth - 1) * strideD + (kernelDepth - 1) * dilationD + 1 - inputDepth)", "samePadHeight": "max(0, (outputHeight - 1) * strideH + (kernelHeight - 1) * dilationH + 1 - inputHeight)", "samePadWidth": "max(0, (outputWidth - 1) * strideW + (kernelWidth - 1) * dilationW + 1 - inputWidth)", "samePadFront": "floor(samePadDepth / 2) if attrs.auto_pad == \"SAME_UPPER\" else samePadDepth - floor(samePadDepth / 2)", "samePadTop": "floor(samePadHeight / 2) if attrs.auto_pad == \"SAME_UPPER\" else samePadHeight - floor(samePadHeight / 2)", "samePadLeft": "floor(samePadWidth / 2) if attrs.auto_pad == \"SAME_UPPER\" else samePadWidth - floor(samePadWidth / 2)", "effectivePadFront": "samePadFront if autoPadSame else (0 if autoPadValid else padFront)", "effectivePadTop": "samePadTop if autoPadSame else (0 if autoPadValid else padTop)", "effectivePadLeft": "samePadLeft if autoPadSame else (0 if autoPadValid else padLeft)", "expectedOutputDepth": "ceil(inputDepth / strideD) if autoPadSame else floor((inputDepth + (0 if autoPadValid else padFront + padBack) - ((kernelDepth - 1) * dilationD + 1)) / strideD) + 1", "expectedOutputHeight": "ceil(inputHeight / strideH) if autoPadSame else floor((inputHeight + (0 if autoPadValid else padTop + padBottom) - ((kernelHeight - 1) * dilationH + 1)) / strideH) + 1", "expectedOutputWidth": "ceil(inputWidth / strideW) if autoPadSame else floor((inputWidth + (0 if autoPadValid else padLeft + padRight) - ((kernelWidth - 1) * dilationW + 1)) / strideW) + 1", "spatialAttributeLengthsOk": "kernelShapeLengthOk and stridesLengthOk and dilationsLengthOk and padsLengthOk", "kernelShapeMatchesWeights": "not has(attrs, \"kernel_shape\") or (kernelW == kernelWidth and (spatialRank < 2 or kernelH == kernelHeight) and (spatialRank < 3 or kernelD == kernelDepth))", "kernelExtentsOk": "kernelWidth >= 1 and (spatialRank < 2 or kernelHeight >= 1) and (spatialRank < 3 or kernelDepth >= 1)", "stridesValuesOk": "not has(attrs, \"strides\") or (strideD >= 1 and floor(strideD) == strideD and strideH >= 1 and floor(strideH) == strideH and strideW >= 1 and floor(strideW) == strideW)", "dilationsValuesOk": "not has(attrs, \"dilations\") or (dilationD >= 1 and floor(dilationD) == dilationD and dilationH >= 1 and floor(dilationH) == dilationH and dilationW >= 1 and floor(dilationW) == dilationW)", "padsValuesOk": "padFront >= 0 and floor(padFront) == padFront and padTop >= 0 and floor(padTop) == padTop and padLeft >= 0 and floor(padLeft) == padLeft and padBack >= 0 and floor(padBack) == padBack and padBottom >= 0 and floor(padBottom) == padBottom and padRight >= 0 and floor(padRight) == padRight", "explicitPadsOk": "attrs.auto_pad == \"NOTSET\" or not has(attrs, \"pads\")", "spatialAttributesOk": "spatialRank >= 1 and spatialRank <= 3 and spatialAttributeLengthsOk and kernelShapeMatchesWeights and kernelExtentsOk and stridesValuesOk and dilationsValuesOk and padsValuesOk and explicitPadsOk", "packedFeature": "device.wgslLanguageFeatures.has(\"packed_4x8_integer_dot_product\")", "rank4TensorOk": "spatialAttributesOk and (ranks.x == 4 and ranks.w == 4 and ranks.y == 4)", "outputBatchChannelsOk": "dim(shapes.y, 0) == dim(shapes.x, 0) and dim(shapes.y, 1) == dim(shapes.w, 0)", "groupChannelsOk": "attrs.group >= 1 and dim(shapes.w, 1) * attrs.group == dim(shapes.x, 1) and dim(shapes.w, 0) % attrs.group == 0", "output2dShapeOk": "dim(shapes.y, 2) == expectedOutputHeight and dim(shapes.y, 3) == expectedOutputWidth", "aScalar": "\"u32\" if tensorDtypes.w == \"uint8\" else \"i32\"", "bScalar": "\"u32\" if tensorDtypes.x == \"uint8\" else \"i32\"", "wScalar": "\"u32\" if tensorDtypes.w == \"uint8\" else \"i32\"", "xScalar": "\"u32\" if tensorDtypes.x == \"uint8\" else \"i32\"", "aUnsigned": "tensorDtypes.w == \"uint8\"", "bUnsigned": "tensorDtypes.x == \"uint8\"", "wUnsigned": "tensorDtypes.w == \"uint8\"", "xUnsigned": "tensorDtypes.x == \"uint8\"", "bZeroPerColumn": false, "rank5TensorOk": "spatialAttributesOk and (ranks.x == 5 and ranks.w == 5 and ranks.y == 5)", "scalarXZeroOk": "ranks.x_zero_point == 0 or (ranks.x_zero_point == 1 and dim(shapes.x_zero_point, 0) == 1)", "scalarWZeroOk": "ranks.w_zero_point == 0 or (ranks.w_zero_point == 1 and dim(shapes.w_zero_point, 0) == 1)", "scalarXZeroRequiredOk": "present.x_zero_point and scalarXZeroOk", "scalarWZeroRequiredOk": "present.w_zero_point and scalarWZeroOk", "ungroupedChannelsOk": "attrs.group == 1 and dim(shapes.w, 1) == dim(shapes.x, 1)", "output3dShapeOk": "dim(shapes.y, 2) == expectedOutputDepth and dim(shapes.y, 3) == expectedOutputHeight and dim(shapes.y, 4) == expectedOutputWidth", "rank3TensorOk": "spatialAttributesOk and (ranks.x == 3 and ranks.w == 3 and ranks.y == 3)", "nchwTensorOk": "rank4TensorOk or rank3TensorOk", "output1dShapeOk": "dim(shapes.y, 2) == expectedOutputWidth", "outputSpatialShapeOk": "output2dShapeOk if rank4TensorOk else output1dShapeOk", "zeroPointsOmitted": "not present.x_zero_point and not present.w_zero_point", "pointwiseTileM": 8, "pointwiseTileN": 64, "pointwiseKtWords": 32, "pointwiseResourcesOk": "pointwiseTileN <= min(device.limits.maxComputeWorkgroupSizeX, device.limits.maxComputeInvocationsPerWorkgroup) and 4 * pointwiseTileM * (pointwiseKtWords + 1) <= device.limits.maxComputeWorkgroupStorageSize", "pointwiseDispatchOk": "ceilDiv(outputHeight * outputWidth, pointwiseTileN) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and ceilDiv(dim(shapes.w, 0), pointwiseTileM) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and dim(shapes.y, 0) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "aVec4": "\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\"" }, "when": ["outputBatchChannelsOk"], "bindings": { "x": { "elementType": "$bScalar" }, "x_zero_point": { "elementType": "$bScalar", "length": 1 }, "cols": { "scratch": "cols3d", "elementType": "$bScalar" }, "params": { "struct": [ { "name": "outCount", "type": "u32", "value": "dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4)" }, { "name": "inChannels", "type": "u32", "value": "dim(shapes.x, 1)" }, { "name": "inD", "type": "u32", "value": "dim(shapes.x, 2)" }, { "name": "inH", "type": "u32", "value": "dim(shapes.x, 3)" }, { "name": "inW", "type": "u32", "value": "dim(shapes.x, 4)" }, { "name": "kRows", "type": "u32", "value": "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4)" }, { "name": "outH", "type": "u32", "value": "dim(shapes.y, 3)" }, { "name": "outW", "type": "u32", "value": "dim(shapes.y, 4)" } ] }, "cols_im2col": { "name": "cols", "buffer": "storage", "elementType": "$bScalar" }, "params_im2col": { "name": "params", "struct": [ { "name": "outCount", "type": "u32", "value": "dim(shapes.y, 2) * dim(shapes.y, 3)" }, { "name": "inChannels", "type": "u32", "value": "dim(shapes.x, 1)" }, { "name": "inH", "type": "u32", "value": "dim(shapes.x, 2)" }, { "name": "inW", "type": "u32", "value": "dim(shapes.x, 3)" }, { "name": "kRows", "type": "u32", "value": "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3)" }, { "name": "outW", "type": "u32", "value": "dim(shapes.y, 3)" } ] }, "a": { "arg": "w", "elementType": "$aVec4" }, "b": { "scratch": "cols3d", "buffer": "read-only-storage", "elementType": "$bScalar" }, "a_zero_point": { "arg": "w_zero_point", "elementType": "$aScalar", "length": 1 }, "b_zero_point": { "arg": "x_zero_point", "elementType": "$bScalar", "length": 1 }, "y": { "elementType": "i32" }, "params_main": { "name": "params", "struct": [ { "name": "M", "type": "u32", "value": "dim(shapes.w, 0)" }, { "name": "N", "type": "u32", "value": "dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4)" }, { "name": "K", "type": "u32", "value": "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4)" }, { "name": "aBatchStride4", "type": "u32", "value": 0 }, { "name": "bBatchStride", "type": "u32", "value": "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) * dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4)" }, { "name": "yBatchStride", "type": "u32", "value": "dim(shapes.w, 0) * dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4)" } ] }, "b_main": { "scratch": "cols", "name": "b", "buffer": "read-only-storage", "elementType": "$bScalar" }, "params__uniform": { "name": "params", "struct": [ { "name": "M", "type": "u32", "value": "dim(shapes.w, 0)" }, { "name": "N", "type": "u32", "value": "dim(shapes.y, 2) * dim(shapes.y, 3)" }, { "name": "K", "type": "u32", "value": "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3)" }, { "name": "aBatchStride4", "type": "u32", "value": 0 }, { "name": "bBatchStride", "type": "u32", "value": "(dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3)) * (dim(shapes.y, 2) * dim(shapes.y, 3))" }, { "name": "yBatchStride", "type": "u32", "value": "dim(shapes.w, 0) * dim(shapes.y, 2) * dim(shapes.y, 3)" } ] }, "a_w": { "arg": "w", "name": "a", "elementType": "$aScalar" }, "b_x": { "arg": "x", "name": "b", "elementType": "$bScalar" }, "params_quant_dp4a_matmul": { "name": "params", "struct": [ { "name": "M", "type": "u32", "value": "dim(shapes.w, 0)" }, { "name": "N", "type": "u32", "value": "outputHeight * outputWidth" }, { "name": "K", "type": "u32", "value": "dim(shapes.x, 1)" }, { "name": "aBatchStride4", "type": "u32", "value": 0 }, { "name": "bBatchStride", "type": "u32", "value": "dim(shapes.x, 1) * inputHeight * inputWidth" }, { "name": "yBatchStride", "type": "u32", "value": "dim(shapes.w, 0) * outputHeight * outputWidth" } ] }, "x_main": { "name": "x", "elementType": "$xScalar" }, "w": { "elementType": "$wScalar" }, "x_zero_point_main": { "name": "x_zero_point", "elementType": "$xScalar", "length": 1 }, "w_zero_point": { "elementType": "$wScalar" }, "params_nchw2d_x_zero_point_only": { "name": "params", "struct": [ { "name": "inChannels", "type": "u32", "value": "dim(shapes.x, 1)" }, { "name": "inH", "type": "u32", "value": "inputHeight" }, { "name": "inW", "type": "u32", "value": "inputWidth" }, { "name": "outChannels", "type": "u32", "value": "dim(shapes.w, 0)" }, { "name": "weightInChannels", "type": "u32", "value": "dim(shapes.w, 1)" }, { "name": "inChannelsPerGroup", "type": "u32", "value": "dim(shapes.x, 1) / attrs.group" }, { "name": "outChannelsPerGroup", "type": "u32", "value": "dim(shapes.w, 0) / attrs.group" }, { "name": "kernelH", "type": "u32", "value": "kernelHeight" }, { "name": "kernelW", "type": "u32", "value": "kernelWidth" }, { "name": "outH", "type": "u32", "value": "outputHeight" }, { "name": "outW", "type": "u32", "value": "outputWidth" }, { "name": "strideH", "type": "u32", "value": "strideH" }, { "name": "strideW", "type": "u32", "value": "strideW" }, { "name": "dilationH", "type": "u32", "value": "dilationH" }, { "name": "dilationW", "type": "u32", "value": "dilationW" }, { "name": "padH", "type": "i32", "value": "effectivePadTop" }, { "name": "padW", "type": "i32", "value": "effectivePadLeft" }, { "name": "count", "type": "u32", "value": "numel(shapes.y)" } ] }, "w_zero_point_main": { "name": "w_zero_point", "elementType": "$wScalar", "length": 1 }, "params_ncdhw3d_x_zero_point_only": { "name": "params", "struct": [ { "name": "inChannels", "type": "u32", "value": "dim(shapes.x, 1)" }, { "name": "inD", "type": "u32", "value": "dim(shapes.x, 2)" }, { "name": "inH", "type": "u32", "value": "dim(shapes.x, 3)" }, { "name": "inW", "type": "u32", "value": "dim(shapes.x, 4)" }, { "name": "outChannels", "type": "u32", "value": "dim(shapes.w, 0)" }, { "name": "weightInChannels", "type": "u32", "value": "dim(shapes.w, 1)" }, { "name": "inChannelsPerGroup", "type": "u32", "value": "dim(shapes.x, 1) / attrs.group" }, { "name": "outChannelsPerGroup", "type": "u32", "value": "dim(shapes.w, 0) / attrs.group" }, { "name": "kernelD", "type": "u32", "value": "dim(shapes.w, 2)" }, { "name": "kernelH", "type": "u32", "value": "dim(shapes.w, 3)" }, { "name": "kernelW", "type": "u32", "value": "dim(shapes.w, 4)" }, { "name": "outD", "type": "u32", "value": "dim(shapes.y, 2)" }, { "name": "outH", "type": "u32", "value": "dim(shapes.y, 3)" }, { "name": "outW", "type": "u32", "value": "dim(shapes.y, 4)" }, { "name": "strideD", "type": "u32", "value": "strideD" }, { "name": "strideH", "type": "u32", "value": "strideH" }, { "name": "strideW", "type": "u32", "value": "strideW" }, { "name": "dilationD", "type": "u32", "value": "dilationD" }, { "name": "dilationH", "type": "u32", "value": "dilationH" }, { "name": "dilationW", "type": "u32", "value": "dilationW" }, { "name": "padD", "type": "i32", "value": "effectivePadFront" }, { "name": "padH", "type": "i32", "value": "effectivePadTop" }, { "name": "padW", "type": "i32", "value": "effectivePadLeft" }, { "name": "count", "type": "u32", "value": "numel(shapes.y)" } ] }, "a_zero_point_per_row": { "arg": "w_zero_point", "name": "a_zero_point", "elementType": "$aScalar" } }, "variants": [ { "id": "dp4a_im2col_ncdhw3d_scalar_zero_points", "priority": 20, "when": ["packedFeature", "rank5TensorOk", "scalarXZeroRequiredOk", "scalarWZeroRequiredOk", "ungroupedChannelsOk", "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) % 4 == 0", "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) >= 32", "dim(shapes.w, 0) >= 8", "dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4) >= 256", "output3dShapeOk", "dim(shapes.x, 0) * dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) * dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4) * 4 <= device.limits.maxStorageBufferBindingSize", "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "ceilDiv(dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4), tunables.WORKGROUP_SIZE) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "ceilDiv(dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4), 64) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "ceilDiv(dim(shapes.w, 0), 8) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "dim(shapes.x, 0) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)"], "derive": { "hasAZero": true, "hasBZero": true, "aPacked": true, "aZeroPerRow": false, "tileM": 8, "tileN": 64, "ktWords": 32, "hasBias": false }, "intermediates": [ { "id": "cols3d", "dtype": "int32", "shape": "[dim(shapes.x, 0) * dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) * dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4)]" } ], "passes": [ { "id": "im2col", "name": "ConvInteger.Im2Col3d", "shader": "conv-int-im2col-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 3, "kernelDSpec": "dim(shapes.w, 2)", "kernelHSpec": "dim(shapes.w, 3)", "kernelWSpec": "dim(shapes.w, 4)", "strideDSpec": "strideD", "strideHSpec": "strideH", "strideWSpec": "strideW", "dilationDSpec": "dilationD", "dilationHSpec": "dilationH", "dilationWSpec": "dilationW", "padFrontSpec": "effectivePadFront", "padTopSpec": "effectivePadTop", "padLeftSpec": "effectivePadLeft" }, "bindings": ["x", "x_zero_point", "cols", "params"], "dispatch": { "x": "ceil(dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4) / tunables.WORKGROUP_SIZE)", "y": "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4)", "z": "dim(shapes.x, 0)" } }, { "id": "main", "name": "ConvInteger.Im2Col3dDp4a", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b", "a_zero_point", "b_zero_point", "y", "params_main"], "dispatch": { "x": "ceil(dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4) / 64)", "y": "ceil(dim(shapes.w, 0) / 8)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_im2col_nchw_scalar_zero_points", "priority": 20, "when": ["packedFeature", "rank4TensorOk", "scalarXZeroRequiredOk", "scalarWZeroRequiredOk", "ungroupedChannelsOk", "(dim(shapes.w, 2) > 1 or dim(shapes.w, 3) > 1)", "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) % 4 == 0", "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) >= 64", "numel(shapes.y) >= 8192", "dim(shapes.y, 2) * dim(shapes.y, 3) <= 4194240", "dim(shapes.w, 0) <= 524280", "dim(shapes.y, 0) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)"], "derive": { "hasAZero": true, "hasBZero": true, "tileM": 8, "tileN": 64, "ktWords": 32 }, "intermediates": [ { "id": "cols", "dtype": "int32", "shape": "[dim(shapes.x, 0) * (dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3)) * (dim(shapes.y, 2) * dim(shapes.y, 3))]" } ], "passes": [ { "id": "im2col", "name": "ConvInteger.Im2Col", "shader": "conv-int-im2col-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 2, "kernelHSpec": "dim(shapes.w, 2)", "kernelWSpec": "dim(shapes.w, 3)", "strideHSpec": "strideH", "strideWSpec": "strideW", "dilationHSpec": "dilationH", "dilationWSpec": "dilationW", "padTopSpec": "effectivePadTop", "padLeftSpec": "effectivePadLeft" }, "bindings": ["x", "x_zero_point", "cols_im2col", "params_im2col"], "dispatch": { "x": "ceil(dim(shapes.y, 2) * dim(shapes.y, 3) / tunables.WORKGROUP_SIZE)", "y": "dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3)", "z": "dim(shapes.x, 0)" } }, { "id": "main", "name": "ConvInteger.Im2ColDp4a", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b_main", "a_zero_point", "b_zero_point", "y", "params__uniform"], "dispatch": { "x": "ceil(dim(shapes.y, 2) * dim(shapes.y, 3) / 64)", "y": "ceil(dim(shapes.w, 0) / 8)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_tail", "priority": 21, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "scalarXZeroRequiredOk", "scalarWZeroRequiredOk", "dim(shapes.x, 1) >= 32", "dim(shapes.x, 1) % 4 != 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "hasAZero": true, "hasBZero": true, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aPacked": false }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwiseTail", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a_w", "b_x", "a_zero_point", "b_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_tail_x_zero_point_only", "priority": 21, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "scalarXZeroRequiredOk", "not present.w_zero_point", "dim(shapes.x, 1) >= 32", "dim(shapes.x, 1) % 4 != 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "hasAZero": false, "hasBZero": true, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aPacked": false }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwiseTail", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a_w", "b_x", "b_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_tail_w_zero_point_only", "priority": 21, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "not present.x_zero_point", "scalarWZeroRequiredOk", "dim(shapes.x, 1) >= 32", "dim(shapes.x, 1) % 4 != 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "hasAZero": true, "hasBZero": false, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aPacked": false }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwiseTail", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a_w", "b_x", "a_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_tail_no_zero_points", "priority": 21, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "not present.x_zero_point", "not present.w_zero_point", "dim(shapes.x, 1) >= 32", "dim(shapes.x, 1) % 4 != 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "hasAZero": false, "hasBZero": false, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aPacked": false }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwiseTail", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a_w", "b_x", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1", "priority": 20, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "scalarXZeroRequiredOk", "scalarWZeroRequiredOk", "dim(shapes.x, 1) % 4 == 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "aVec4": "\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\"", "hasAZero": true, "hasBZero": true, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords" }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwise", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b_x", "a_zero_point", "b_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_x_zero_point_only", "priority": 20, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "scalarXZeroRequiredOk", "not present.w_zero_point", "dim(shapes.x, 1) % 4 == 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "aVec4": "\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\"", "hasAZero": false, "hasBZero": true, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords" }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwise", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b_x", "b_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_w_zero_point_only", "priority": 20, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "not present.x_zero_point", "scalarWZeroRequiredOk", "dim(shapes.x, 1) % 4 == 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "aVec4": "\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\"", "hasAZero": true, "hasBZero": false, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords" }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwise", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b_x", "a_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_no_zero_points", "priority": 20, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "not present.x_zero_point", "not present.w_zero_point", "dim(shapes.x, 1) % 4 == 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "aVec4": "\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\"", "hasAZero": false, "hasBZero": false, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords" }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwise", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b_x", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_tail_per_channel", "priority": 21, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "scalarXZeroRequiredOk", "present.w_zero_point", "ranks.w_zero_point == 1", "dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)", "dim(shapes.x, 1) >= 32", "dim(shapes.x, 1) % 4 != 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "hasAZero": true, "hasBZero": true, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aPacked": false, "aZeroPerRow": true }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwiseTail", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a_w", "b_x", "a_zero_point_per_row", "b_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_tail_per_channel_w_zero_point_only", "priority": 21, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "not present.x_zero_point", "present.w_zero_point", "ranks.w_zero_point == 1", "dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)", "dim(shapes.x, 1) >= 32", "dim(shapes.x, 1) % 4 != 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "hasAZero": true, "hasBZero": false, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aPacked": false, "aZeroPerRow": true }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwiseTail", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a_w", "b_x", "a_zero_point_per_row", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_per_channel", "priority": 20, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "scalarXZeroRequiredOk", "present.w_zero_point", "ranks.w_zero_point == 1", "dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)", "dim(shapes.x, 1) % 4 == 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "aVec4": "\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\"", "hasAZero": true, "hasBZero": true, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aZeroPerRow": true }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwise", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b_x", "a_zero_point_per_row", "b_zero_point", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "dp4a_pointwise_1x1_per_channel_w_zero_point_only", "priority": 20, "when": ["nchwTensorOk", "ungroupedChannelsOk", "kernelHeight == 1", "kernelWidth == 1", "strideH == 1", "strideW == 1", "padTop == 0 and padBottom == 0", "padLeft == 0 and padRight == 0", "outputHeight == inputHeight", "outputWidth == inputWidth", "not present.x_zero_point", "present.w_zero_point", "ranks.w_zero_point == 1", "dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)", "dim(shapes.x, 1) % 4 == 0", "pointwiseResourcesOk", "pointwiseDispatchOk"], "derive": { "aVec4": "\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\"", "hasAZero": true, "hasBZero": false, "tileM": "pointwiseTileM", "tileN": "pointwiseTileN", "ktWords": "pointwiseKtWords", "aZeroPerRow": true }, "passes": [ { "id": "main", "name": "ConvInteger.Dp4aPointwise", "shader": "quant-dp4a-matmul.wgsl.jinja", "bindings": ["a", "b_x", "a_zero_point_per_row", "y", "params_quant_dp4a_matmul"], "dispatch": { "x": "ceilDiv(outputHeight * outputWidth, pointwiseTileN)", "y": "ceilDiv(dim(shapes.w, 0), pointwiseTileM)", "z": "dim(shapes.y, 0)" } } ] }, { "id": "nchw2d_per_channel_zero_point", "priority": 5, "when": ["nchwTensorOk", "scalarXZeroRequiredOk", "ranks.w_zero_point == 1", "dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)", "groupChannelsOk", "outputSpatialShapeOk"], "derive": { "wZeroPerChannel": true }, "passes": [ { "id": "main", "name": "ConvIntegerPerChannel", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 2, "xZeroOmitted": "false", "wZeroOmitted": "false" }, "bindings": ["x_main", "w", "x_zero_point_main", "w_zero_point", "y", "params_nchw2d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "nchw2d_per_channel_w_zero_point_only", "priority": 5, "when": ["nchwTensorOk", "not present.x_zero_point", "present.w_zero_point", "ranks.w_zero_point == 1", "dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)", "groupChannelsOk", "outputSpatialShapeOk"], "derive": { "wZeroPerChannel": true }, "passes": [ { "id": "main", "name": "ConvIntegerPerChannel", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 2, "xZeroOmitted": "true", "wZeroOmitted": "false" }, "bindings": ["x_main", "w", "w_zero_point", "y", "params_nchw2d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "nchw2d_scalar_zero_points", "when": ["nchwTensorOk", "scalarXZeroRequiredOk", "scalarWZeroRequiredOk", "groupChannelsOk", "outputSpatialShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 2, "xZeroOmitted": "false", "wZeroOmitted": "false" }, "bindings": ["x_main", "w", "x_zero_point_main", "w_zero_point_main", "y", "params_nchw2d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "nchw2d_x_zero_point_only", "when": ["nchwTensorOk", "present.x_zero_point", "not present.w_zero_point", "scalarXZeroRequiredOk", "groupChannelsOk", "outputSpatialShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 2, "xZeroOmitted": "false", "wZeroOmitted": "true" }, "bindings": ["x_main", "w", "x_zero_point_main", "y", "params_nchw2d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "nchw2d_w_zero_point_only", "when": ["nchwTensorOk", "not present.x_zero_point", "present.w_zero_point", "scalarWZeroRequiredOk", "groupChannelsOk", "outputSpatialShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 2, "xZeroOmitted": "true", "wZeroOmitted": "false" }, "bindings": ["x_main", "w", "w_zero_point_main", "y", "params_nchw2d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "ncdhw3d_scalar_zero_points", "when": ["rank5TensorOk", "scalarXZeroRequiredOk", "scalarWZeroRequiredOk", "groupChannelsOk", "output3dShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger3d", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 3, "xZeroOmitted": "false", "wZeroOmitted": "false" }, "bindings": ["x_main", "w", "x_zero_point_main", "w_zero_point_main", "y", "params_ncdhw3d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "ncdhw3d_x_zero_point_only", "when": ["rank5TensorOk", "scalarXZeroRequiredOk", "not present.w_zero_point", "groupChannelsOk", "output3dShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger3d", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 3, "xZeroOmitted": "false", "wZeroOmitted": "true" }, "bindings": ["x_main", "w", "x_zero_point_main", "y", "params_ncdhw3d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "ncdhw3d_w_zero_point_only", "when": ["rank5TensorOk", "not present.x_zero_point", "scalarWZeroRequiredOk", "groupChannelsOk", "output3dShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger3d", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 3, "xZeroOmitted": "true", "wZeroOmitted": "false" }, "bindings": ["x_main", "w", "w_zero_point_main", "y", "params_ncdhw3d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "ncdhw3d_implicit_zero_points", "when": ["rank5TensorOk", "zeroPointsOmitted", "groupChannelsOk", "output3dShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger3d", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 3, "xZeroOmitted": "true", "wZeroOmitted": "true" }, "bindings": ["x_main", "w", "y", "params_ncdhw3d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] }, { "id": "nchw_implicit_zero_points", "when": ["nchwTensorOk", "zeroPointsOmitted", "groupChannelsOk", "outputSpatialShapeOk"], "derive": {}, "passes": [ { "id": "main", "name": "ConvInteger", "shader": "conv-int-accumulate-spatial.wgsl.jinja", "derive": { "spatialRankSpec": 2, "xZeroOmitted": "true", "wZeroOmitted": "true" }, "bindings": ["x_main", "w", "y", "params_nchw2d_x_zero_point_only"], "dispatch": { "x": "min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "y": "ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)", "z": 1 } } ] } ]}{"domain":"ai.onnx","name":"ConvInteger","sinceVersion":10,"inputs":{"x":{"dtype":"TX"},"w":{"dtype":"TW"},"x_zero_point":{"dtype":"TX","optional":true},"w_zero_point":{"dtype":"TW","optional":true}},"outputs":{"y":{"dtype":"TY","rank":"ranks.x","shape":"[dim(shapes.x, 0), dim(shapes.w, 0), expectedOutputWidth] if ranks.x == 3 else ([dim(shapes.x, 0), dim(shapes.w, 0), expectedOutputHeight, expectedOutputWidth] if ranks.x == 4 else [dim(shapes.x, 0), dim(shapes.w, 0), expectedOutputDepth, expectedOutputHeight, expectedOutputWidth])"}},"attributes":{"auto_pad":{"default":"NOTSET"},"group":{"default":1},"dilations":{},"kernel_shape":{},"pads":{},"strides":{}},"attributeConstraints":{"auto_pad":{"values":["NOTSET","SAME_UPPER","SAME_LOWER","VALID"]}},"typeConstraints":{"TX":["uint8","int8"],"TW":["uint8","int8"],"TY":["int32"]},"tunables":{"WORKGROUP_SIZE":{"default":256}},"derive":{"inputDepth":"dim(shapes.x, 2) if ranks.x == 5 else 1","inputHeight":"dim(shapes.x, 3) if ranks.x == 5 else (dim(shapes.x, 2) if ranks.x == 4 else 1)","inputWidth":"dim(shapes.x, ranks.x - 1) if ranks.x >= 3 else 1","outputDepth":"dim(shapes.y, 2) if ranks.y == 5 else 1","outputHeight":"dim(shapes.y, 3) if ranks.y == 5 else (dim(shapes.y, 2) if ranks.y == 4 else 1)","outputWidth":"dim(shapes.y, ranks.y - 1) if ranks.y >= 3 else 1","kernelDepth":"dim(shapes.w, 2) if ranks.w == 5 else 1","kernelHeight":"dim(shapes.w, 3) if ranks.w == 5 else (dim(shapes.w, 2) if ranks.w == 4 else 1)","kernelWidth":"dim(shapes.w, ranks.w - 1) if ranks.w >= 3 else 1","spatialRank":"ranks.w - 2","kernelShapeLengthOk":"not has(attrs, \"kernel_shape\") or (attrs.kernel_shape | length) == spatialRank","stridesLengthOk":"not has(attrs, \"strides\") or (attrs.strides | length) == spatialRank","dilationsLengthOk":"not has(attrs, \"dilations\") or (attrs.dilations | length) == spatialRank","padsLengthOk":"not has(attrs, \"pads\") or (attrs.pads | length) == 2 * spatialRank","kernelD":"attrs.kernel_shape[0] if kernelShapeLengthOk and has(attrs, \"kernel_shape\") and spatialRank == 3 else 1","kernelH":"attrs.kernel_shape[spatialRank - 2] if kernelShapeLengthOk and has(attrs, \"kernel_shape\") and spatialRank >= 2 else 1","kernelW":"attrs.kernel_shape[spatialRank - 1] if kernelShapeLengthOk and has(attrs, \"kernel_shape\") and spatialRank >= 1 else 1","strideD":"attrs.strides[0] if stridesLengthOk and has(attrs, \"strides\") and spatialRank == 3 else 1","strideH":"attrs.strides[spatialRank - 2] if stridesLengthOk and has(attrs, \"strides\") and spatialRank >= 2 else 1","strideW":"attrs.strides[spatialRank - 1] if stridesLengthOk and has(attrs, \"strides\") and spatialRank >= 1 else 1","dilationD":"attrs.dilations[0] if dilationsLengthOk and has(attrs, \"dilations\") and spatialRank == 3 else 1","dilationH":"attrs.dilations[spatialRank - 2] if dilationsLengthOk and has(attrs, \"dilations\") and spatialRank >= 2 else 1","dilationW":"attrs.dilations[spatialRank - 1] if dilationsLengthOk and has(attrs, \"dilations\") and spatialRank >= 1 else 1","padFront":"attrs.pads[0] if padsLengthOk and has(attrs, \"pads\") and spatialRank == 3 else 0","padTop":"attrs.pads[spatialRank - 2] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 2 else 0","padLeft":"attrs.pads[spatialRank - 1] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 1 else 0","padBack":"attrs.pads[spatialRank] if padsLengthOk and has(attrs, \"pads\") and spatialRank == 3 else 0","padBottom":"attrs.pads[2 * spatialRank - 2] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 2 else 0","padRight":"attrs.pads[2 * spatialRank - 1] if padsLengthOk and has(attrs, \"pads\") and spatialRank >= 1 else 0","autoPadSame":"attrs.auto_pad == \"SAME_UPPER\" or attrs.auto_pad == \"SAME_LOWER\"","autoPadValid":"attrs.auto_pad == \"VALID\"","samePadDepth":"max(0, (outputDepth - 1) * strideD + (kernelDepth - 1) * dilationD + 1 - inputDepth)","samePadHeight":"max(0, (outputHeight - 1) * strideH + (kernelHeight - 1) * dilationH + 1 - inputHeight)","samePadWidth":"max(0, (outputWidth - 1) * strideW + (kernelWidth - 1) * dilationW + 1 - inputWidth)","samePadFront":"floor(samePadDepth / 2) if attrs.auto_pad == \"SAME_UPPER\" else samePadDepth - floor(samePadDepth / 2)","samePadTop":"floor(samePadHeight / 2) if attrs.auto_pad == \"SAME_UPPER\" else samePadHeight - floor(samePadHeight / 2)","samePadLeft":"floor(samePadWidth / 2) if attrs.auto_pad == \"SAME_UPPER\" else samePadWidth - floor(samePadWidth / 2)","effectivePadFront":"samePadFront if autoPadSame else (0 if autoPadValid else padFront)","effectivePadTop":"samePadTop if autoPadSame else (0 if autoPadValid else padTop)","effectivePadLeft":"samePadLeft if autoPadSame else (0 if autoPadValid else padLeft)","expectedOutputDepth":"ceil(inputDepth / strideD) if autoPadSame else floor((inputDepth + (0 if autoPadValid else padFront + padBack) - ((kernelDepth - 1) * dilationD + 1)) / strideD) + 1","expectedOutputHeight":"ceil(inputHeight / strideH) if autoPadSame else floor((inputHeight + (0 if autoPadValid else padTop + padBottom) - ((kernelHeight - 1) * dilationH + 1)) / strideH) + 1","expectedOutputWidth":"ceil(inputWidth / strideW) if autoPadSame else floor((inputWidth + (0 if autoPadValid else padLeft + padRight) - ((kernelWidth - 1) * dilationW + 1)) / strideW) + 1","spatialAttributeLengthsOk":"kernelShapeLengthOk and stridesLengthOk and dilationsLengthOk and padsLengthOk","kernelShapeMatchesWeights":"not has(attrs, \"kernel_shape\") or (kernelW == kernelWidth and (spatialRank < 2 or kernelH == kernelHeight) and (spatialRank < 3 or kernelD == kernelDepth))","kernelExtentsOk":"kernelWidth >= 1 and (spatialRank < 2 or kernelHeight >= 1) and (spatialRank < 3 or kernelDepth >= 1)","stridesValuesOk":"not has(attrs, \"strides\") or (strideD >= 1 and floor(strideD) == strideD and strideH >= 1 and floor(strideH) == strideH and strideW >= 1 and floor(strideW) == strideW)","dilationsValuesOk":"not has(attrs, \"dilations\") or (dilationD >= 1 and floor(dilationD) == dilationD and dilationH >= 1 and floor(dilationH) == dilationH and dilationW >= 1 and floor(dilationW) == dilationW)","padsValuesOk":"padFront >= 0 and floor(padFront) == padFront and padTop >= 0 and floor(padTop) == padTop and padLeft >= 0 and floor(padLeft) == padLeft and padBack >= 0 and floor(padBack) == padBack and padBottom >= 0 and floor(padBottom) == padBottom and padRight >= 0 and floor(padRight) == padRight","explicitPadsOk":"attrs.auto_pad == \"NOTSET\" or not has(attrs, \"pads\")","spatialAttributesOk":"spatialRank >= 1 and spatialRank <= 3 and spatialAttributeLengthsOk and kernelShapeMatchesWeights and kernelExtentsOk and stridesValuesOk and dilationsValuesOk and padsValuesOk and explicitPadsOk","packedFeature":"device.wgslLanguageFeatures.has(\"packed_4x8_integer_dot_product\")","rank4TensorOk":"spatialAttributesOk and (ranks.x == 4 and ranks.w == 4 and ranks.y == 4)","outputBatchChannelsOk":"dim(shapes.y, 0) == dim(shapes.x, 0) and dim(shapes.y, 1) == dim(shapes.w, 0)","groupChannelsOk":"attrs.group >= 1 and dim(shapes.w, 1) * attrs.group == dim(shapes.x, 1) and dim(shapes.w, 0) % attrs.group == 0","output2dShapeOk":"dim(shapes.y, 2) == expectedOutputHeight and dim(shapes.y, 3) == expectedOutputWidth","aScalar":"\"u32\" if tensorDtypes.w == \"uint8\" else \"i32\"","bScalar":"\"u32\" if tensorDtypes.x == \"uint8\" else \"i32\"","wScalar":"\"u32\" if tensorDtypes.w == \"uint8\" else \"i32\"","xScalar":"\"u32\" if tensorDtypes.x == \"uint8\" else \"i32\"","aUnsigned":"tensorDtypes.w == \"uint8\"","bUnsigned":"tensorDtypes.x == \"uint8\"","wUnsigned":"tensorDtypes.w == \"uint8\"","xUnsigned":"tensorDtypes.x == \"uint8\"","bZeroPerColumn":false,"packedDotTilesOk":"not (has(device.adapterInfo, \"architecture\") and device.adapterInfo.architecture == \"adreno-8xx\")","rank5TensorOk":"spatialAttributesOk and (ranks.x == 5 and ranks.w == 5 and ranks.y == 5)","scalarXZeroOk":"ranks.x_zero_point == 0 or (ranks.x_zero_point == 1 and dim(shapes.x_zero_point, 0) == 1)","scalarWZeroOk":"ranks.w_zero_point == 0 or (ranks.w_zero_point == 1 and dim(shapes.w_zero_point, 0) == 1)","scalarXZeroRequiredOk":"present.x_zero_point and scalarXZeroOk","scalarWZeroRequiredOk":"present.w_zero_point and scalarWZeroOk","ungroupedChannelsOk":"attrs.group == 1 and dim(shapes.w, 1) == dim(shapes.x, 1)","output3dShapeOk":"dim(shapes.y, 2) == expectedOutputDepth and dim(shapes.y, 3) == expectedOutputHeight and dim(shapes.y, 4) == expectedOutputWidth","rank3TensorOk":"spatialAttributesOk and (ranks.x == 3 and ranks.w == 3 and ranks.y == 3)","nchwTensorOk":"rank4TensorOk or rank3TensorOk","output1dShapeOk":"dim(shapes.y, 2) == expectedOutputWidth","outputSpatialShapeOk":"output2dShapeOk if rank4TensorOk else output1dShapeOk","pointwiseTileM":8,"pointwiseTileN":64,"pointwiseKtWords":32,"pointwiseResourcesOk":"pointwiseTileN <= min(device.limits.maxComputeWorkgroupSizeX, device.limits.maxComputeInvocationsPerWorkgroup) and 4 * pointwiseTileM * (pointwiseKtWords + 1) <= device.limits.maxComputeWorkgroupStorageSize","pointwiseDispatchOk":"ceilDiv(outputHeight * outputWidth, pointwiseTileN) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and ceilDiv(dim(shapes.w, 0), pointwiseTileM) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and dim(shapes.y, 0) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)","aVec4":"\"vec4<u32>\" if tensorDtypes.w == \"uint8\" else \"vec4<i32>\""},"when":["outputBatchChannelsOk"],"bindings":{"x":{"elementType":"$bScalar"},"x_zero_point":{"elementType":"$bScalar","length":1},"params":{"when":"rank5TensorOk","struct":[{"name":"outCount","type":"u32","value":"dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4)"},{"name":"inChannels","type":"u32","value":"dim(shapes.x, 1)"},{"name":"inD","type":"u32","value":"dim(shapes.x, 2)"},{"name":"inH","type":"u32","value":"dim(shapes.x, 3)"},{"name":"inW","type":"u32","value":"dim(shapes.x, 4)"},{"name":"kRows","type":"u32","value":"dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4)"},{"name":"outH","type":"u32","value":"dim(shapes.y, 3)"},{"name":"outW","type":"u32","value":"dim(shapes.y, 4)"}]},"cols_im2col":{"name":"cols","buffer":"storage","elementType":"$bScalar"},"params_im2col":{"name":"params","when":"not rank5TensorOk","struct":[{"name":"outCount","type":"u32","value":"dim(shapes.y, 2) * dim(shapes.y, 3)"},{"name":"inChannels","type":"u32","value":"dim(shapes.x, 1)"},{"name":"inH","type":"u32","value":"dim(shapes.x, 2)"},{"name":"inW","type":"u32","value":"dim(shapes.x, 3)"},{"name":"kRows","type":"u32","value":"dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3)"},{"name":"outW","type":"u32","value":"dim(shapes.y, 3)"}]},"a":{"arg":"w","elementType":"$aVec4"},"a_zero_point":{"arg":"w_zero_point","elementType":"$aScalar","length":1,"when":"present.w_zero_point"},"b_zero_point":{"arg":"x_zero_point","elementType":"$bScalar","length":1,"when":"present.x_zero_point"},"y":{"elementType":"i32"},"b_main":{"scratch":"cols","name":"b","buffer":"read-only-storage","elementType":"$bScalar"},"params__uniform":{"name":"params","struct":[{"name":"M","type":"u32","value":"dim(shapes.w, 0)"},{"name":"N","type":"u32","value":"outSpatial"},{"name":"K","type":"u32","value":"kRows"},{"name":"aBatchStride4","type":"u32","value":0},{"name":"bBatchStride","type":"u32","value":"kRows * outSpatial"},{"name":"yBatchStride","type":"u32","value":"dim(shapes.w, 0) * outSpatial"}]},"a_w":{"arg":"w","name":"a","elementType":"$aStorage"},"b_x":{"arg":"x","name":"b","elementType":"$bScalar"},"params_quant_dp4a_matmul":{"name":"params","struct":[{"name":"M","type":"u32","value":"dim(shapes.w, 0)"},{"name":"N","type":"u32","value":"outputHeight * outputWidth"},{"name":"K","type":"u32","value":"dim(shapes.x, 1)"},{"name":"aBatchStride4","type":"u32","value":0},{"name":"bBatchStride","type":"u32","value":"dim(shapes.x, 1) * inputHeight * inputWidth"},{"name":"yBatchStride","type":"u32","value":"dim(shapes.w, 0) * outputHeight * outputWidth"}]},"x_main":{"name":"x","elementType":"$xScalar"},"w":{"elementType":"$wScalar"},"x_zero_point_main":{"name":"x_zero_point","elementType":"$xScalar","length":1,"when":"present.x_zero_point"},"w_zero_point":{"elementType":"$wScalar"},"params_nchw":{"name":"params","struct":[{"name":"inChannels","type":"u32","value":"dim(shapes.x, 1)"},{"name":"inH","type":"u32","value":"inputHeight"},{"name":"inW","type":"u32","value":"inputWidth"},{"name":"outChannels","type":"u32","value":"dim(shapes.w, 0)"},{"name":"weightInChannels","type":"u32","value":"dim(shapes.w, 1)"},{"name":"inChannelsPerGroup","type":"u32","value":"dim(shapes.x, 1) / attrs.group"},{"name":"outChannelsPerGroup","type":"u32","value":"dim(shapes.w, 0) / attrs.group"},{"name":"kernelH","type":"u32","value":"kernelHeight"},{"name":"kernelW","type":"u32","value":"kernelWidth"},{"name":"outH","type":"u32","value":"outputHeight"},{"name":"outW","type":"u32","value":"outputWidth"},{"name":"strideH","type":"u32","value":"strideH"},{"name":"strideW","type":"u32","value":"strideW"},{"name":"dilationH","type":"u32","value":"dilationH"},{"name":"dilationW","type":"u32","value":"dilationW"},{"name":"padH","type":"i32","value":"effectivePadTop"},{"name":"padW","type":"i32","value":"effectivePadLeft"},{"name":"count","type":"u32","value":"numel(shapes.y)"}],"when":"not rank5TensorOk"},"w_zero_point_main":{"name":"w_zero_point","elementType":"$wScalar","length":1,"when":"present.w_zero_point"},"params_ncdhw":{"name":"params","struct":[{"name":"inChannels","type":"u32","value":"dim(shapes.x, 1)"},{"name":"inD","type":"u32","value":"dim(shapes.x, 2)"},{"name":"inH","type":"u32","value":"dim(shapes.x, 3)"},{"name":"inW","type":"u32","value":"dim(shapes.x, 4)"},{"name":"outChannels","type":"u32","value":"dim(shapes.w, 0)"},{"name":"weightInChannels","type":"u32","value":"dim(shapes.w, 1)"},{"name":"inChannelsPerGroup","type":"u32","value":"dim(shapes.x, 1) / attrs.group"},{"name":"outChannelsPerGroup","type":"u32","value":"dim(shapes.w, 0) / attrs.group"},{"name":"kernelD","type":"u32","value":"dim(shapes.w, 2)"},{"name":"kernelH","type":"u32","value":"dim(shapes.w, 3)"},{"name":"kernelW","type":"u32","value":"dim(shapes.w, 4)"},{"name":"outD","type":"u32","value":"dim(shapes.y, 2)"},{"name":"outH","type":"u32","value":"dim(shapes.y, 3)"},{"name":"outW","type":"u32","value":"dim(shapes.y, 4)"},{"name":"strideD","type":"u32","value":"strideD"},{"name":"strideH","type":"u32","value":"strideH"},{"name":"strideW","type":"u32","value":"strideW"},{"name":"dilationD","type":"u32","value":"dilationD"},{"name":"dilationH","type":"u32","value":"dilationH"},{"name":"dilationW","type":"u32","value":"dilationW"},{"name":"padD","type":"i32","value":"effectivePadFront"},{"name":"padH","type":"i32","value":"effectivePadTop"},{"name":"padW","type":"i32","value":"effectivePadLeft"},{"name":"count","type":"u32","value":"numel(shapes.y)"}],"when":"rank5TensorOk"},"a_zero_point_per_row":{"arg":"w_zero_point","name":"a_zero_point","elementType":"$aScalar"}},"variants":[{"id":"dp4a_im2col_scalar_zero_points","priority":20,"when":["packedFeature","rank5TensorOk or rank4TensorOk","scalarXZeroRequiredOk","scalarWZeroRequiredOk","ungroupedChannelsOk","(dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) % 4 == 0 and dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) >= 32 and dim(shapes.w, 0) >= 8 and dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4) >= 256 and output3dShapeOk and dim(shapes.x, 0) * dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) * dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4) * 4 <= device.limits.maxStorageBufferBindingSize and dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * dim(shapes.w, 4) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and ceilDiv(dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4), tunables.WORKGROUP_SIZE) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and ceilDiv(dim(shapes.y, 2) * dim(shapes.y, 3) * dim(shapes.y, 4), 64) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and ceilDiv(dim(shapes.w, 0), 8) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535) and dim(shapes.x, 0) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)) if rank5TensorOk else ((dim(shapes.w, 2) > 1 or dim(shapes.w, 3) > 1) and dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) % 4 == 0 and dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) >= 64 and numel(shapes.y) >= 8192 and dim(shapes.y, 2) * dim(shapes.y, 3) <= 4194240 and dim(shapes.w, 0) <= 524280 and dim(shapes.y, 0) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535))","packedDotTilesOk"],"derive":{"hasAZero":true,"hasBZero":true,"aPacked":true,"aZeroPerRow":false,"tileM":8,"tileN":64,"ktWords":32,"hasBias":false,"kRows":"dim(shapes.w, 1) * dim(shapes.w, 2) * dim(shapes.w, 3) * (dim(shapes.w, 4) if rank5TensorOk else 1)","outSpatial":"dim(shapes.y, 2) * dim(shapes.y, 3) * (dim(shapes.y, 4) if rank5TensorOk else 1)"},"intermediates":[{"id":"cols","dtype":"int32","shape":"[dim(shapes.x, 0) * kRows * outSpatial]"}],"passes":[{"id":"im2col","name":"ConvInteger.Im2Col","shader":"conv-int-im2col-spatial.wgsl.jinja","derive":{"spatialRankSpec":"3 if rank5TensorOk else 2","kernelDSpec":"dim(shapes.w, 2) if rank5TensorOk else 1","kernelHSpec":"dim(shapes.w, ranks.w - 2)","kernelWSpec":"dim(shapes.w, ranks.w - 1)","strideDSpec":"strideD if rank5TensorOk else 1","strideHSpec":"strideH","strideWSpec":"strideW","dilationDSpec":"dilationD if rank5TensorOk else 1","dilationHSpec":"dilationH","dilationWSpec":"dilationW","padFrontSpec":"effectivePadFront if rank5TensorOk else 0","padTopSpec":"effectivePadTop","padLeftSpec":"effectivePadLeft"},"bindings":["x","x_zero_point","cols_im2col","params","params_im2col"],"dispatch":{"x":"ceil(outSpatial / tunables.WORKGROUP_SIZE)","y":"kRows","z":"dim(shapes.x, 0)"}},{"id":"main","name":"ConvInteger.Im2ColDp4a","shader":"quant-dp4a-matmul.wgsl.jinja","bindings":["a","b_main","a_zero_point","b_zero_point","y","params__uniform"],"dispatch":{"x":"ceil(outSpatial / 64)","y":"ceil(dim(shapes.w, 0) / 8)","z":"dim(shapes.y, 0)"}}]},{"id":"dp4a_pointwise_1x1","priority":21,"when":["nchwTensorOk","ungroupedChannelsOk","kernelHeight == 1","kernelWidth == 1","strideH == 1","strideW == 1","padTop == 0 and padBottom == 0","padLeft == 0 and padRight == 0","outputHeight == inputHeight","outputWidth == inputWidth","not present.x_zero_point or scalarXZeroOk","not present.w_zero_point or scalarWZeroOk","dim(shapes.x, 1) % 4 == 0 or dim(shapes.x, 1) >= 32","pointwiseResourcesOk","pointwiseDispatchOk","packedDotTilesOk"],"derive":{"aPacked":"dim(shapes.x, 1) % 4 == 0","aStorage":"aVec4 if aPacked else aScalar","hasAZero":"present.w_zero_point","hasBZero":"present.x_zero_point","tileM":"pointwiseTileM","tileN":"pointwiseTileN","ktWords":"pointwiseKtWords"},"passes":[{"id":"main","name":"ConvInteger.Dp4aPointwise","shader":"quant-dp4a-matmul.wgsl.jinja","bindings":["a_w","b_x","a_zero_point","b_zero_point","y","params_quant_dp4a_matmul"],"dispatch":{"x":"ceilDiv(outputHeight * outputWidth, pointwiseTileN)","y":"ceilDiv(dim(shapes.w, 0), pointwiseTileM)","z":"dim(shapes.y, 0)"}}]},{"id":"dp4a_pointwise_1x1_per_channel","priority":21,"when":["nchwTensorOk","ungroupedChannelsOk","kernelHeight == 1","kernelWidth == 1","strideH == 1","strideW == 1","padTop == 0 and padBottom == 0","padLeft == 0 and padRight == 0","outputHeight == inputHeight","outputWidth == inputWidth","not present.x_zero_point or scalarXZeroOk","present.w_zero_point","ranks.w_zero_point == 1","dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)","dim(shapes.x, 1) % 4 == 0 or dim(shapes.x, 1) >= 32","pointwiseResourcesOk","pointwiseDispatchOk","packedDotTilesOk"],"derive":{"aPacked":"dim(shapes.x, 1) % 4 == 0","aStorage":"aVec4 if aPacked else aScalar","hasAZero":"present.w_zero_point","hasBZero":"present.x_zero_point","tileM":"pointwiseTileM","tileN":"pointwiseTileN","ktWords":"pointwiseKtWords","aZeroPerRow":true},"passes":[{"id":"main","name":"ConvInteger.Dp4aPointwise","shader":"quant-dp4a-matmul.wgsl.jinja","bindings":["a_w","b_x","a_zero_point_per_row","b_zero_point","y","params_quant_dp4a_matmul"],"dispatch":{"x":"ceilDiv(outputHeight * outputWidth, pointwiseTileN)","y":"ceilDiv(dim(shapes.w, 0), pointwiseTileM)","z":"dim(shapes.y, 0)"}}]},{"id":"nchw2d_per_channel_zero_point","priority":5,"when":["nchwTensorOk","not present.x_zero_point or scalarXZeroOk","present.w_zero_point","ranks.w_zero_point == 1","dim(shapes.w_zero_point, 0) == dim(shapes.w, 0)","groupChannelsOk","outputSpatialShapeOk"],"derive":{"wZeroPerChannel":true},"passes":[{"id":"main","name":"ConvIntegerPerChannel","shader":"conv-int-accumulate-spatial.wgsl.jinja","derive":{"spatialRankSpec":2,"xZeroOmitted":"not present.x_zero_point","wZeroOmitted":false},"bindings":["x_main","w","x_zero_point_main","w_zero_point","y","params_nchw"],"dispatch":{"x":"min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]},{"id":"spatial","when":["nchwTensorOk and outputSpatialShapeOk or rank5TensorOk and output3dShapeOk","not present.x_zero_point or scalarXZeroOk","not present.w_zero_point or scalarWZeroOk","groupChannelsOk"],"passes":[{"id":"main","name":"ConvInteger","shader":"conv-int-accumulate-spatial.wgsl.jinja","derive":{"spatialRankSpec":"3 if rank5TensorOk else 2","xZeroOmitted":"not present.x_zero_point","wZeroOmitted":"not present.w_zero_point"},"bindings":["x_main","w","x_zero_point_main","w_zero_point_main","y","params_nchw","params_ncdhw"],"dispatch":{"x":"min(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)","y":"ceilDiv(ceilDiv((numel(shapes.y)), (tunables.WORKGROUP_SIZE)), 65535)","z":1}}]}]}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647481{ "name": "ai.onnx.ConvInteger", "id": "_ai_onnx_convinteger_webgpu_befbf8c", "version": 1, "license": "Apache-2.0", "backend": { "type": "webgpu" }, "digest": { "algorithm": "sha256", "files": { "bench.json": "w1Y+YvLhm6rmHnI3I6fdQTErLMPyr5es6PymArrgGTA=", "conv-int-accumulate-spatial.wgsl.jinja": "7393dtsdsogF8Zzus4+gZiwygpXHb15ZTWhE9VM83UA=", "conv-int-im2col-spatial.wgsl.jinja": "rUkI3zRiXYyD3r5GvVRqfcLMijHGc2KA71kljasROJM=", "manifest.json": "guLLSG4M/NsDkfMSVXE0qMhQ2L9fYa8oY2GLgeyOXME=", "quant-dp4a-matmul.wgsl.jinja": "hfcRmXhc3rBZU5qOfHyf75KqjiAmJpqzTY7BlyvoyC8=", "test.json": "T5Q9TkFCTbjYtbC//Z9DuWYARBX+XkneiZt+RCoNamI=" } }, "provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } }, "webgpu": { "manifestSpec": "2.1", "variants": { "dp4a_im2col_ncdhw3d_scalar_zero_points": ["conv-int-im2col-spatial.wgsl.jinja", "quant-dp4a-matmul.wgsl.jinja"], "dp4a_im2col_nchw_scalar_zero_points": ["conv-int-im2col-spatial.wgsl.jinja", "quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_tail": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_tail_x_zero_point_only": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_tail_w_zero_point_only": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_tail_no_zero_points": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_x_zero_point_only": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_w_zero_point_only": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_no_zero_points": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_tail_per_channel": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_tail_per_channel_w_zero_point_only": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_per_channel": ["quant-dp4a-matmul.wgsl.jinja"], "dp4a_pointwise_1x1_per_channel_w_zero_point_only": ["quant-dp4a-matmul.wgsl.jinja"], "nchw2d_per_channel_zero_point": ["conv-int-accumulate-spatial.wgsl.jinja"], "nchw2d_per_channel_w_zero_point_only": ["conv-int-accumulate-spatial.wgsl.jinja"], "nchw2d_scalar_zero_points": ["conv-int-accumulate-spatial.wgsl.jinja"], "nchw2d_x_zero_point_only": ["conv-int-accumulate-spatial.wgsl.jinja"], "nchw2d_w_zero_point_only": ["conv-int-accumulate-spatial.wgsl.jinja"], "ncdhw3d_scalar_zero_points": ["conv-int-accumulate-spatial.wgsl.jinja"], "ncdhw3d_x_zero_point_only": ["conv-int-accumulate-spatial.wgsl.jinja"], "ncdhw3d_w_zero_point_only": ["conv-int-accumulate-spatial.wgsl.jinja"], "ncdhw3d_implicit_zero_points": ["conv-int-accumulate-spatial.wgsl.jinja"], "nchw_implicit_zero_points": ["conv-int-accumulate-spatial.wgsl.jinja"] } }}{"name":"ai.onnx.ConvInteger","id":"_ai_onnx_convinteger_webgpu_d1b7c67","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"w1Y+YvLhm6rmHnI3I6fdQTErLMPyr5es6PymArrgGTA=","conv-int-accumulate-spatial.wgsl.jinja":"aNoDIh9f/UhH7upOE35yFfVbY5BBWuv+wpadUC3q5eE=","conv-int-im2col-spatial.wgsl.jinja":"zFQCVRtTKPVsLMUEXXIjrpglz1slGPNoqUbfjmD4AO4=","manifest.json":"cSxM39Ex0c9XKDLCURa5HIKJ6ogEsPriUhVa3BimNiA=","quant-dp4a-matmul.wgsl.jinja":"ckxNIVOW81JCyci6rfZJ0Gjq0fSBb4+KB9T5v/TX128=","test.json":"T5Q9TkFCTbjYtbC//Z9DuWYARBX+XkneiZt+RCoNamI="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}1234544 unmodified lines50515251535455565 unmodified lines626364636566676818 unmodified lines878889889091929334 unmodified lines12812913012913113213313439 unmodified lines17417517617517717817918077 unmodified lines25825926025926126226326452 unmodified lines317318319318320321322323{% set bPrepacked = false -%}{% set ownRowSums = false -%}{% macro quant_read_column_zero(fn_name, buffer_name, is_unsigned, present=true, per_column=false, param_name="col", return_type="i32") %}fn {{ fn_name }}({% if per_column %}{{ param_name }}: u32{% endif %}) -> {{ return_type }} { {% if per_column %}44 unmodified lines{% set needsBSum = hasAZero or aUnsigned %}var<workgroup> a_tile: array<u32, A_TILE_WORDS>;{% if needsASum %}var<workgroup> a_row_sum: array<atomic<i32>, TILE_M>;var<workgroup> a_row_sum: array<{{ "i32" if ownRowSums else "atomic<i32>" }}, TILE_M>;
{% endif %}// Pack 4 widened A values into one u32 (byte 0 = lowest k).5 unmodified lines return (u32(v.x) & 0xFFu) | ((u32(v.y) & 0xFFu) << 8u) | ((u32(v.z) & 0xFFu) << 16u) | ((u32(v.w) & 0xFFu) << 24u);{% endif %}}{% if needsASum %}{% if needsASum and not ownRowSums %}
// Sum of the 4 bias-shifted A values of one packed word.fn sum4_a(v: vec4<{{ aScalar }}>) -> i32 {18 unmodified linesfn dot4_packed(a_word: u32, b_word: u32) -> i32 { return dot4I8Packed(a_word, b_word);}{% if needsBSum %}{% if needsBSum and not bPrepacked %}
fn sum4_b(b0: {{ bScalar }}, b1: {{ bScalar }}, b2: {{ bScalar }}, b3: {{ bScalar }}) -> i32 {{% if bUnsigned %}34 unmodified lines
{% if needsASum %} if (tid < TILE_M) { atomicStore(&a_row_sum[tid], 0); {{ "a_row_sum[tid] = 0;" if ownRowSums else "atomicStore(&a_row_sum[tid], 0);" }} } workgroupBarrier();
39 unmodified lines let v = a[a_base4 + src_m * k_words_total + kw0 + ki];{% endif %} packed = pack_a(v);{% if needsASum %}{% if needsASum and not ownRowSums %} atomicAdd(&a_row_sum[mi], sum4_a(v));{% endif %} }77 unmodified lines let v = vec4<{{ aScalar }}>(a0, a1, a2, a3); packed = pack_a(v);{% if needsASum %} atomicAdd(&a_row_sum[tid], sum4_a(v)); {{ "a_row_sum[tid] += dot4_packed(packed, 0x01010101u);" if ownRowSums else "atomicAdd(&a_row_sum[tid], sum4_a(v));" }}{% endif %} } a_tile[tid * KT_WORDS] = packed;52 unmodified lines{% endif %} acc = acc + kcc;{% if hasBias %} acc = acc + bias[{{ "col" if biasPerColumn is defined and biasPerColumn else "mr" }}]; acc = acc + bias[{{ "mr" }}];{% endif %} y[y_base + mr * params.N + col] = acc; }README.md+17-22
build/webgpu/conv-int-accumulate-spatial.wgsl.jinja+9-6
build/webgpu/conv-int-im2col-spatial.wgsl.jinja-4
build/webgpu/manifest.json+1-882
build/webgpu/metadata.json+1-48
build/webgpu/quant-dp4a-matmul.wgsl.jinja+9-7