Xenova's picture
Xenova HF Staff
sync 2e7068faf55e
d047a99 verified
Raw
History Blame
15.3 kB
{
"op": "ai.onnx.CastLike",
"cases": [
{
"name": "float32_to_uint32_like",
"inputs": {
"x": {
"dtype": "float32",
"shape": [6],
"data": { "kind": "values", "values": [0.1, 1.9, 2.2, 5.8, 7.0, 9.6] }
},
"target": { "dtype": "uint32", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "uint32", "shape": [6] } }
},
{
"name": "uint32_to_float32_like_extremes",
"provenance": {
"source": "onnx/onnx/docs/Operators.md#CastLike-25",
"notes": "Provides executable source-side uint32 coverage, including values beyond signed-i32 and exact-f32 ranges."
},
"inputs": {
"x": {
"dtype": "uint32",
"shape": [4],
"data": { "kind": "values", "values": [0, 16777217, 2147483648, 4294967295] }
},
"target": { "dtype": "float32", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [4], "tolerance": 0 } }
},
{
"name": "bool_to_int32_like",
"provenance": {
"source": "onnx/onnx/docs/Operators.md#CastLike-25",
"notes": "Provides executable source-side bool coverage while keeping the logical bool contract distinct from widened u32 storage."
},
"inputs": {
"x": { "dtype": "bool", "shape": [4], "data": { "kind": "values", "values": [0, 1, 1, 0] } },
"target": { "dtype": "int32", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "int32", "shape": [4], "tolerance": 0 } }
},
{
"name": "int32_to_float32_like_scalar_target",
"inputs": {
"x": { "dtype": "int32", "shape": [2, 3], "data": { "kind": "values", "values": [-3, -1, 0, 1, 7, 12] } },
"target": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [0.0] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [2, 3] } }
},
{
"name": "uint8_to_float16_like",
"inputs": {
"x": { "dtype": "uint8", "shape": [4], "data": { "kind": "values", "values": [0, 1, 127, 255] } },
"target": { "dtype": "float16", "shape": [2, 2], "data": { "kind": "values", "values": [0.0, 0.0, 0.0, 0.0] } }
},
"outputs": { "y": { "dtype": "float16", "shape": [4] } },
"tolerance": 0.001
},
{
"name": "float16_to_int32_like",
"inputs": {
"x": { "dtype": "float16", "shape": [5], "data": { "kind": "values", "values": [-2.75, -1.1, 0.0, 1.9, 4.5] } },
"target": { "dtype": "int32", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "int32", "shape": [5] } }
},
{
"name": "ort_function_scalar_float_to_ranked_float_like",
"provenance": {
"source": "onnxruntime/test/framework/function_test.cc",
"test": "FunctionTest.AttrWithDefault",
"notes": "Covers ORT's use of CastLike inside a function body; the target tensor contributes only the output dtype, not the output shape."
},
"inputs": {
"x": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [2.0] } },
"target": { "dtype": "float32", "shape": [3], "data": { "kind": "values", "values": [0.0, 0.0, 0.0] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [], "tolerance": 0 } }
},
{
"name": "ort_scatternd_float32_to_float16_like_initializer",
"provenance": {
"source": "onnxruntime/test/python/onnxruntime_test_scatternd.py",
"test": "TestScatterND.common_scatter",
"notes": "Adapts ORT's ScatterND helper pattern where CastLike converts float input to the dtype of a float16 initializer before later graph ops."
},
"inputs": {
"x": { "dtype": "float32", "shape": [2, 2], "data": { "kind": "values", "values": [-3.5, -0.25, 1.5, 8.0] } },
"target": { "dtype": "float16", "shape": [1], "data": { "kind": "values", "values": [0.0] } }
},
"outputs": { "y": { "dtype": "float16", "shape": [2, 2], "tolerance": 0.001 } }
},
{
"name": "onnx_backend_empty_like_float32_to_int8",
"provenance": {
"source": "cmake/external/onnx/onnx/backend/test/case/node/castlike.py",
"test": "CastLike.export",
"notes": "Uses the ONNX backend generator pattern where the like tensor is empty and only supplies the target dtype."
},
"inputs": {
"x": { "dtype": "float32", "shape": [5], "data": { "kind": "values", "values": [-3.9, -1.1, 0.0, 1.9, 127.9] } },
"target": { "dtype": "int8", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "int8", "shape": [5], "tolerance": 0 } }
},
{
"name": "onnx_backend_empty_like_float32_to_uint8",
"provenance": {
"source": "cmake/external/onnx/onnx/backend/test/case/node/castlike.py",
"test": "CastLike.export",
"notes": "Uses the ONNX backend generator pattern where the like tensor is empty and only supplies the target dtype."
},
"inputs": {
"x": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.9, 1.9, 127.9, 255.9] } },
"target": { "dtype": "uint8", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "uint8", "shape": [4], "tolerance": 0 } }
},
{
"name": "onnx_backend_empty_like_int8_to_float32",
"provenance": {
"source": "cmake/external/onnx/onnx/backend/test/case/node/castlike.py",
"test": "CastLike.export",
"notes": "Uses the ONNX backend generator pattern where the like tensor is empty and only supplies the target dtype."
},
"inputs": {
"x": { "dtype": "int8", "shape": [4], "data": { "kind": "values", "values": [-128, -1, 0, 127] } },
"target": { "dtype": "float32", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [4], "tolerance": 0 } }
},
{
"name": "onnx_backend_empty_like_uint8_to_int32",
"provenance": {
"source": "cmake/external/onnx/onnx/backend/test/case/node/castlike.py",
"test": "CastLike.export",
"notes": "Uses the ONNX backend generator pattern where the like tensor is empty and only supplies the target dtype."
},
"inputs": {
"x": { "dtype": "uint8", "shape": [4], "data": { "kind": "values", "values": [0, 1, 127, 255] } },
"target": { "dtype": "int32", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "int32", "shape": [4], "tolerance": 0 } }
},
{
"name": "onnx_backend_castlike_float_to_float16",
"provenance": {
"source": "cmake/external/onnx/onnx/backend/test/data/node/test_castlike_FLOAT_to_FLOAT16",
"test": "test_castlike_FLOAT_to_FLOAT16"
},
"inputs": {
"x": {
"dtype": "float32",
"shape": [3, 4],
"data": {
"kind": "values",
"values": [0.4789254665374756, 0.48033666610717773, 0.4996848702430725, 0.8191054463386536, 0.4703124761581421, 0.8164680004119873, 0.21087194979190826, 0.7229037880897522, "NaN", "Infinity", "Infinity", "-Infinity"]
}
},
"target": { "dtype": "float16", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "float16", "shape": [3, 4], "tolerance": 0.001, "allowNaN": true } }
},
{
"name": "onnx_backend_castlike_float16_to_float",
"provenance": {
"source": "cmake/external/onnx/onnx/backend/test/data/node/test_castlike_FLOAT16_to_FLOAT",
"test": "test_castlike_FLOAT16_to_FLOAT"
},
"inputs": {
"x": {
"dtype": "float16",
"shape": [3, 4],
"data": {
"kind": "values",
"values": [0.47900390625, 0.480224609375, 0.499755859375, 0.8193359375, 0.47021484375, 0.81640625, 0.2108154296875, 0.72314453125, "NaN", "Infinity", "Infinity", "-Infinity"]
}
},
"target": { "dtype": "float32", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [3, 4], "tolerance": 0, "allowNaN": true } }
},
{
"name": "vec4_i32_to_f32_lanes",
"inputs": {
"x": {
"dtype": "int32",
"shape": [8],
"data": { "kind": "values", "values": [-100, -3, -1, 0, 1, 7, 12, 100] }
},
"target": { "dtype": "float32", "shape": [], "data": { "kind": "values", "values": [0.0] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [8], "tolerance": 0 } }
},
{
"name": "vec4_f32_to_i32_like_truncates_toward_zero",
"inputs": {
"x": {
"dtype": "float32",
"shape": [8],
"data": { "kind": "values", "values": [1.0, 2.9, -3.0, 0.0, 100.0, -0.5, -2.9, 127.75] }
},
"target": { "dtype": "int32", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "int32", "shape": [8], "tolerance": 0 } }
},
{
"name": "vec4_f16_to_i32_like_truncates_toward_zero",
"inputs": {
"x": {
"dtype": "float16",
"shape": [8],
"data": { "kind": "values", "values": [1.0, 2.5, -3.0, 0.0, 100.0, -0.5, -2.5, 7.5] }
},
"target": { "dtype": "int32", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "int32", "shape": [8], "tolerance": 0 } }
},
{
"name": "vec4_f32_to_i8_like_in_range_truncates",
"inputs": {
"x": {
"dtype": "float32",
"shape": [8],
"data": { "kind": "values", "values": [-128.0, -1.9, -0.5, 0.0, 1.9, 127.0, -127.75, 126.5] }
},
"target": { "dtype": "int8", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "int8", "shape": [8], "tolerance": 0 } }
},
{
"name": "scalar_x4_f32_to_u32_like_tail",
"inputs": {
"x": {
"dtype": "float32",
"shape": [17],
"data": {
"kind": "values",
"values": [0.0, 1.9, 2.2, 3.8, 4.0, 5.6, 6.1, 7.9, 8.0, 9.2, 10.7, 11.0, 12.4, 13.8, 14.0, 15.9, 16.2]
}
},
"target": { "dtype": "uint32", "shape": [0], "data": { "kind": "values", "values": [] } }
},
"outputs": { "y": { "dtype": "uint32", "shape": [17], "tolerance": 0 } }
},
{
"name": "vec4_tail_i8_to_f32_like_4097",
"inputs": {
"x": { "dtype": "int8", "shape": [4097], "data": { "kind": "constant", "value": -3 } },
"target": { "dtype": "float32", "shape": [1], "data": { "kind": "values", "values": [0.0] } }
},
"outputs": { "y": { "dtype": "float32", "shape": [4097], "tolerance": 0 } },
"provenance": { "notes": "Exercises a packed vec4 bulk followed by a scalar tail in the same dispatch." }
},
{
"name": "vec4_tail_f32_to_i8_like_4099",
"inputs": {
"x": {
"dtype": "float32",
"shape": [4099],
"data": { "kind": "cycle", "values": [1.5, -2.5, 126.25, -127.75, 63.5] }
},
"target": { "dtype": "int8", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "int8", "shape": [4099], "tolerance": 0 } },
"provenance": {
"notes": "CastLike to an int8 target above the vec4-tail crossover (4099 = 4096 packed elements plus a 3-element scalar tail), selecting the vec4 bulk plus scalar-tail path with its signed int8 storage conversion. Every value is within int8's representable range, so the fixture asserts ONNX-defined truncation toward zero without depending on undefined out-of-range float-to-fixed-point behavior."
}
},
{
"name": "vec4_tail_f16_to_u8_like_4099",
"inputs": {
"x": {
"dtype": "float16",
"shape": [4099],
"data": { "kind": "cycle", "values": [0.5, 200.75, 255.0, 254.25, 1.5, 44.5, 127.5] }
},
"target": { "dtype": "uint8", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "uint8", "shape": [4099], "tolerance": 0 } },
"provenance": {
"notes": "Float16 source with a uint8 target above the vec4-tail crossover: renders the scalar tail kernel with usesF16 and wrapNarrowInt both set and the UNSIGNED low-byte return. Every cycle value is exactly representable in float16 and lies within uint8's representable range. ONNX defines out-of-range float-to-fixed-point conversion as undefined, so this portable fixture deliberately does not assert wraparound for such values."
}
},
{
"name": "int32_to_bool_like",
"inputs": {
"x": { "dtype": "int32", "shape": [2, 3], "data": { "kind": "values", "values": [-3, 1, 0, 42, -1, 0] } },
"target": { "dtype": "bool", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": {
"y": {
"dtype": "bool",
"shape": [2, 3],
"tolerance": 0,
"data": { "kind": "values", "values": [1, 1, 0, 1, 1, 0] }
}
}
},
{
"name": "vec4_f32_finite_overflow_to_float16_like_saturate_vs_inf",
"inputs": {
"x": {
"dtype": "float32",
"shape": [8],
"data": { "kind": "values", "values": [70000.0, -1e+30, 65504.0, 65600.0, 1.0, -2.5, 0.0, -70000.0] }
},
"target": { "dtype": "float16", "shape": [1], "data": { "kind": "values", "values": [0.0] } }
},
"outputs": { "y": { "dtype": "float16", "shape": [8], "tolerance": 0.001 } }
},
{
"name": "vec4_f32_nonzero_special_to_bool_like",
"inputs": {
"x": {
"dtype": "float32",
"shape": [8],
"data": { "kind": "values", "values": ["NaN", "Infinity", "-Infinity", 0.0, 0.0, 1.0, -2.5, 1e-30] }
},
"target": { "dtype": "bool", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": {
"y": {
"dtype": "bool",
"shape": [8],
"tolerance": 0,
"data": { "kind": "values", "values": [1, 1, 1, 0, 0, 1, 1, 1] }
}
}
},
{
"name": "rank7_vec4_f32_to_i32",
"inputs": {
"x": {
"dtype": "float32",
"shape": [1, 1, 1, 1, 1, 1, 8],
"data": { "kind": "values", "values": [0.1, 1.9, 2.2, 5.8, 7.0, 9.6, -3.7, -1.2] }
},
"target": { "dtype": "int32", "shape": [1], "data": { "kind": "values", "values": [0] } }
},
"outputs": { "y": { "dtype": "int32", "shape": [1, 1, 1, 1, 1, 1, 8], "tolerance": 0 } },
"provenance": {
"notes": "Rank-7 flat input on the shared vec4 unary cast kernel (indexes by flat numel; sibling Cast has no rank cap). Covers the regime the removed 'ranks.x <= 6' guard rejected."
}
}
]
}