ai.onnx.SwiGLU / build /webgpu /test.json
Xenova's picture
Xenova HF Staff
sync 6fdf6301e2bb
e34da4c verified
Raw History Blame
6.41 kB
{
"fixtureArrays": { "onnx_example_a": [1, -2, 3, 4, -1, 2, -3, 0.5], "onnx_example_b": [0.5, 1, -1, 2, 2, -1, 0.5, 1] },
"cases": [
{
"name": "half_function_rounding_vec4",
"inputs": {
"a": {
"dtype": "float16",
"shape": [4],
"data": { "kind": "values", "values": [-1.8203125, 0.0611572265625, -1.30859375, 0.96337890625] }
},
"b": {
"dtype": "float16",
"shape": [4],
"data": { "kind": "values", "values": [1.298828125, -0.1517333984375, -1.8056640625, 2.80859375] }
}
},
"outputs": {
"y": {
"dtype": "float16",
"shape": [4],
"data": { "kind": "values", "values": [-0.329345703125, -0.004779815673828125, 0.50244140625, 1.9580078125] },
"tolerance": 0.000002
}
},
"provenance": {
"source": "ONNX SwiGLU-28 Function body",
"notes": "Negative and positive gates with explicit half Sigmoid, Swish and Mul edges, in vectorized and scalar-tail execution."
}
},
{
"name": "half_function_rounding_scalar_tail",
"inputs": {
"a": {
"dtype": "float16",
"shape": [5],
"data": { "kind": "values", "values": [-1.8203125, 0.0611572265625, -1.30859375, 0.96337890625, -1.8203125] }
},
"b": {
"dtype": "float16",
"shape": [5],
"data": {
"kind": "values",
"values": [1.298828125, -0.1517333984375, -1.8056640625, 2.80859375, 1.298828125]
}
}
},
"outputs": {
"y": {
"dtype": "float16",
"shape": [5],
"data": {
"kind": "values",
"values": [-0.329345703125, -0.004779815673828125, 0.50244140625, 1.9580078125, -0.329345703125]
},
"tolerance": 0.000002
}
},
"provenance": {
"source": "ONNX SwiGLU-28 Function body",
"notes": "Negative and positive gates with explicit half Sigmoid, Swish and Mul edges, in vectorized and scalar-tail execution."
}
},
{
"name": "onnx_default_rank2",
"provenance": {
"source": "onnx/backend/test/case/node/swiglu.py",
"test": "test_swiglu",
"notes": "Standard ONNX-28 example using the default alpha of one."
},
"inputs": {
"a": {
"dtype": "float32",
"shape": [2, 4],
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_example_a" } }
},
"b": {
"dtype": "float32",
"shape": [2, 4],
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_example_b" } }
}
},
"outputs": { "y": { "dtype": "float32", "shape": [2, 4], "tolerance": 0.000001 } }
},
{
"name": "onnx_alpha_half_rank2",
"provenance": {
"source": "onnx/backend/test/case/node/swiglu.py",
"test": "test_swiglu_alpha",
"notes": "Standard ONNX-28 example with alpha set to 0.5."
},
"attrs": { "alpha": 0.5 },
"inputs": {
"a": {
"dtype": "float32",
"shape": [2, 4],
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_example_a" } }
},
"b": {
"dtype": "float32",
"shape": [2, 4],
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_example_b" } }
}
},
"outputs": { "y": { "dtype": "float32", "shape": [2, 4], "tolerance": 0.000001 } }
},
{
"name": "onnx_float16_rank2",
"provenance": {
"source": "onnx/backend/test/case/node/swiglu.py",
"test": "test_swiglu_float16",
"notes": "Standard ONNX-28 float16 example. The fused kernel preserves the typed Swish and final Mul boundaries from the operator's Function body."
},
"inputs": {
"a": {
"dtype": "float16",
"shape": [2, 4],
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_example_a" } }
},
"b": {
"dtype": "float16",
"shape": [2, 4],
"data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/onnx_example_b" } }
}
},
"outputs": { "y": { "dtype": "float16", "shape": [2, 4], "tolerance": 0.001 } }
},
{
"name": "float16_function_stage_boundaries",
"provenance": {
"source": "onnx/defs/math/defs.cc",
"test": "SwiGLU-28 Function body",
"notes": "Separates the standard typed Swish and Mul stages from a one-cast fused-float32 implementation."
},
"attrs": { "alpha": -0.4201333224773407 },
"inputs": {
"a": { "dtype": "float16", "shape": [1], "data": { "kind": "values", "values": [-3.376953125] } },
"b": { "dtype": "float16", "shape": [1], "data": { "kind": "values", "values": [0.5576171875] } }
},
"outputs": {
"y": { "dtype": "float16", "shape": [1], "data": { "kind": "values", "values": [-1.515625] }, "tolerance": 0 }
}
},
{
"name": "odd_rank3_scalar_x4",
"attrs": { "alpha": -0.75 },
"inputs": {
"a": {
"dtype": "float32",
"shape": [1, 2, 3],
"data": { "kind": "values", "values": [-4.0, -1.0, -0.25, 0.0, 1.5, 5.0] }
},
"b": {
"dtype": "float32",
"shape": [1, 2, 3],
"data": { "kind": "values", "values": [0.5, -2.0, 4.0, 8.0, -1.0, 0.25] }
}
},
"outputs": { "y": { "dtype": "float32", "shape": [1, 2, 3], "tolerance": 0.000001 } }
},
{
"name": "rank0_scalar",
"attrs": { "alpha": 2 },
"inputs": {
"a": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [-1.25] } },
"b": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [3.0] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [], "tolerance": 0.000001 } }
},
{
"name": "empty_rank4",
"inputs": {
"a": { "dtype": "float32", "shape": [2, 0, 3, 1], "data": { "kind": "values", "values": [] } },
"b": { "dtype": "float32", "shape": [2, 0, 3, 1], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [2, 0, 3, 1] } }
}
]
}