Xenova HF Staff commited on
Commit
a0e12a2
·
verified ·
1 Parent(s): 9e0b43e

sync 2e7068faf55e

Browse files
README.md CHANGED
@@ -1,3 +1,81 @@
1
  ---
 
2
  license: apache-2.0
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ library_name: kernels
3
  license: apache-2.0
4
+ tags:
5
+ - kernel
6
+ - webgpu
7
+ - wgsl
8
  ---
9
+ # ai.onnx.BatchNormalization
10
+
11
+ `ai.onnx` · standard ONNX operator · ONNX opset ≥ 15
12
+
13
+ ## Description
14
+
15
+ Applies inference-mode batch normalization: `Y = (X - input_mean) / sqrt(input_var + epsilon) * scale + B`. This package supports `training_mode=0`, rank-2-or-higher inputs, and a common float16 or float32 dtype for every tensor. ONNX training mode is intentionally not implemented because this inference-only release does not expose its required running-mean and running-variance outputs.
16
+
17
+ See the [ONNX `BatchNormalization` spec](https://onnx.ai/onnx/operators/onnx__BatchNormalization.html) for the reference semantics.
18
+
19
+ ## Inputs
20
+
21
+ | Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
22
+ | --- | --- | --- | --- | --- | --- | --- |
23
+ | `X` | `x` | `T` | — | — | Input data tensor with shape `(N, C, D1, ..., Dn)`, normalized independently per channel using the supplied estimated statistics. | required |
24
+ | `scale` | `scale` | `T` | `1` | — | Per-channel scale tensor with shape `(C)`. | required |
25
+ | `B` | `b` | `T` | `1` | — | Per-channel bias tensor with shape `(C)`. | required |
26
+ | `input_mean` | `inputMean` | `T` | `1` | — | Precomputed estimated mean tensor with shape `(C)` used for inference. | required |
27
+ | `input_var` | `inputVar` | `T` | `1` | — | Precomputed estimated variance tensor with shape `(C)` used for inference. | required |
28
+
29
+ ## Outputs
30
+
31
+ | Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
32
+ | --- | --- | --- | --- | --- | --- | --- |
33
+ | `Y` | `y` | `T` | same as `X` | same as `X` | Batch-normalized output tensor with the same shape as `X`. | required |
34
+
35
+ ## Attributes
36
+
37
+ Default values (overridable per request):
38
+
39
+ | Attribute | Default | Description |
40
+ | --- | --- | --- |
41
+ | `epsilon` | `0.00001` | Small value added to the variance before taking the square root to avoid division by zero. |
42
+ | `momentum` | `0.9` | Standard ONNX running-statistics momentum. This inference-only package accepts the default `0.9`; non-default values are reserved for the unsupported training-state update. |
43
+ | `training_mode` | `0` | Execution mode. This inference-only package supports the default value 0; value 1 is rejected because the ONNX training outputs are not exposed. |
44
+
45
+ ## Type constraints
46
+
47
+ | Variable | Allowed dtypes |
48
+ | --- | --- |
49
+ | `T` | `float32`, `float16` |
50
+
51
+ ## Files
52
+
53
+ - [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, provenance)
54
+ - [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
55
+ - [`test.json`](build/webgpu/test.json) — correctness cases
56
+ - [`bench.json`](build/webgpu/bench.json) — benchmark + tuning cases
57
+ - [`batch-normalization-nc-vec4.wgsl.jinja`](build/webgpu/batch-normalization-nc-vec4.wgsl.jinja)
58
+ - [`batch-normalization-nchw-vec4.wgsl.jinja`](build/webgpu/batch-normalization-nchw-vec4.wgsl.jinja)
59
+ - [`batch-normalization-nchw.wgsl.jinja`](build/webgpu/batch-normalization-nchw.wgsl.jinja)
60
+
61
+ ## Use with `@huggingface/kernels`
62
+
63
+ The loader derives every required output's shape and logical dtype from the manifest contract and this call.
64
+ It then allocates the result tensors automatically.
65
+
66
+ The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
67
+
68
+ Replace each `*Data` placeholder with a typed array containing the corresponding input data.
69
+
70
+ ```js
71
+ import { getKernel } from "@huggingface/kernels";
72
+
73
+ const kernel = await getKernel("webgpu-kernels/ai.onnx.BatchNormalization", { version: 1 });
74
+ const { y } = await kernel({
75
+ x: { data: xData, shape: [2, 3] },
76
+ scale: { data: scaleData, shape: [3] },
77
+ b: { data: bData, shape: [3] },
78
+ inputMean: { data: inputMeanData, shape: [3] },
79
+ inputVar: { data: inputVarData, shape: [3] },
80
+ });
81
+ ```
build/webgpu/batch-normalization-nc-vec4.wgsl.jinja ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}
2
+ {% if note == "dispatch-limit" %}
3
+ // 2D-folded flat index: gid.y carries the high bits past the
4
+ // maxComputeWorkgroupsPerDimension dispatch limit (outputs > 16.7M elements).
5
+ {% elif note == "limit" %}
6
+ // 2D-folded flat index: gid.y carries the high bits past the
7
+ // maxComputeWorkgroupsPerDimension limit.
8
+ {% elif note == "device-axis" %}
9
+ // The flat dispatch is folded across x/y at the device's per-axis workgroup
10
+ // limit; gid.y carries the high portion of the output index.
11
+ {% elif note == "vec4-limit" %}
12
+ // 2D-folded flat vec4 index: gid.y carries the high bits past the
13
+ // maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills into y).
14
+ {% elif note == "element-limit" %}
15
+ // 2D-folded flat element index: gid.y carries the high bits past the
16
+ // maxComputeWorkgroupsPerDimension limit.
17
+ {% elif note == "dispatch" %}
18
+ // 2D-folded flat index: gid.y carries the high bits past the
19
+ // maxComputeWorkgroupsPerDimension dispatch limit.
20
+ {% endif %}
21
+ {% if bound == "" %}
22
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
23
+ {%- elif guardInline %}
24
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
25
+ if ({{ name }} >= {{ bound }}) { return; }
26
+ {%- else %}
27
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
28
+ if ({{ name }} >= {{ bound }}) {
29
+ return;
30
+ }
31
+ {%- endif %}
32
+ {% endmacro %}
33
+
34
+ {{ env.wgsl.resourceDeclarations }}
35
+
36
+ // Rank-2 [N, C] inference vec4 specialization. Vectors run across adjacent channels, so
37
+ // scale/bias/mean/var are also bound as vec4<f32> and C must be divisible by 4.
38
+ @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
39
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
40
+ {{ flat_index_2d("i", "params.count4") }}
41
+ let channel4 = i % params.channels4;
42
+ let alpha = scale[channel4] * inverseSqrt(input_var[channel4] + vec4<f32>(params.epsilon));
43
+ y[i] = x[i] * alpha + (bias[channel4] - input_mean[channel4] * alpha);
44
+ }
build/webgpu/batch-normalization-nchw-vec4.wgsl.jinja ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}
2
+ {% if note == "dispatch-limit" %}
3
+ // 2D-folded flat index: gid.y carries the high bits past the
4
+ // maxComputeWorkgroupsPerDimension dispatch limit (outputs > 16.7M elements).
5
+ {% elif note == "limit" %}
6
+ // 2D-folded flat index: gid.y carries the high bits past the
7
+ // maxComputeWorkgroupsPerDimension limit.
8
+ {% elif note == "device-axis" %}
9
+ // The flat dispatch is folded across x/y at the device's per-axis workgroup
10
+ // limit; gid.y carries the high portion of the output index.
11
+ {% elif note == "vec4-limit" %}
12
+ // 2D-folded flat vec4 index: gid.y carries the high bits past the
13
+ // maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills into y).
14
+ {% elif note == "element-limit" %}
15
+ // 2D-folded flat element index: gid.y carries the high bits past the
16
+ // maxComputeWorkgroupsPerDimension limit.
17
+ {% elif note == "dispatch" %}
18
+ // 2D-folded flat index: gid.y carries the high bits past the
19
+ // maxComputeWorkgroupsPerDimension dispatch limit.
20
+ {% endif %}
21
+ {% if bound == "" %}
22
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
23
+ {%- elif guardInline %}
24
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
25
+ if ({{ name }} >= {{ bound }}) { return; }
26
+ {%- else %}
27
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
28
+ if ({{ name }} >= {{ bound }}) {
29
+ return;
30
+ }
31
+ {%- endif %}
32
+ {% endmacro %}
33
+
34
+ {{ env.wgsl.resourceDeclarations }}
35
+
36
+ // Inference-only vec4 specialization: 128-bit loads/stores over x/y. Gated to
37
+ // spatial % 4 == 0 so each vec4 stays inside one channel; the per-component
38
+ // calculation is:
39
+ // (x - mean) * inverseSqrt(var + epsilon) * scale + bias
40
+ @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
41
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
42
+ {{ flat_index_2d("i", "params.count4") }}
43
+ let channel = (i / params.spatial4) % params.channels;
44
+ let normalized = (x[i] - vec4<f32>(input_mean[channel])) * inverseSqrt(input_var[channel] + params.epsilon);
45
+ y[i] = normalized * vec4<f32>(scale[channel]) + vec4<f32>(bias[channel]);
46
+ }
build/webgpu/batch-normalization-nchw.wgsl.jinja ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro flat_index_2d(name="i", bound="params.count", guardInline=false, note="dispatch-limit") %}
2
+ {% if note == "dispatch-limit" %}
3
+ // 2D-folded flat index: gid.y carries the high bits past the
4
+ // maxComputeWorkgroupsPerDimension dispatch limit (outputs > 16.7M elements).
5
+ {% elif note == "limit" %}
6
+ // 2D-folded flat index: gid.y carries the high bits past the
7
+ // maxComputeWorkgroupsPerDimension limit.
8
+ {% elif note == "device-axis" %}
9
+ // The flat dispatch is folded across x/y at the device's per-axis workgroup
10
+ // limit; gid.y carries the high portion of the output index.
11
+ {% elif note == "vec4-limit" %}
12
+ // 2D-folded flat vec4 index: gid.y carries the high bits past the
13
+ // maxComputeWorkgroupsPerDimension limit (the dispatch caps x and spills into y).
14
+ {% elif note == "element-limit" %}
15
+ // 2D-folded flat element index: gid.y carries the high bits past the
16
+ // maxComputeWorkgroupsPerDimension limit.
17
+ {% elif note == "dispatch" %}
18
+ // 2D-folded flat index: gid.y carries the high bits past the
19
+ // maxComputeWorkgroupsPerDimension dispatch limit.
20
+ {% endif %}
21
+ {% if bound == "" %}
22
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
23
+ {%- elif guardInline %}
24
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
25
+ if ({{ name }} >= {{ bound }}) { return; }
26
+ {%- else %}
27
+ let {{ name }} = gid.x + gid.y * nwg.x * {{ tunables.WORKGROUP_SIZE }}u;
28
+ if ({{ name }} >= {{ bound }}) {
29
+ return;
30
+ }
31
+ {%- endif %}
32
+ {% endmacro %}
33
+
34
+ {% if usesF16 %}
35
+ enable f16;
36
+ {% endif %}
37
+ {{ env.wgsl.resourceDeclarations }}
38
+ @compute @workgroup_size({{ tunables.WORKGROUP_SIZE }})
39
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(num_workgroups) nwg: vec3<u32>) {
40
+ {{ flat_index_2d("index") }}
41
+ let spatial = params.height * params.width;
42
+ let channel = (index / spatial) % params.channels;
43
+ {% if usesF16 %}
44
+ // f16 tensors use an f32 epsilon, so widen the normalization arithmetic to
45
+ // f32 and narrow only on store. WGSL does not allow the mixed f16 + f32 add.
46
+ let normalized = (f32(x[index]) - f32(input_mean[channel])) * inverseSqrt(f32(input_var[channel]) + params.epsilon);
47
+ y[index] = {{ scalar }}(normalized * f32(scale[channel]) + f32(bias[channel]));
48
+ {% else %}
49
+ let normalized = (x[index] - input_mean[channel]) * inverseSqrt(input_var[channel] + params.epsilon);
50
+ y[index] = normalized * scale[channel] + bias[channel];
51
+ {% endif %}
52
+ }
build/webgpu/bench.json ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "op": "ai.onnx.BatchNormalization",
3
+ "cases": [
4
+ {
5
+ "name": "nchw_4x64x112x112_vec4",
6
+ "preset": "smoke",
7
+ "vars": { "dtype": "float32", "batch": 4, "channels": 64, "height": 112, "width": 112 },
8
+ "inputs": {
9
+ "x": { "dtype": "float32", "shape": [4, 64, 112, 112], "dist": "normal", "seed": 770, "scale": 0.5 },
10
+ "scale": { "dtype": "float32", "shape": [64], "dist": "uniform", "seed": 771, "scale": 0.25, "offset": 1 },
11
+ "b": { "dtype": "float32", "shape": [64], "dist": "normal", "seed": 772, "scale": 0.1 },
12
+ "inputMean": { "dtype": "float32", "shape": [64], "dist": "normal", "seed": 773, "scale": 0.1 },
13
+ "inputVar": { "dtype": "float32", "shape": [64], "data": { "kind": "constant", "value": 1.0 } }
14
+ },
15
+ "outputs": { "y": { "dtype": "float32", "shape": [4, 64, 112, 112] } },
16
+ "bench": {
17
+ "primary": true,
18
+ "metrics": [
19
+ {
20
+ "type": "bandwidth",
21
+ "value": "args.batch * args.channels * args.height * args.width * dtypeBytes(args.dtype) * 2 + args.channels * dtypeBytes(args.dtype) * 4"
22
+ }
23
+ ]
24
+ }
25
+ },
26
+ {
27
+ "name": "nchw_1x64x112x112",
28
+ "vars": { "dtype": "float32", "batch": 1, "channels": 64, "height": 112, "width": 112 },
29
+ "inputs": {
30
+ "x": { "dtype": "float32", "shape": [1, 64, 112, 112] },
31
+ "scale": { "dtype": "float32", "shape": [64] },
32
+ "b": { "dtype": "float32", "shape": [64] },
33
+ "inputMean": { "dtype": "float32", "shape": [64] },
34
+ "inputVar": { "dtype": "float32", "shape": [64], "data": { "kind": "constant", "value": 1.0 } }
35
+ },
36
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 64, 112, 112] } },
37
+ "bench": {
38
+ "primary": true,
39
+ "metrics": [
40
+ {
41
+ "type": "bandwidth",
42
+ "value": "args.batch * args.channels * args.height * args.width * dtypeBytes(args.dtype) * 2 + args.channels * dtypeBytes(args.dtype) * 4"
43
+ }
44
+ ]
45
+ }
46
+ },
47
+ {
48
+ "name": "nc_4096x768",
49
+ "vars": { "dtype": "float32", "batch": 4096, "channels": 768, "height": 1, "width": 1 },
50
+ "inputs": {
51
+ "x": { "dtype": "float32", "shape": [4096, 768] },
52
+ "scale": { "dtype": "float32", "shape": [768] },
53
+ "b": { "dtype": "float32", "shape": [768] },
54
+ "inputMean": { "dtype": "float32", "shape": [768] },
55
+ "inputVar": { "dtype": "float32", "shape": [768], "dist": "constant", "value": 1 }
56
+ },
57
+ "outputs": { "y": { "dtype": "float32", "shape": [4096, 768] } },
58
+ "bench": {
59
+ "metrics": [
60
+ {
61
+ "type": "bandwidth",
62
+ "value": "args.batch * args.channels * dtypeBytes(args.dtype) * 2 + args.channels * dtypeBytes(args.dtype) * 4"
63
+ }
64
+ ]
65
+ }
66
+ },
67
+ {
68
+ "name": "nchw_inference_scalar_no_vec4_1x64x63x63",
69
+ "preset": "edge",
70
+ "vars": { "dtype": "float32", "batch": 1, "channels": 64, "height": 63, "width": 63 },
71
+ "inputs": {
72
+ "x": { "dtype": "float32", "shape": [1, 64, 63, 63], "dist": "normal", "seed": 6301, "scale": 1 },
73
+ "scale": { "dtype": "float32", "shape": [64], "dist": "uniform", "seed": 6302, "scale": 0.25, "offset": 1 },
74
+ "b": { "dtype": "float32", "shape": [64], "dist": "normal", "seed": 6303, "scale": 0.1 },
75
+ "inputMean": { "dtype": "float32", "shape": [64], "dist": "normal", "seed": 6304, "scale": 0.1 },
76
+ "inputVar": { "dtype": "float32", "shape": [64], "dist": "uniform", "seed": 6305, "scale": 0.5, "offset": 1 }
77
+ },
78
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 64, 63, 63] } },
79
+ "bench": {
80
+ "metrics": [
81
+ {
82
+ "type": "bandwidth",
83
+ "value": "args.batch * args.channels * args.height * args.width * dtypeBytes(args.dtype) * 2 + args.channels * dtypeBytes(args.dtype) * 4"
84
+ }
85
+ ]
86
+ }
87
+ }
88
+ ]
89
+ }
build/webgpu/manifest.json ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "ai.onnx",
3
+ "name": "BatchNormalization",
4
+ "sinceVersion": 15,
5
+ "description": "Applies inference-mode batch normalization: `Y = (X - input_mean) / sqrt(input_var + epsilon) * scale + B`. This package supports `training_mode=0`, rank-2-or-higher inputs, and a common float16 or float32 dtype for every tensor. ONNX training mode is intentionally not implemented because this inference-only release does not expose its required running-mean and running-variance outputs.",
6
+ "inputs": [
7
+ {
8
+ "role": "X",
9
+ "dtype": "T",
10
+ "description": "Input data tensor with shape `(N, C, D1, ..., Dn)`, normalized independently per channel using the supplied estimated statistics."
11
+ },
12
+ { "role": "scale", "dtype": "T", "rank": 1, "description": "Per-channel scale tensor with shape `(C)`." },
13
+ { "role": "B", "dtype": "T", "rank": 1, "description": "Per-channel bias tensor with shape `(C)`." },
14
+ {
15
+ "role": "input_mean",
16
+ "dtype": "T",
17
+ "rank": 1,
18
+ "description": "Precomputed estimated mean tensor with shape `(C)` used for inference."
19
+ },
20
+ {
21
+ "role": "input_var",
22
+ "dtype": "T",
23
+ "rank": 1,
24
+ "description": "Precomputed estimated variance tensor with shape `(C)` used for inference."
25
+ }
26
+ ],
27
+ "outputs": [
28
+ {
29
+ "role": "Y",
30
+ "dtype": "T",
31
+ "rank": "ranks.X",
32
+ "description": "Batch-normalized output tensor with the same shape as `X`.",
33
+ "shape": "shapes.X"
34
+ }
35
+ ],
36
+ "attributes": { "epsilon": 0.00001, "momentum": 0.9, "training_mode": 0 },
37
+ "attributeDescriptions": {
38
+ "epsilon": "Small value added to the variance before taking the square root to avoid division by zero.",
39
+ "momentum": "Standard ONNX running-statistics momentum. This inference-only package accepts the default `0.9`; non-default values are reserved for the unsupported training-state update.",
40
+ "training_mode": "Execution mode. This inference-only package supports the default value 0; value 1 is rejected because the ONNX training outputs are not exposed."
41
+ },
42
+ "attributeConstraints": {
43
+ "momentum": { "values": [0.9], "comparison": "float32" },
44
+ "training_mode": { "values": [0] }
45
+ },
46
+ "typeConstraints": { "T": ["float32", "float16"] },
47
+ "args": {
48
+ "x": { "kind": "tensor", "semantic": "X", "role": "input" },
49
+ "scale": { "kind": "tensor", "semantic": "scale", "role": "input" },
50
+ "b": { "kind": "tensor", "semantic": "B", "role": "input" },
51
+ "inputMean": { "kind": "tensor", "semantic": "input_mean", "role": "input" },
52
+ "inputVar": { "kind": "tensor", "semantic": "input_var", "role": "input" },
53
+ "y": { "kind": "tensor", "semantic": "Y", "role": "output" }
54
+ },
55
+ "tunables": { "WORKGROUP_SIZE": 256 },
56
+ "derive": {
57
+ "normalizationParamsOk": "ranks.scale == 1 and ranks.B == 1 and ranks.input_mean == 1 and ranks.input_var == 1 and dim(shapes.scale, 0) == dim(shapes.X, 1) and dim(shapes.B, 0) == dim(shapes.X, 1) and dim(shapes.input_mean, 0) == dim(shapes.X, 1) and dim(shapes.input_var, 0) == dim(shapes.X, 1)",
58
+ "inferenceContractOk": "f16Ok(dtypes.T) and ranks.X >= 2 and ranks.Y == ranks.X and sameShape(shapes.Y, shapes.X) and normalizationParamsOk"
59
+ },
60
+ "bindingSets": {
61
+ "ncInferenceVec4": [
62
+ {
63
+ "name": "x",
64
+ "arg": "x",
65
+ "semantic": "X",
66
+ "buffer": { "type": "read-only-storage" },
67
+ "elementType": "vec4<f32>"
68
+ },
69
+ {
70
+ "name": "scale",
71
+ "arg": "scale",
72
+ "semantic": "scale",
73
+ "buffer": { "type": "read-only-storage" },
74
+ "elementType": "vec4<f32>"
75
+ },
76
+ {
77
+ "name": "bias",
78
+ "arg": "b",
79
+ "semantic": "B",
80
+ "buffer": { "type": "read-only-storage" },
81
+ "elementType": "vec4<f32>"
82
+ },
83
+ {
84
+ "name": "input_mean",
85
+ "arg": "inputMean",
86
+ "semantic": "input_mean",
87
+ "buffer": { "type": "read-only-storage" },
88
+ "elementType": "vec4<f32>"
89
+ },
90
+ {
91
+ "name": "input_var",
92
+ "arg": "inputVar",
93
+ "semantic": "input_var",
94
+ "buffer": { "type": "read-only-storage" },
95
+ "elementType": "vec4<f32>"
96
+ },
97
+ { "name": "y", "arg": "y", "semantic": "Y", "buffer": { "type": "storage" }, "elementType": "vec4<f32>" },
98
+ {
99
+ "name": "params",
100
+ "semantic": "kernel.params",
101
+ "buffer": { "type": "uniform" },
102
+ "struct": {
103
+ "name": "Params",
104
+ "fields": [
105
+ { "name": "count4", "type": "u32", "value": "numel(shapes.Y) / 4" },
106
+ { "name": "channels4", "type": "u32", "value": "dim(shapes.X, 1) / 4" },
107
+ { "name": "epsilon", "type": "f32", "value": "attrs.epsilon" }
108
+ ]
109
+ }
110
+ }
111
+ ],
112
+ "spatialInferenceVec4": [
113
+ {
114
+ "name": "x",
115
+ "arg": "x",
116
+ "semantic": "X",
117
+ "buffer": { "type": "read-only-storage" },
118
+ "elementType": "vec4<f32>"
119
+ },
120
+ {
121
+ "name": "scale",
122
+ "arg": "scale",
123
+ "semantic": "scale",
124
+ "buffer": { "type": "read-only-storage" },
125
+ "elementType": "$T"
126
+ },
127
+ { "name": "bias", "arg": "b", "semantic": "B", "buffer": { "type": "read-only-storage" }, "elementType": "$T" },
128
+ {
129
+ "name": "input_mean",
130
+ "arg": "inputMean",
131
+ "semantic": "input_mean",
132
+ "buffer": { "type": "read-only-storage" },
133
+ "elementType": "$T"
134
+ },
135
+ {
136
+ "name": "input_var",
137
+ "arg": "inputVar",
138
+ "semantic": "input_var",
139
+ "buffer": { "type": "read-only-storage" },
140
+ "elementType": "$T"
141
+ },
142
+ { "name": "y", "arg": "y", "semantic": "Y", "buffer": { "type": "storage" }, "elementType": "vec4<f32>" },
143
+ {
144
+ "name": "params",
145
+ "semantic": "kernel.params",
146
+ "buffer": { "type": "uniform" },
147
+ "struct": {
148
+ "name": "Params",
149
+ "fields": [
150
+ { "name": "count4", "type": "u32", "value": "numel(shapes.Y) / 4" },
151
+ { "name": "spatial4", "type": "u32", "value": "inner(shapes.X, 1) / 4" },
152
+ { "name": "channels", "type": "u32", "value": "dim(shapes.X, 1)" },
153
+ { "name": "epsilon", "type": "f32", "value": "attrs.epsilon" }
154
+ ]
155
+ }
156
+ }
157
+ ],
158
+ "inferenceScalar": [
159
+ { "name": "x", "arg": "x", "semantic": "X", "buffer": { "type": "read-only-storage" }, "elementType": "$T" },
160
+ {
161
+ "name": "scale",
162
+ "arg": "scale",
163
+ "semantic": "scale",
164
+ "buffer": { "type": "read-only-storage" },
165
+ "elementType": "$T"
166
+ },
167
+ { "name": "bias", "arg": "b", "semantic": "B", "buffer": { "type": "read-only-storage" }, "elementType": "$T" },
168
+ {
169
+ "name": "input_mean",
170
+ "arg": "inputMean",
171
+ "semantic": "input_mean",
172
+ "buffer": { "type": "read-only-storage" },
173
+ "elementType": "$T"
174
+ },
175
+ {
176
+ "name": "input_var",
177
+ "arg": "inputVar",
178
+ "semantic": "input_var",
179
+ "buffer": { "type": "read-only-storage" },
180
+ "elementType": "$T"
181
+ },
182
+ { "name": "y", "arg": "y", "semantic": "Y", "buffer": { "type": "storage" }, "elementType": "$T" },
183
+ {
184
+ "name": "params",
185
+ "semantic": "kernel.params",
186
+ "buffer": { "type": "uniform" },
187
+ "struct": {
188
+ "name": "Params",
189
+ "fields": [
190
+ { "name": "channels", "type": "u32", "value": "dim(shapes.X, 1)" },
191
+ { "name": "height", "type": "u32", "value": "1 if ranks.X == 2 else dim(shapes.X, 2)" },
192
+ { "name": "width", "type": "u32", "value": "1 if ranks.X == 2 else inner(shapes.X, 2)" },
193
+ { "name": "epsilon", "type": "f32", "value": "attrs.epsilon" },
194
+ { "name": "count", "type": "u32", "value": "numel(shapes.Y)" }
195
+ ]
196
+ }
197
+ }
198
+ ]
199
+ },
200
+ "variants": [
201
+ {
202
+ "id": "inference_scalar",
203
+ "when": ["inferenceContractOk"],
204
+ "constants": { "scalar": "dtypes.T", "usesF16": "dtypes.T == \"f16\"" },
205
+ "passes": [
206
+ {
207
+ "id": "main",
208
+ "name": "BatchNormalization.InferenceScalar",
209
+ "shader": "batch-normalization-nchw.wgsl.jinja",
210
+ "bindings": "inferenceScalar",
211
+ "dispatch": { "threads": "numel(shapes.Y)", "workgroupSize": "tunables.WORKGROUP_SIZE" }
212
+ }
213
+ ]
214
+ },
215
+ {
216
+ "id": "nc_inference_vec4",
217
+ "priority": 110,
218
+ "when": ["inferenceContractOk", "dtypes.T == \"f32\"", "ranks.X == 2", "dim(shapes.X, 1) % 4 == 0"],
219
+ "passes": [
220
+ {
221
+ "id": "main",
222
+ "name": "BatchNormalization.NcInferenceVec4",
223
+ "shader": "batch-normalization-nc-vec4.wgsl.jinja",
224
+ "bindings": "ncInferenceVec4",
225
+ "dispatch": { "threads": "numel(shapes.Y) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
226
+ }
227
+ ]
228
+ },
229
+ {
230
+ "id": "nchw_inference_vec4",
231
+ "priority": 100,
232
+ "when": ["inferenceContractOk", "dtypes.T == \"f32\"", "ranks.X >= 3", "inner(shapes.X, 1) % 4 == 0"],
233
+ "passes": [
234
+ {
235
+ "id": "main",
236
+ "name": "BatchNormalization.InferenceVec4",
237
+ "shader": "batch-normalization-nchw-vec4.wgsl.jinja",
238
+ "bindings": "spatialInferenceVec4",
239
+ "dispatch": { "threads": "numel(shapes.Y) / 4", "workgroupSize": "tunables.WORKGROUP_SIZE" }
240
+ }
241
+ ]
242
+ }
243
+ ]
244
+ }
build/webgpu/metadata.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ai.onnx.BatchNormalization",
3
+ "id": "_ai_onnx_batchnormalization_webgpu_36b417d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "backend": { "type": "webgpu" },
7
+ "digest": {
8
+ "algorithm": "sha256",
9
+ "files": {
10
+ "batch-normalization-nc-vec4.wgsl.jinja": "Lrc9lNARoZohL7Uv2G+JcdoTcEs6dqsaiP1+NPW1rsk=",
11
+ "batch-normalization-nchw-vec4.wgsl.jinja": "Rsd2siANpuQMlk5/ueUS07ZKscDp/jF8EQKsOyQAXN8=",
12
+ "batch-normalization-nchw.wgsl.jinja": "TfDSthFwA8AdlFykWHTOroAgZeC/TS7i8Wt7OKHyJbc=",
13
+ "bench.json": "GitYvHBWRsJ0jrz/w4vwR6ryXBDINuJ0gS+Fcrml9Gc=",
14
+ "manifest.json": "YZlooDSV8vRLHoVdW2ELx4Bhy0CGOB8w5jIIBn7j5ig=",
15
+ "test.json": "uHgc/mVjiAXJHTJLWPa9ZswwhfBjhvH0QmiRAzqFncE="
16
+ }
17
+ },
18
+ "provenance": { "kernel": { "sha": "2e7068faf55e7f43df740015f6d1ee49391a41c5", "dirty": false } },
19
+ "webgpu": { "manifestSpec": "1.0", "specialized": true, "opPath": "ops/ai.onnx.BatchNormalization" }
20
+ }
build/webgpu/test.json ADDED
@@ -0,0 +1,620 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "op": "ai.onnx.BatchNormalization",
3
+ "fixtureArrays": {
4
+ "ort_positive_single_channel_7x7_exact_default_epsilon_input_x": [0.329876, -0.287158, -0.411425, 0.473621, 0.18156, -0.170596, -0.329516, -0.170733, -0.121664, 0.4372, -0.485668, 0.218049, -0.360263, 0.107016, 0.45358, 0.325056, 0.15995, 0.098852, -0.283453, -0.373051, 0.257542, 0.0614853, -0.0592363, 0.434488, -0.0179583, 0.398374, -0.451602, -0.132009, -0.174468, -0.0247169, 0.418897, -0.47159, -0.131925, 0.470943, 0.118357, 0.155664, 0.370062, -0.279229, 0.240311, -0.451034, 0.249178, -0.294496, 0.13683, -0.0806475, -0.309849, -0.450604, -0.28048, -0.420197, -0.433369]
5
+ },
6
+ "cases": [
7
+ {
8
+ "name": "dispatch_cliff_nc_inference_rank2",
9
+ "attrs": { "epsilon": 0.00001 },
10
+ "inputs": {
11
+ "x": { "dtype": "float32", "shape": [16776961, 1], "data": { "kind": "linspace", "start": -2.0, "end": 2.0 } },
12
+ "scale": { "dtype": "float32", "shape": [1], "data": { "kind": "constant", "value": 1.5 } },
13
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "constant", "value": 0.25 } },
14
+ "inputMean": { "dtype": "float32", "shape": [1], "data": { "kind": "constant", "value": 0.1 } },
15
+ "inputVar": { "dtype": "float32", "shape": [1], "data": { "kind": "constant", "value": 0.5 } }
16
+ },
17
+ "outputs": { "y": { "dtype": "float32", "shape": [16776961, 1], "tolerance": 0.0001 } }
18
+ },
19
+ {
20
+ "name": "nchw_inference",
21
+ "attrs": { "epsilon": 0.00001 },
22
+ "inputs": {
23
+ "x": {
24
+ "dtype": "float32",
25
+ "shape": [1, 3, 2, 2],
26
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, -1.0, -2.0, -3.0, -4.0, 2.0, 4.0, 6.0, 8.0] }
27
+ },
28
+ "scale": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1.0, 0.5, 2.0] } },
29
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 1.0, -1.0] } },
30
+ "inputMean": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [2.5, -2.5, 5.0] } },
31
+ "inputVar": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1.25, 1.25, 5.0] } }
32
+ },
33
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 3, 2, 2], "tolerance": 0.000001 } }
34
+ },
35
+ {
36
+ "name": "f32_subnormal_variance_epsilon_zero_gpu_gap",
37
+ "skipGpu": {
38
+ "category": "permanent",
39
+ "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: WebGPU/Metal flushes subnormals to zero in f32; the subnormal variance collapses to zero so inverseSqrt yields Infinity instead of a finite value."
40
+ },
41
+ "provenance": {
42
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
43
+ "test": "BatchNormTest.SpatialNoBatch_2",
44
+ "notes": "Valid epsilon=0 edge: subnormal input variance and tiny normal centered values should produce finite normalized outputs, not infinities."
45
+ },
46
+ "attrs": { "epsilon": 0 },
47
+ "inputs": {
48
+ "x": { "dtype": "float32", "shape": [1, 1, 2], "data": { "kind": "values", "values": [1e-20, -1e-20] } },
49
+ "scale": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.0] } },
50
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.0] } },
51
+ "inputMean": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.0] } },
52
+ "inputVar": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1e-40] } }
53
+ },
54
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 1, 2], "tolerance": 0.00001 } }
55
+ },
56
+ {
57
+ "name": "f32_subnormal_scale_rank3_gpu_gap",
58
+ "skipGpu": {
59
+ "category": "permanent",
60
+ "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: WebGPU/Metal flushes subnormals to zero in f32; the subnormal affine scale collapses to zero, losing the tiny output it should preserve."
61
+ },
62
+ "provenance": {
63
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
64
+ "test": "BatchNormTest.PositiveTestCase",
65
+ "notes": "Subnormal scale is a valid affine parameter; inference output should preserve the tiny normalized values."
66
+ },
67
+ "attrs": { "epsilon": 0.00001 },
68
+ "inputs": {
69
+ "x": { "dtype": "float32", "shape": [1, 1, 3], "data": { "kind": "values", "values": [-1.0, 0.0, 2.0] } },
70
+ "scale": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1e-40] } },
71
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.0] } },
72
+ "inputMean": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.0] } },
73
+ "inputVar": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.0] } }
74
+ },
75
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 1, 3], "tolerance": 1e-44 } }
76
+ },
77
+ {
78
+ "name": "f32_subnormal_scale_rank4_vec4_gpu_gap",
79
+ "skipGpu": {
80
+ "category": "permanent",
81
+ "reason": "Portable WGSL floating-point semantics do not guarantee preservation of the subnormal values required by this fixture. Backend evidence: WebGPU/Metal flushes subnormals to zero in f32; the subnormal affine scale collapses to zero (vec4 path)."
82
+ },
83
+ "provenance": {
84
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
85
+ "test": "BatchNormTest.PositiveTestCase",
86
+ "notes": "Vec4 inference companion: subnormal scale should not collapse an otherwise ordinary normalized channel to zero."
87
+ },
88
+ "attrs": { "epsilon": 0.00001 },
89
+ "inputs": {
90
+ "x": {
91
+ "dtype": "float32",
92
+ "shape": [1, 1, 2, 2],
93
+ "data": { "kind": "values", "values": [-1.0, 0.0, 1.0, 2.0] }
94
+ },
95
+ "scale": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-2e-40] } },
96
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.0] } },
97
+ "inputMean": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.0] } },
98
+ "inputVar": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.0] } }
99
+ },
100
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 1, 2, 2], "tolerance": 1e-44 } }
101
+ },
102
+ {
103
+ "name": "nc_inference_rank2",
104
+ "attrs": { "epsilon": 0.00001 },
105
+ "inputs": {
106
+ "x": {
107
+ "dtype": "float32",
108
+ "shape": [2, 3],
109
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] }
110
+ },
111
+ "scale": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1.0, 0.5, 2.0] } },
112
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 1.0, -1.0] } },
113
+ "inputMean": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [2.5, 3.5, 4.5] } },
114
+ "inputVar": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [2.25, 2.25, 2.25] } }
115
+ },
116
+ "outputs": { "y": { "dtype": "float32", "shape": [2, 3], "tolerance": 0.000001 } }
117
+ },
118
+ {
119
+ "name": "nc_inference_rank2_vec4",
120
+ "attrs": { "epsilon": 0.00001 },
121
+ "inputs": {
122
+ "x": {
123
+ "dtype": "float32",
124
+ "shape": [2, 8],
125
+ "data": { "kind": "fillFloat32", "sinStep": 0.17, "cosStep": 0.29 }
126
+ },
127
+ "scale": {
128
+ "dtype": "float32",
129
+ "shape": [8],
130
+ "data": { "kind": "values", "values": [1.0, 0.5, 2.0, -1.0, 0.25, 1.5, -0.75, 0.8] }
131
+ },
132
+ "b": {
133
+ "dtype": "float32",
134
+ "shape": [8],
135
+ "data": { "kind": "values", "values": [0.0, 1.0, -1.0, 0.25, 0.5, -0.5, 0.75, -0.25] }
136
+ },
137
+ "inputMean": {
138
+ "dtype": "float32",
139
+ "shape": [8],
140
+ "data": { "kind": "values", "values": [0.2, -0.3, 0.4, -0.5, 0.1, -0.2, 0.3, -0.4] }
141
+ },
142
+ "inputVar": {
143
+ "dtype": "float32",
144
+ "shape": [8],
145
+ "data": { "kind": "values", "values": [1.0, 0.75, 1.25, 2.0, 0.5, 1.5, 0.9, 1.1] }
146
+ }
147
+ },
148
+ "outputs": { "y": { "dtype": "float32", "shape": [2, 8], "tolerance": 0.000001 } }
149
+ },
150
+ {
151
+ "name": "ncl_inference_rank3",
152
+ "attrs": { "epsilon": 0.00001 },
153
+ "inputs": {
154
+ "x": {
155
+ "dtype": "float32",
156
+ "shape": [2, 3, 4],
157
+ "data": {
158
+ "kind": "values",
159
+ "values": [1.0, 2.0, 3.0, 4.0, -1.0, -2.0, -3.0, -4.0, 2.0, 4.0, 6.0, 8.0, 0.5, 1.5, 2.5, 3.5, -0.5, -1.5, -2.5, -3.5, 3.0, 5.0, 7.0, 9.0]
160
+ }
161
+ },
162
+ "scale": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1.0, 0.5, 2.0] } },
163
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 1.0, -1.0] } },
164
+ "inputMean": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [2.0, -2.5, 5.0] } },
165
+ "inputVar": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1.25, 1.25, 5.0] } }
166
+ },
167
+ "outputs": { "y": { "dtype": "float32", "shape": [2, 3, 4], "tolerance": 0.000001 } }
168
+ },
169
+ {
170
+ "name": "ncdhw_inference_rank5",
171
+ "attrs": { "epsilon": 0.00001 },
172
+ "inputs": {
173
+ "x": {
174
+ "dtype": "float32",
175
+ "shape": [1, 2, 2, 2, 2],
176
+ "data": {
177
+ "kind": "values",
178
+ "values": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0]
179
+ }
180
+ },
181
+ "scale": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [1.0, 0.5] } },
182
+ "b": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [0.0, 1.0] } },
183
+ "inputMean": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [4.5, -4.5] } },
184
+ "inputVar": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [5.25, 5.25] } }
185
+ },
186
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 2, 2, 2, 2], "tolerance": 0.000001 } }
187
+ },
188
+ {
189
+ "name": "ort_zero_variance_large_epsilon",
190
+ "provenance": {
191
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
192
+ "test": "BatchNormTest.PositiveTestCase",
193
+ "notes": "Project regression adapted from ORT BatchNormalization positive cases to stress zero variance with a large epsilon."
194
+ },
195
+ "attrs": { "epsilon": 0.25 },
196
+ "inputs": {
197
+ "x": {
198
+ "dtype": "float32",
199
+ "shape": [1, 2, 2, 2],
200
+ "data": { "kind": "values", "values": [1.0, 1.25, 0.75, 2.0, -3.0, -2.5, -4.0, -3.5] }
201
+ },
202
+ "scale": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [1.0, -2.0] } },
203
+ "b": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [0.5, -1.0] } },
204
+ "inputMean": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [1.0, -3.0] } },
205
+ "inputVar": { "dtype": "float32", "shape": [2], "data": { "kind": "constant", "value": 0.0 } }
206
+ },
207
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 2, 2, 2], "tolerance": 0.000001 } }
208
+ },
209
+ {
210
+ "name": "ort_positive_single_channel_7x7_generated",
211
+ "attrs": { "epsilon": 0.00001 },
212
+ "provenance": {
213
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
214
+ "test": "BatchNormTest.PositiveTestCase",
215
+ "notes": "Uses ORT's single-channel rank-4 shape and parameter values; X is generated deterministically."
216
+ },
217
+ "inputs": {
218
+ "x": {
219
+ "dtype": "float32",
220
+ "shape": [1, 1, 7, 7],
221
+ "data": { "kind": "fillFloat32", "sinStep": 0.07, "cosStep": 0.19, "scale": 0.75 }
222
+ },
223
+ "scale": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.589433] } },
224
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-0.384622] } },
225
+ "inputMean": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-2.45673] } },
226
+ "inputVar": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.37998] } }
227
+ },
228
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 1, 7, 7], "tolerance": 0.000001 } }
229
+ },
230
+ {
231
+ "name": "ort_pytorch_rank3_4x5x3_generated",
232
+ "attrs": { "epsilon": 0.00001 },
233
+ "provenance": {
234
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
235
+ "test": "BatchNormTest.BatchNorm1d_3d_Pytorch",
236
+ "notes": "Uses ORT's rank-3 Pytorch-style shape and parameter values; X is generated deterministically."
237
+ },
238
+ "inputs": {
239
+ "x": {
240
+ "dtype": "float32",
241
+ "shape": [4, 5, 3],
242
+ "data": { "kind": "fillFloat32", "sinStep": 0.11, "cosStep": 0.05, "scale": 1.25 }
243
+ },
244
+ "scale": {
245
+ "dtype": "float32",
246
+ "shape": [5],
247
+ "data": { "kind": "values", "values": [0.36102, 0.592982, 0.808513, 0.0531484, 0.0960613] }
248
+ },
249
+ "b": { "dtype": "float32", "shape": [5], "data": { "kind": "constant", "value": 0.0 } },
250
+ "inputMean": { "dtype": "float32", "shape": [5], "data": { "kind": "constant", "value": 0.0 } },
251
+ "inputVar": { "dtype": "float32", "shape": [5], "data": { "kind": "constant", "value": 1.0 } }
252
+ },
253
+ "outputs": { "y": { "dtype": "float32", "shape": [4, 5, 3], "tolerance": 0.000001 } }
254
+ },
255
+ {
256
+ "name": "ort_positive_single_channel_7x7_exact_default_epsilon",
257
+ "provenance": {
258
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
259
+ "test": "BatchNormTest.PositiveTestCaseDefaultEpsilon"
260
+ },
261
+ "inputs": {
262
+ "x": {
263
+ "dtype": "float32",
264
+ "shape": [1, 1, 7, 7],
265
+ "data": {
266
+ "kind": "values",
267
+ "values": { "$ref": "#/fixtureArrays/ort_positive_single_channel_7x7_exact_default_epsilon_input_x" }
268
+ }
269
+ },
270
+ "scale": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.589433] } },
271
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-0.384622] } },
272
+ "inputMean": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-2.45673] } },
273
+ "inputVar": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.37998] } }
274
+ },
275
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 1, 7, 7], "tolerance": 0.000001 } }
276
+ },
277
+ {
278
+ "name": "ort_pytorch_rank3_4x5x3_exact",
279
+ "attrs": { "epsilon": 0.00001 },
280
+ "provenance": {
281
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
282
+ "test": "BatchNormTest.BatchNorm1d_3d_Pytorch"
283
+ },
284
+ "inputs": {
285
+ "x": {
286
+ "dtype": "float32",
287
+ "shape": [4, 5, 3],
288
+ "data": {
289
+ "kind": "values",
290
+ "values": [0.948241, 1.23591, -0.39321, 1.4254, -0.730771, 0.439872, 0.0265089, 0.8748, -0.197505, 0.962646, 0.421469, 1.94512, 0.234179, -0.931897, -0.214905, -0.982965, -0.495436, 0.81949, -0.796605, -0.758605, 0.665557, 0.0909539, 1.10448, 1.91214, -1.97433, -2.26429, -0.384419, -0.226564, 0.230568, 0.533968, -1.31382, -0.156257, 0.532323, -0.16714, 0.971087, 0.600249, 0.858778, 0.423108, -0.414433, -1.17608, 0.673753, 0.278517, -2.19044, -0.161453, 1.17092, -0.155138, -0.094729, 0.19479, -1.17344, -0.213813, 0.118659, -2.39525, 0.257687, 0.784609, 0.297942, 1.10277, -1.58026, 0.197625, 0.0432784, 1.12924]
291
+ }
292
+ },
293
+ "scale": {
294
+ "dtype": "float32",
295
+ "shape": [5],
296
+ "data": { "kind": "values", "values": [0.36102, 0.592982, 0.808513, 0.0531484, 0.0960613] }
297
+ },
298
+ "b": { "dtype": "float32", "shape": [5], "data": { "kind": "constant", "value": 0.0 } },
299
+ "inputMean": { "dtype": "float32", "shape": [5], "data": { "kind": "constant", "value": 0.0 } },
300
+ "inputVar": { "dtype": "float32", "shape": [5], "data": { "kind": "constant", "value": 1.0 } }
301
+ },
302
+ "outputs": { "y": { "dtype": "float32", "shape": [4, 5, 3], "tolerance": 0.000001 } }
303
+ },
304
+ {
305
+ "name": "ort_positive_single_channel_5d_exact",
306
+ "attrs": { "epsilon": 0.00001 },
307
+ "provenance": {
308
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
309
+ "test": "BatchNormTest.PositiveTestCase_5D"
310
+ },
311
+ "inputs": {
312
+ "x": {
313
+ "dtype": "float32",
314
+ "shape": [1, 1, 7, 7, 1],
315
+ "data": {
316
+ "kind": "values",
317
+ "values": { "$ref": "#/fixtureArrays/ort_positive_single_channel_7x7_exact_default_epsilon_input_x" }
318
+ }
319
+ },
320
+ "scale": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.589433] } },
321
+ "b": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-0.384622] } },
322
+ "inputMean": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [-2.45673] } },
323
+ "inputVar": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [1.37998] } }
324
+ },
325
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 1, 7, 7, 1], "tolerance": 0.000001 } }
326
+ },
327
+ {
328
+ "name": "ort_pytorch_rank4_2x3x6x6_generated",
329
+ "provenance": {
330
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
331
+ "test": "BatchNormTest.BatchNorm2d_Pytorch",
332
+ "notes": "Uses the ORT PyTorch rank-4 shape and normalization parameters with deterministic fixture data to avoid committing the large literal tensor."
333
+ },
334
+ "attrs": { "epsilon": 0.00001 },
335
+ "inputs": {
336
+ "x": {
337
+ "dtype": "float32",
338
+ "shape": [2, 3, 6, 6],
339
+ "data": { "kind": "fillFloat32", "scale": 1.4, "sinStep": 0.017, "cosStep": 0.031 }
340
+ },
341
+ "scale": {
342
+ "dtype": "float32",
343
+ "shape": [3],
344
+ "data": { "kind": "values", "values": [0.736494, 0.580251, 0.374834] }
345
+ },
346
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 0.0, 0.0] } },
347
+ "inputMean": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 0.0, 0.0] } },
348
+ "inputVar": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1.0, 1.0, 1.0] } }
349
+ },
350
+ "outputs": { "y": { "dtype": "float32", "shape": [2, 3, 6, 6], "tolerance": 0.00001 } }
351
+ },
352
+ {
353
+ "name": "ort_pytorch_rank5_2x3x4x4x4_generated",
354
+ "provenance": {
355
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
356
+ "test": "BatchNormTest.BatchNorm3d_Pytorch",
357
+ "notes": "Uses the ORT PyTorch rank-5 shape and normalization parameters with deterministic fixture data to avoid committing the large literal tensor."
358
+ },
359
+ "attrs": { "epsilon": 0.00001 },
360
+ "inputs": {
361
+ "x": {
362
+ "dtype": "float32",
363
+ "shape": [2, 3, 4, 4, 4],
364
+ "data": { "kind": "fillFloat32", "scale": 1.1, "sinStep": 0.013, "cosStep": 0.019 }
365
+ },
366
+ "scale": {
367
+ "dtype": "float32",
368
+ "shape": [3],
369
+ "data": { "kind": "values", "values": [0.241661, 0.960798, 0.474727] }
370
+ },
371
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 0.0, 0.0] } },
372
+ "inputMean": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 0.0, 0.0] } },
373
+ "inputVar": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [1.0, 1.0, 1.0] } }
374
+ },
375
+ "outputs": { "y": { "dtype": "float32", "shape": [2, 3, 4, 4, 4], "tolerance": 0.00001 } }
376
+ },
377
+ {
378
+ "name": "onnx_backend_batchnorm_epsilon",
379
+ "attrs": { "epsilon": 0.009999999776482582 },
380
+ "inputs": {
381
+ "x": {
382
+ "dtype": "float32",
383
+ "shape": [2, 3, 4, 5],
384
+ "data": {
385
+ "kind": "values",
386
+ "values": [0.40746182203292847, 1.3439544439315796, -0.8182209730148315, 0.08270993828773499, -1.2910584211349487, -0.6611042022705078, -1.1801910400390625, 0.19764263927936554, 0.4138999879360199, 1.1973220109939575, 1.88335382938385, 0.7142238020896912, 2.2843334674835205, 1.5641025304794312, 0.6111037135124207, -0.8773633241653442, -1.6210875511169434, -0.5816730260848999, -0.5378339290618896, -1.5560237169265747, -0.05446484312415123, -1.8112788200378418, -0.6311752200126648, -0.9281591773033142, 1.4907219409942627, 0.19549933075904846, -0.4716043472290039, 1.8123546838760376, -2.294137477874756, 0.6512093544006348, -1.1304965019226074, -0.777346670627594, 1.115938425064087, 1.3394529819488525, -1.7674336433410645, 0.42441245913505554, 1.0893090963363647, -0.38418567180633545, 0.6322014331817627, -0.5496559143066406, 0.5211257338523865, 0.10834954679012299, 0.26166847348213196, -0.9147553443908691, 0.8582378029823303, 0.09433428943157196, -1.4859038591384888, -1.9005842208862305, -1.1375792026519775, -1.7620388269424438, -0.28862321376800537, 1.0479822158813477, 0.24995754659175873, 0.046904463320970535, -1.032243013381958, 0.4031856954097748, -0.6840592622756958, 1.262322187423706, -2.005556583404541, -0.33203038573265076, -0.2961004078388214, -2.218360662460327, -0.18350288271903992, 0.3923080563545227, 0.241634801030159, 0.10393591225147247, -0.8295711874961853, 0.4927593767642975, 0.09011279046535492, -0.9975675344467163, -0.80003821849823, 0.2070755809545517, 0.5234630107879639, -0.6993948221206665, 0.9137058258056641, -0.6727848052978516, 0.1333245038986206, 0.42689600586891174, -0.01284939143806696, -0.35224831104278564, 0.8194665908813477, 0.5219877362251282, 1.1972599029541016, -0.3824862241744995, 0.6916618943214417, 0.3538850247859955, 1.047585368156433, -0.4238962233066559, -3.514768123626709, -1.3431566953659058, 1.4255061149597168, 0.2285820096731186, -0.257663756608963, 0.0503707155585289, -1.3802108764648438, -0.26167207956314087, -0.1793796867132187, -0.6927706003189087, 1.137826919555664, -0.1691572517156601, -0.7639136910438538, -0.49807310104370117, -0.3628911077976227, 0.2639603018760681, -0.6296418905258179, -0.47225841879844666, -1.5133610963821411, 1.1076246500015259, 0.1762387454509735, -0.940353512763977, 0.9295943379402161, -1.0627949237823486, -0.8864062428474426, 1.92134690284729, -0.4597805142402649, -1.0890344381332397, 0.9841172695159912, -1.1592062711715698, -0.43653708696365356, 1.0092445611953735]
387
+ }
388
+ },
389
+ "scale": {
390
+ "dtype": "float32",
391
+ "shape": [3],
392
+ "data": { "kind": "values", "values": [0.7133895754814148, -0.7280577421188354, 0.8395164608955383] }
393
+ },
394
+ "b": {
395
+ "dtype": "float32",
396
+ "shape": [3],
397
+ "data": { "kind": "values", "values": [1.2390209436416626, -1.784803867340088, -0.7961858510971069] }
398
+ },
399
+ "inputMean": {
400
+ "dtype": "float32",
401
+ "shape": [3],
402
+ "data": { "kind": "values", "values": [-1.4005413055419922, -0.18435057997703552, -1.391193151473999] }
403
+ },
404
+ "inputVar": {
405
+ "dtype": "float32",
406
+ "shape": [3],
407
+ "data": { "kind": "values", "values": [0.044612299650907516, 0.7997958660125732, 0.07695644348859787] }
408
+ }
409
+ },
410
+ "outputs": { "y": { "dtype": "float32", "shape": [2, 3, 4, 5] } },
411
+ "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_batchnorm_epsilon" }
412
+ },
413
+ {
414
+ "name": "onnx_backend_batchnorm_example",
415
+ "inputs": {
416
+ "x": {
417
+ "dtype": "float32",
418
+ "shape": [2, 3, 4, 5],
419
+ "data": {
420
+ "kind": "values",
421
+ "values": [1.764052391052246, 0.40015721321105957, 0.978738009929657, 2.2408931255340576, 1.8675580024719238, -0.9772778749465942, 0.9500884413719177, -0.15135720372200012, -0.10321885347366333, 0.4105985164642334, 0.14404356479644775, 1.4542734622955322, 0.7610377073287964, 0.12167501449584961, 0.44386324286460876, 0.3336743414402008, 1.4940791130065918, -0.2051582634449005, 0.3130677044391632, -0.8540957570075989, -2.5529897212982178, 0.653618574142456, 0.8644362092018127, -0.7421650290489197, 2.269754648208618, -1.4543657302856445, 0.04575851559638977, -0.18718385696411133, 1.5327792167663574, 1.4693588018417358, 0.154947429895401, 0.37816253304481506, -0.8877857327461243, -1.980796456336975, -0.34791216254234314, 0.15634897351264954, 1.2302906513214111, 1.202379822731018, -0.38732680678367615, -0.302302747964859, -1.0485529899597168, -1.420017957687378, -1.7062702178955078, 1.950775384902954, -0.5096521973609924, -0.4380742907524109, -1.2527953386306763, 0.7774903774261475, -1.6138978004455566, -0.21274028718471527, -0.8954665660858154, 0.38690251111984253, -0.5108051300048828, -1.18063223361969, -0.02818222902715206, 0.4283318817615509, 0.06651721894741058, 0.30247190594673157, -0.6343221068382263, -0.3627411723136902, -0.6724604368209839, -0.35955315828323364, -0.8131462931632996, -1.7262825965881348, 0.17742614448070526, -0.4017809331417084, -1.630198359489441, 0.46278226375579834, -0.9072983860969543, 0.05194539576768875, 0.7290905714035034, 0.12898291647434235, 1.1394007205963135, -1.234825849533081, 0.4023416340351105, -0.6848101019859314, -0.8707971572875977, -0.5788496732711792, -0.3115525245666504, 0.056165341287851334, -1.1651498079299927, 0.9008265137672424, 0.4656624495983124, -1.5362436771392822, 1.4882521629333496, 1.895889163017273, 1.1787796020507812, -0.1799248307943344, -1.0707526206970215, 1.0544517040252686, -0.4031769335269928, 1.222445011138916, 0.2082749754190445, 0.9766390323638916, 0.3563663959503174, 0.7065731883049011, 0.01050002034753561, 1.7858705520629883, 0.12691208720207214, 0.4019893705844879, 1.8831506967544556, -1.3477590084075928, -1.2704850435256958, 0.969396710395813, -1.1731233596801758, 1.9436211585998535, -0.4136189818382263, -0.747454822063446, 1.922942042350769, 1.4805147647857666, 1.8675589561462402, 0.9060446619987488, -0.8612256646156311, 1.910064935684204, -0.26800337433815, 0.8024563789367676, 0.9472519755363464, -0.15501008927822113, 0.6140793561935425, 0.922206699848175]
422
+ }
423
+ },
424
+ "scale": {
425
+ "dtype": "float32",
426
+ "shape": [3],
427
+ "data": { "kind": "values", "values": [0.37642553448677063, -1.0994007587432861, 0.29823818802833557] }
428
+ },
429
+ "b": {
430
+ "dtype": "float32",
431
+ "shape": [3],
432
+ "data": { "kind": "values", "values": [1.3263858556747437, -0.694567859172821, -0.14963454008102417] }
433
+ },
434
+ "inputMean": {
435
+ "dtype": "float32",
436
+ "shape": [3],
437
+ "data": { "kind": "values", "values": [-0.4351535439491272, 1.8492637872695923, 0.6722947359085083] }
438
+ },
439
+ "inputVar": {
440
+ "dtype": "float32",
441
+ "shape": [3],
442
+ "data": { "kind": "values", "values": [0.9755215048789978, 0.855803370475769, 0.011714084073901176] }
443
+ }
444
+ },
445
+ "outputs": { "y": { "dtype": "float32", "shape": [2, 3, 4, 5] } },
446
+ "provenance": { "source": "cmake/external/onnx/onnx/backend/test/data/node/test_batchnorm_example" }
447
+ },
448
+ {
449
+ "name": "ort_fp16_inference_rank4",
450
+ "provenance": {
451
+ "source": "onnxruntime/test/providers/cpu/nn/batch_norm_op_test.cc",
452
+ "test": "BatchNormTest.BatchNorm2d_fp16",
453
+ "notes": "Compact rank-4 fp16 inference projection of ORT's BatchNorm2d_fp16 coverage."
454
+ },
455
+ "attrs": { "epsilon": 0.00001 },
456
+ "inputs": {
457
+ "x": {
458
+ "dtype": "float16",
459
+ "shape": [1, 2, 2, 2],
460
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, -1.0, 0.0, 1.0, 2.0] }
461
+ },
462
+ "scale": { "dtype": "float16", "shape": [2], "data": { "kind": "values", "values": [1.5, -2.0] } },
463
+ "b": { "dtype": "float16", "shape": [2], "data": { "kind": "values", "values": [0.25, 1.0] } },
464
+ "inputMean": { "dtype": "float16", "shape": [2], "data": { "kind": "values", "values": [2.5, 0.5] } },
465
+ "inputVar": { "dtype": "float16", "shape": [2], "data": { "kind": "values", "values": [1.25, 1.25] } }
466
+ },
467
+ "outputs": { "y": { "dtype": "float16", "shape": [1, 2, 2, 2], "tolerance": 0.002 } }
468
+ },
469
+ {
470
+ "name": "empty_zero_dim",
471
+ "attrs": { "epsilon": 0.00001 },
472
+ "inputs": {
473
+ "x": { "dtype": "float32", "shape": [0, 3, 2, 2], "data": { "kind": "values", "values": [] } },
474
+ "scale": { "dtype": "float32", "shape": [3], "data": { "kind": "constant", "value": 1.0 } },
475
+ "b": { "dtype": "float32", "shape": [3], "data": { "kind": "constant", "value": 0.0 } },
476
+ "inputMean": { "dtype": "float32", "shape": [3], "data": { "kind": "constant", "value": 0.0 } },
477
+ "inputVar": { "dtype": "float32", "shape": [3], "data": { "kind": "constant", "value": 1.0 } }
478
+ },
479
+ "outputs": { "y": { "dtype": "float32", "shape": [0, 3, 2, 2], "tolerance": 0 } }
480
+ },
481
+ {
482
+ "name": "empty_zero_dim_nc_vec4_rank2",
483
+ "attrs": { "epsilon": 0.00001 },
484
+ "inputs": {
485
+ "x": { "dtype": "float32", "shape": [0, 8], "data": { "kind": "values", "values": [] } },
486
+ "scale": {
487
+ "dtype": "float32",
488
+ "shape": [8],
489
+ "data": { "kind": "values", "values": [1.0, 0.5, 2.0, -1.0, 0.25, 1.5, -0.75, 0.8] }
490
+ },
491
+ "b": {
492
+ "dtype": "float32",
493
+ "shape": [8],
494
+ "data": { "kind": "values", "values": [0.0, 1.0, -1.0, 0.25, 0.5, -0.5, 0.75, -0.25] }
495
+ },
496
+ "inputMean": {
497
+ "dtype": "float32",
498
+ "shape": [8],
499
+ "data": { "kind": "values", "values": [0.2, -0.3, 0.4, -0.5, 0.1, -0.2, 0.3, -0.4] }
500
+ },
501
+ "inputVar": {
502
+ "dtype": "float32",
503
+ "shape": [8],
504
+ "data": { "kind": "values", "values": [1.0, 0.75, 1.25, 2.0, 0.5, 1.5, 0.9, 1.1] }
505
+ }
506
+ },
507
+ "outputs": { "y": { "dtype": "float32", "shape": [0, 8], "tolerance": 0 } }
508
+ },
509
+ {
510
+ "name": "nc_vec4_rank2_multigroup_3x12",
511
+ "attrs": { "epsilon": 0.00001 },
512
+ "inputs": {
513
+ "x": {
514
+ "dtype": "float32",
515
+ "shape": [3, 12],
516
+ "data": { "kind": "fillFloat32", "sinStep": 0.13, "cosStep": 0.23, "scale": 1.5 }
517
+ },
518
+ "scale": {
519
+ "dtype": "float32",
520
+ "shape": [12],
521
+ "data": { "kind": "values", "values": [1.0, 0.5, 2.0, -1.0, 0.25, 1.5, -0.75, 0.8, 1.2, -0.6, 0.9, -1.3] }
522
+ },
523
+ "b": {
524
+ "dtype": "float32",
525
+ "shape": [12],
526
+ "data": { "kind": "values", "values": [0.0, 1.0, -1.0, 0.25, 0.5, -0.5, 0.75, -0.25, 0.1, -0.1, 0.3, -0.3] }
527
+ },
528
+ "inputMean": {
529
+ "dtype": "float32",
530
+ "shape": [12],
531
+ "data": { "kind": "values", "values": [0.2, -0.3, 0.4, -0.5, 0.1, -0.2, 0.3, -0.4, 0.05, -0.05, 0.15, -0.15] }
532
+ },
533
+ "inputVar": {
534
+ "dtype": "float32",
535
+ "shape": [12],
536
+ "data": { "kind": "values", "values": [1.0, 0.75, 1.25, 2.0, 0.5, 1.5, 0.9, 1.1, 0.6, 1.4, 0.8, 1.2] }
537
+ }
538
+ },
539
+ "outputs": { "y": { "dtype": "float32", "shape": [3, 12], "tolerance": 0.000001 } }
540
+ },
541
+ {
542
+ "name": "nchw_inference_vec4_channel_boundary_1x4x1x4",
543
+ "attrs": { "epsilon": 0.00001 },
544
+ "inputs": {
545
+ "x": {
546
+ "dtype": "float32",
547
+ "shape": [1, 4, 1, 4],
548
+ "data": {
549
+ "kind": "values",
550
+ "values": [1.0, 2.0, 3.0, 4.0, -1.0, -2.0, -3.0, -4.0, 10.0, 20.0, 30.0, 40.0, 0.5, 1.5, 2.5, 3.5]
551
+ }
552
+ },
553
+ "scale": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [1.0, 0.5, 2.0, -1.5] } },
554
+ "b": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.0, 1.0, -1.0, 0.25] } },
555
+ "inputMean": {
556
+ "dtype": "float32",
557
+ "shape": [4],
558
+ "data": { "kind": "values", "values": [2.5, -2.5, 25.0, 2.0] }
559
+ },
560
+ "inputVar": {
561
+ "dtype": "float32",
562
+ "shape": [4],
563
+ "data": { "kind": "values", "values": [1.25, 1.25, 125.0, 1.25] }
564
+ }
565
+ },
566
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 4, 1, 4], "tolerance": 0.000001 } }
567
+ },
568
+ {
569
+ "name": "ort_f16_inference_near_zero_variance_multichannel",
570
+ "attrs": { "epsilon": 0.00001 },
571
+ "inputs": {
572
+ "x": {
573
+ "dtype": "float16",
574
+ "shape": [1, 3, 2, 2],
575
+ "data": {
576
+ "kind": "values",
577
+ "values": [8.0, 9.0, 10.0, 11.0, -4.0, -3.0, -2.0, -1.0, 100.0, 120.0, 140.0, 160.0]
578
+ }
579
+ },
580
+ "scale": { "dtype": "float16", "shape": [3], "data": { "kind": "values", "values": [2.0, 1.0, 0.5] } },
581
+ "b": { "dtype": "float16", "shape": [3], "data": { "kind": "values", "values": [0.5, -1.0, 2.0] } },
582
+ "inputMean": { "dtype": "float16", "shape": [3], "data": { "kind": "values", "values": [9.5, -2.5, 130.0] } },
583
+ "inputVar": { "dtype": "float16", "shape": [3], "data": { "kind": "values", "values": [0.01, 1.25, 400.0] } }
584
+ },
585
+ "outputs": { "y": { "dtype": "float16", "shape": [1, 3, 2, 2], "tolerance": 0.01 } }
586
+ },
587
+ {
588
+ "name": "inference_rank6_spatial_flatten",
589
+ "attrs": { "epsilon": 0.00001, "training_mode": 0 },
590
+ "inputs": {
591
+ "x": {
592
+ "dtype": "float32",
593
+ "shape": [1, 2, 2, 1, 2, 1],
594
+ "data": { "kind": "values", "values": [1.0, 2.0, 3.0, 4.0, -4.0, -2.0, 0.0, 2.0] }
595
+ },
596
+ "scale": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [2.0, 0.5] } },
597
+ "b": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [0.25, -1.0] } },
598
+ "inputMean": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [2.5, -1.0] } },
599
+ "inputVar": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [1.25, 5.0] } }
600
+ },
601
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 2, 2, 1, 2, 1], "tolerance": 0.000001 } }
602
+ },
603
+ {
604
+ "name": "inference_rank8_spatial_flatten",
605
+ "attrs": { "epsilon": 0.00001, "training_mode": 0 },
606
+ "inputs": {
607
+ "x": {
608
+ "dtype": "float32",
609
+ "shape": [1, 2, 2, 1, 2, 1, 2, 2],
610
+ "data": { "kind": "fillFloat32", "sinStep": 0.13, "cosStep": 0.27 }
611
+ },
612
+ "scale": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [1.5, -0.5] } },
613
+ "b": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [0.25, -1.0] } },
614
+ "inputMean": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [0.1, -0.2] } },
615
+ "inputVar": { "dtype": "float32", "shape": [2], "data": { "kind": "values", "values": [0.5, 2.0] } }
616
+ },
617
+ "outputs": { "y": { "dtype": "float32", "shape": [1, 2, 2, 1, 2, 1, 2, 2], "tolerance": 0.000001 } }
618
+ }
619
+ ]
620
+ }