Cast - version 21#
This page documents version 21 of operator Cast. See Cast for the latest version (since version 25).
Domain:
ai.onnxSince version: 21
The operator casts the elements of a given input tensor to a data type specified by the ‘to’ argument and returns an output tensor of the same size in the converted type. The ‘to’ argument must be one of the data types specified in the ‘DataType’ enum field in the TensorProto message.
Inputs
input (T1): Input tensor to be cast.
Outputs
output (T2): Output tensor with the same shape as input with type specified by the ‘to’ argument
Type Constraints
T1: Constrain input types. Casting from complex is not supported. Allowed types: tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8).
T2: Constrain output types. Casting to complex is not supported. Allowed types: tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8).
Examples#
test_cast_no_saturate_FLOAT16_to_FLOAT8E4M3FN
Node:
Cast(input) -> (output)
Attributes:
to = 17
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fn
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, nan, 0, nan, nan],
[nan, nan, -0, 0, nan]]
test_cast_no_saturate_FLOAT16_to_FLOAT8E4M3FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 18
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fnuz
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, nan, 0, nan, nan],
[nan, nan, 0, 0, nan]]
test_cast_no_saturate_FLOAT16_to_FLOAT8E5M2
Node:
Cast(input) -> (output)
Attributes:
to = 19
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, inf, 0, nan, inf],
[inf, -inf, -0, 0, -inf]]
test_cast_no_saturate_FLOAT16_to_FLOAT8E5M2FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 20
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2fnuz
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, nan, 0, nan, nan],
[nan, nan, 0, 0, nan]]
test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FN
Node:
Cast(input) -> (output)
Attributes:
to = 17
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fn
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, nan, 0, nan, nan],
[nan, nan, -0, 0, nan]]
test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 18
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fnuz
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, nan, 0, nan, nan],
[nan, nan, 0, 0, nan]]
test_cast_no_saturate_FLOAT_to_FLOAT8E5M2
Node:
Cast(input) -> (output)
Attributes:
to = 19
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, inf, 0, nan, inf],
[inf, -inf, -0, 0, -inf]]
test_cast_no_saturate_FLOAT_to_FLOAT8E5M2FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 20
saturate = 0
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2fnuz
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, nan, 0, nan, nan],
[nan, nan, 0, 0, nan]]
test_cc_cast_FLOAT16_to_FLOAT8E4M3FN
Node:
Cast(input) -> (output)
Attributes:
to = 17
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fn
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 448, 0, nan, 448],
[448, -448, -0, 0, -448]]
test_cc_cast_FLOAT16_to_FLOAT8E4M3FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 18
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fnuz
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 240, 0, nan, 240],
[240, -240, 0, 0, -240]]
test_cc_cast_FLOAT16_to_FLOAT8E5M2
Node:
Cast(input) -> (output)
Attributes:
to = 19
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, -0, 0, -57344]]
test_cc_cast_FLOAT16_to_FLOAT8E5M2FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 20
Inputs:
input: shape=(3, 5), dtype=float16
[[ 4.790e-01, 4.802e-01, 4.998e-01, 8.193e-01, 4.702e-01],
[ 7.231e-01, inf, 1.192e-07, nan, inf],
[ inf, -inf, -1.192e-07, 1.192e-07, -inf]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2fnuz
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, 0, 0, -57344]]
test_cc_cast_FLOAT16_to_INT4
Node:
Cast(input) -> (output)
Attributes:
to = 22
Inputs:
input: shape=(5, 5), dtype=float16
[[-9., -8., -7., -6., -5.],
[-4., -3., -2., -1., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10.],
[11., 12., 13., 14., 15.]]
Outputs:
output: shape=(5, 5), dtype=int4
[[7, -8, -7, -6, -5],
[-4, -3, -2, -1, 0],
[1, 2, 3, 4, 5],
[6, 7, -8, -7, -6],
[-5, -4, -3, -2, -1]]
test_cc_cast_FLOAT16_to_UINT4
Node:
Cast(input) -> (output)
Attributes:
to = 21
Inputs:
input: shape=(5, 5), dtype=float16
[[-9., -8., -7., -6., -5.],
[-4., -3., -2., -1., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10.],
[11., 12., 13., 14., 15.]]
Outputs:
output: shape=(5, 5), dtype=uint4
[[7, 8, 9, 10, 11],
[12, 13, 14, 15, 0],
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
test_cc_cast_FLOAT8E4M3FNUZ_to_FLOAT
Node:
Cast(input) -> (output)
Attributes:
to = 1
Inputs:
input: shape=(3, 5), dtype=float8_e4m3fnuz
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 240, 0, nan, 240],
[240, -240, 0, 0, -240]]
Outputs:
output: shape=(3, 5), dtype=float32
[[ 0.46875, 0.46875, 0.5 , 0.8125 , 0.46875],
[ 0.75 , 240. , 0. , nan, 240. ],
[ 240. , -240. , 0. , 0. , -240. ]]
test_cc_cast_FLOAT8E4M3FNUZ_to_FLOAT16
Node:
Cast(input) -> (output)
Attributes:
to = 10
Inputs:
input: shape=(3, 5), dtype=float8_e4m3fnuz
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 240, 0, nan, 240],
[240, -240, 0, 0, -240]]
Outputs:
output: shape=(3, 5), dtype=float16
[[ 0.4688, 0.4688, 0.5 , 0.8125, 0.4688],
[ 0.75 , 240. , 0. , nan, 240. ],
[ 240. , -240. , 0. , 0. , -240. ]]
test_cc_cast_FLOAT8E4M3FN_to_FLOAT
Node:
Cast(input) -> (output)
Attributes:
to = 1
Inputs:
input: shape=(3, 5), dtype=float8_e4m3fn
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 448, 0, nan, 448],
[448, -448, -0, 0, -448]]
Outputs:
output: shape=(3, 5), dtype=float32
[[ 0.46875, 0.46875, 0.5 , 0.8125 , 0.46875],
[ 0.75 , 448. , 0. , nan, 448. ],
[ 448. , -448. , -0. , 0. , -448. ]]
test_cc_cast_FLOAT8E4M3FN_to_FLOAT16
Node:
Cast(input) -> (output)
Attributes:
to = 10
Inputs:
input: shape=(3, 5), dtype=float8_e4m3fn
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 448, 0, nan, 448],
[448, -448, -0, 0, -448]]
Outputs:
output: shape=(3, 5), dtype=float16
[[ 0.4688, 0.4688, 0.5 , 0.8125, 0.4688],
[ 0.75 , 448. , 0. , nan, 448. ],
[ 448. , -448. , -0. , 0. , -448. ]]
test_cc_cast_FLOAT8E5M2FNUZ_to_FLOAT
Node:
Cast(input) -> (output)
Attributes:
to = 1
Inputs:
input: shape=(3, 5), dtype=float8_e5m2fnuz
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, 0, 0, -57344]]
Outputs:
output: shape=(3, 5), dtype=float32
[[ 5.0000e-01, 5.0000e-01, 5.0000e-01, 8.7500e-01, 5.0000e-01],
[ 7.5000e-01, 5.7344e+04, 0.0000e+00, nan, 5.7344e+04],
[ 5.7344e+04, -5.7344e+04, 0.0000e+00, 0.0000e+00, -5.7344e+04]]
test_cc_cast_FLOAT8E5M2FNUZ_to_FLOAT16
Node:
Cast(input) -> (output)
Attributes:
to = 10
Inputs:
input: shape=(3, 5), dtype=float8_e5m2fnuz
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, 0, 0, -57344]]
Outputs:
output: shape=(3, 5), dtype=float16
[[ 5.000e-01, 5.000e-01, 5.000e-01, 8.750e-01, 5.000e-01],
[ 7.500e-01, 5.734e+04, 0.000e+00, nan, 5.734e+04],
[ 5.734e+04, -5.734e+04, 0.000e+00, 0.000e+00, -5.734e+04]]
test_cc_cast_FLOAT8E5M2_to_FLOAT
Node:
Cast(input) -> (output)
Attributes:
to = 1
Inputs:
input: shape=(3, 5), dtype=float8_e5m2
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, -0, 0, -57344]]
Outputs:
output: shape=(3, 5), dtype=float32
[[ 5.0000e-01, 5.0000e-01, 5.0000e-01, 8.7500e-01, 5.0000e-01],
[ 7.5000e-01, 5.7344e+04, 0.0000e+00, nan, 5.7344e+04],
[ 5.7344e+04, -5.7344e+04, -0.0000e+00, 0.0000e+00, -5.7344e+04]]
test_cc_cast_FLOAT8E5M2_to_FLOAT16
Node:
Cast(input) -> (output)
Attributes:
to = 10
Inputs:
input: shape=(3, 5), dtype=float8_e5m2
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, -0, 0, -57344]]
Outputs:
output: shape=(3, 5), dtype=float16
[[ 5.000e-01, 5.000e-01, 5.000e-01, 8.750e-01, 5.000e-01],
[ 7.500e-01, 5.734e+04, 0.000e+00, nan, 5.734e+04],
[ 5.734e+04, -5.734e+04, -0.000e+00, 0.000e+00, -5.734e+04]]
test_cc_cast_FLOAT_to_FLOAT8E4M3FN
Node:
Cast(input) -> (output)
Attributes:
to = 17
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fn
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 448, 0, nan, 448],
[448, -448, -0, 0, -448]]
test_cc_cast_FLOAT_to_FLOAT8E4M3FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 18
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e4m3fnuz
[[0.46875, 0.46875, 0.5, 0.8125, 0.46875],
[0.75, 240, 0, nan, 240],
[240, -240, 0, 0, -240]]
test_cc_cast_FLOAT_to_FLOAT8E5M2
Node:
Cast(input) -> (output)
Attributes:
to = 19
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, -0, 0, -57344]]
test_cc_cast_FLOAT_to_FLOAT8E5M2FNUZ
Node:
Cast(input) -> (output)
Attributes:
to = 20
Inputs:
input: shape=(3, 5), dtype=float32
[[ 4.7892547e-01, 4.8033667e-01, 4.9968487e-01, 8.1910545e-01,
4.7031248e-01],
[ 7.2290379e-01, 1.0000000e+06, 1.0000000e-07, nan,
inf],
[ inf, -inf, -1.0000000e-07, 1.0000000e-07,
-1.0000000e+06]]
Outputs:
output: shape=(3, 5), dtype=float8_e5m2fnuz
[[0.5, 0.5, 0.5, 0.875, 0.5],
[0.75, 57344, 0, nan, 57344],
[57344, -57344, 0, 0, -57344]]
test_cc_cast_FLOAT_to_INT4
Node:
Cast(input) -> (output)
Attributes:
to = 22
Inputs:
input: shape=(5, 5), dtype=float32
[[-9., -8., -7., -6., -5.],
[-4., -3., -2., -1., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10.],
[11., 12., 13., 14., 15.]]
Outputs:
output: shape=(5, 5), dtype=int4
[[7, -8, -7, -6, -5],
[-4, -3, -2, -1, 0],
[1, 2, 3, 4, 5],
[6, 7, -8, -7, -6],
[-5, -4, -3, -2, -1]]
test_cc_cast_FLOAT_to_UINT4
Node:
Cast(input) -> (output)
Attributes:
to = 21
Inputs:
input: shape=(5, 5), dtype=float32
[[-9., -8., -7., -6., -5.],
[-4., -3., -2., -1., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10.],
[11., 12., 13., 14., 15.]]
Outputs:
output: shape=(5, 5), dtype=uint4
[[7, 8, 9, 10, 11],
[12, 13, 14, 15, 0],
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
test_cc_cast_INT4_to_FLOAT
Node:
Cast(input) -> (output)
Attributes:
to = 1
Inputs:
input: shape=(5, 5), dtype=int4
[[7, -8, -7, -6, -5],
[-4, -3, -2, -1, 0],
[1, 2, 3, 4, 5],
[6, 7, -8, -7, -6],
[-5, -4, -3, -2, -1]]
Outputs:
output: shape=(5, 5), dtype=float32
[[ 7., -8., -7., -6., -5.],
[-4., -3., -2., -1., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., -8., -7., -6.],
[-5., -4., -3., -2., -1.]]
test_cc_cast_INT4_to_FLOAT16
Node:
Cast(input) -> (output)
Attributes:
to = 10
Inputs:
input: shape=(5, 5), dtype=int4
[[7, -8, -7, -6, -5],
[-4, -3, -2, -1, 0],
[1, 2, 3, 4, 5],
[6, 7, -8, -7, -6],
[-5, -4, -3, -2, -1]]
Outputs:
output: shape=(5, 5), dtype=float16
[[ 7., -8., -7., -6., -5.],
[-4., -3., -2., -1., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., -8., -7., -6.],
[-5., -4., -3., -2., -1.]]
test_cc_cast_INT4_to_INT8
Node:
Cast(input) -> (output)
Attributes:
to = 3
Inputs:
input: shape=(5, 5), dtype=int4
[[7, -8, -7, -6, -5],
[-4, -3, -2, -1, 0],
[1, 2, 3, 4, 5],
[6, 7, -8, -7, -6],
[-5, -4, -3, -2, -1]]
Outputs:
output: shape=(5, 5), dtype=int8
[[ 7, -8, -7, -6, -5],
[-4, -3, -2, -1, 0],
[ 1, 2, 3, 4, 5],
[ 6, 7, -8, -7, -6],
[-5, -4, -3, -2, -1]]
test_cc_cast_UINT4_to_FLOAT
Node:
Cast(input) -> (output)
Attributes:
to = 1
Inputs:
input: shape=(5, 5), dtype=uint4
[[7, 8, 9, 10, 11],
[12, 13, 14, 15, 0],
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
Outputs:
output: shape=(5, 5), dtype=float32
[[ 7., 8., 9., 10., 11.],
[12., 13., 14., 15., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10.],
[11., 12., 13., 14., 15.]]
test_cc_cast_UINT4_to_FLOAT16
Node:
Cast(input) -> (output)
Attributes:
to = 10
Inputs:
input: shape=(5, 5), dtype=uint4
[[7, 8, 9, 10, 11],
[12, 13, 14, 15, 0],
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
Outputs:
output: shape=(5, 5), dtype=float16
[[ 7., 8., 9., 10., 11.],
[12., 13., 14., 15., 0.],
[ 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10.],
[11., 12., 13., 14., 15.]]
test_cc_cast_UINT4_to_UINT8
Node:
Cast(input) -> (output)
Attributes:
to = 2
Inputs:
input: shape=(5, 5), dtype=uint4
[[7, 8, 9, 10, 11],
[12, 13, 14, 15, 0],
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
Outputs:
output: shape=(5, 5), dtype=uint8
[[ 7, 8, 9, 10, 11],
[12, 13, 14, 15, 0],
[ 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
test_cc_cast_e8m0_FLOAT16_to_FLOAT8E8M0
Node:
Cast(input) -> (output)
Attributes:
to = 24
Inputs:
input: shape=(2, 4), dtype=float16
[[0. , 0.124, 0.25 , 0.5 ],
[1.1 , 2. , 4. , 8. ]]
Outputs:
output: shape=(2, 4), dtype=float8_e8m0fnu
[[5.87747e-39, 0.125, 0.25, 0.5],
[2, 2, 4, 8]]
test_cc_cast_e8m0_FLOAT8E8M0_to_FLOAT
Node:
Cast(input) -> (output)
Attributes:
to = 1
Inputs:
input: shape=(2, 4), dtype=float8_e8m0fnu
[[5.87747e-39, 0.125, 0.25, 0.5],
[2, 2, 4, 8]]
Outputs:
output: shape=(2, 4), dtype=float32
[[0. , 0.125, 0.25 , 0.5 ],
[2. , 2. , 4. , 8. ]]
test_cc_cast_e8m0_FLOAT8E8M0_to_FLOAT16
Node:
Cast(input) -> (output)
Attributes:
to = 10
Inputs:
input: shape=(2, 4), dtype=float8_e8m0fnu
[[5.87747e-39, 0.125, 0.25, 0.5],
[2, 2, 4, 8]]
Outputs:
output: shape=(2, 4), dtype=float16
[[0. , 0.125, 0.25 , 0.5 ],
[2. , 2. , 4. , 8. ]]
test_cc_cast_e8m0_FLOAT_to_FLOAT8E8M0
Node:
Cast(input) -> (output)
Attributes:
to = 24
Inputs:
input: shape=(2, 4), dtype=float32
[[0. , 0.124, 0.25 , 0.5 ],
[1.1 , 2. , 4. , 8. ]]
Outputs:
output: shape=(2, 4), dtype=float8_e8m0fnu
[[5.87747e-39, 0.125, 0.25, 0.5],
[2, 2, 4, 8]]
Differences with previous version (19)#
SchemaDiff: Cast (domain 'ai.onnx')
old version: 19
new version: 21
breaking: no
Type constraints:
changed ‘T1’: added types: [‘tensor(int4)’, ‘tensor(uint4)’]
changed ‘T2’: added types: [‘tensor(int4)’, ‘tensor(uint4)’]