Skip to content

Instantly share code, notes, and snippets.

@justinchuby
Created July 2, 2025 21:50
Show Gist options
  • Save justinchuby/bc5b40213b0e2319eeb717b524726664 to your computer and use it in GitHub Desktop.
Save justinchuby/bc5b40213b0e2319eeb717b524726664 to your computer and use it in GitHub Desktop.
Cast verification
"""Verify the cast values"""
import os
import onnx
import onnx_ir as ir
DIR = "onnx/backend/test/data/node/"
def verify_one_case(path: str):
test_name = os.path.basename(path)
input_path = os.path.join(path, "test_data_set_0", "input_0.pb")
output_path = os.path.join(path, "test_data_set_0", "output_0.pb")
input_tensor = ir.from_proto(onnx.load_tensor(input_path))
output_tensor = ir.from_proto(onnx.load_tensor(output_path))
print("Test", test_name)
print(" Input:", input_tensor)
print(" Input Numpy:", input_tensor.numpy())
print()
print(" Input Bytes:", input_tensor.tobytes().hex(" "))
print()
print(" Output:", output_tensor)
print(" Output Numpy:", output_tensor.numpy())
print()
print(" Output Bytes:", output_tensor.tobytes().hex(" "))
print()
print("--------------------")
def main():
for file in sorted(os.listdir(DIR)):
if file.startswith("test_cast_") and "STRING" not in file:
path = os.path.join(DIR, file)
verify_one_case(path)
if __name__ == "__main__":
main()
@justinchuby
Copy link
Author

Test test_cast_BFLOAT16_to_FLOAT
Input: TensorProtoTensor<UINT16,[3,4]>(name='input')
Input Numpy: [[16117 16117 16127 16209]
[16112 16209 15959 16185]
[32704 32640 32640 65408]]

Input Bytes: f5 3e f5 3e ff 3e 51 3f f0 3e 51 3f 57 3e 39 3f c0 7f 80 7f 80 7f 80 ff

Output: TensorProtoTensor<FLOAT,[3,4]>(name='output')
Output Numpy: [[0.47851562 0.47851562 0.49804688 0.81640625]

[0.46875 0.81640625 0.20996094 0.72265625]
[ nan inf inf -inf]]

Output Bytes: 00 00 f5 3e 00 00 f5 3e 00 00 ff 3e 00 00 51 3f 00 00 f0 3e 00 00 51 3f 00 00 57 3e 00 00 39 3f 00 00 c0 7f 00 0

0 80 7f 00 00 80 7f 00 00 80 ff

Test test_cast_DOUBLE_to_FLOAT
Input: TensorProtoTensor<DOUBLE,[3,4]>(name='input')
Input Numpy: [[0.31542835 0.36371077 0.57019677 0.43860151]
[0.98837384 0.10204481 0.20887676 0.16130952]
[0.65310833 0.2532916 0.46631077 0.24442559]]

Input Bytes: 52 d6 dc 64 fa 2f d4 3f 5c b2 99 8a 09 47 d7 3f fe 58 27 4c 0d 3f e2 3f 46 fe 12 15 0c 12 dc 3f cc f6 d5 2b c2 a0

ef 3f 80 a8 e3 d4 9b 1f ba 3f 7c 33 29 3a 79 bc ca 3f 3c bf ec 4f ca a5 c4 3f 92 d0 53 6e 43 e6 e4 3f 7a a0 50 fb ed 35 d0 3f 34 2e cc 23 09 d8 dd 3f b8 e5 f9 79 56 49 cf 3f
Output: TensorProtoTensor<FLOAT,[3,4]>(name='output')
Output Numpy: [[0.31542835 0.36371076 0.57019675 0.43860152]
[0.9883738 0.10204481 0.20887676 0.16130951]
[0.6531083 0.2532916 0.46631077 0.2444256 ]]

Output Bytes: d3 7f a1 3e 4c 38 ba 3e 6a f8 11 3f 61 90 e0 3e 11 06 7d 3f df fc d0 3d ca e3 55 3e 52 2e 25 3e 1b 32 27 3f 70 a

f 81 3e 49 c0 ee 3e b4 4a 7a 3e

Test test_cast_DOUBLE_to_FLOAT16
Input: TensorProtoTensor<DOUBLE,[3,4]>(name='input')
Input Numpy: [[0.15896958 0.11037514 0.65632959 0.13818295]
[0.19658236 0.36872517 0.82099323 0.09710128]
[0.83794491 0.09609841 0.97645947 0.4686512 ]]

Input Bytes: ac 7a 68 85 1d 59 c4 3f 28 92 97 95 8b 41 bc 3f 88 d0 44 e9 a6 00 e5 3f 64 1a 74 9c fa af c1 3f 68 71 31 5f 9c 29

c9 3f e2 da 4c 75 31 99 d7 3f b9 e5 0d 98 93 45 ea 3f e8 5a ee 13 a1 db b8 3f d4 d3 b1 d6 71 d0 ea 3f 60 2c 1a bf e7 99 b8 3f 26 45 83 eb 27 3f ef 3f f0 b5 13 9c 61 fe dd 3f
Output: TensorProtoTensor<FLOAT16,[3,4]>(name='output')
Output Numpy: [[0.1589 0.11035 0.6562 0.1382 ]
[0.1965 0.3687 0.821 0.0971 ]
[0.838 0.09607 0.9766 0.4688 ]]

Output Bytes: 16 31 10 2f 40 39 6c 30 4a 32 e6 35 91 3a 37 2e b4 3a 26 2e d0 3b 80 37

Test test_cast_FLOAT16_to_DOUBLE
Input: TensorProtoTensor<FLOAT16,[3,4]>(name='input')
Input Numpy: [[0.6123 0.6167 0.944 0.6816]
[0.3596 0.437 0.6978 0.0602]
[0.667 0.6704 0.2103 0.1289]]

Input Bytes: e6 38 ef 38 8d 3b 74 39 c1 35 fe 36 95 39 b5 2b 56 39 5d 39 bb 32 20 30

Output: TensorProtoTensor<DOUBLE,[3,4]>(name='output')
Output Numpy: [[0.61230469 0.61669922 0.94384766 0.68164062]

[0.35961914 0.43701172 0.69775391 0.06021118]
[0.66699219 0.67041016 0.21032715 0.12890625]]

Output Bytes: 00 00 00 00 00 98 e3 3f 00 00 00 00 00 bc e3 3f 00 00 00 00 00 34 ee 3f 00 00 00 00 00 d0 e5 3f 00 00 00 00 00 0

4 d7 3f 00 00 00 00 00 f8 db 3f 00 00 00 00 00 54 e6 3f 00 00 00 00 00 d4 ae 3f 00 00 00 00 00 58 e5 3f 00 00 00 00 00 74 e5 3f 00 00 00 00 00 ec ca 3f 00 00 00 00 00 80 c0 3f

Test test_cast_FLOAT16_to_FLOAT
Input: TensorProtoTensor<FLOAT16,[3,4]>(name='input')
Input Numpy: [[0.1183 0.64 0.1433 0.945 ]
[0.522 0.4146 0.2646 0.7744 ]
[0.456 0.5684 0.01878 0.6177 ]]

Input Bytes: 92 2f 1f 39 96 30 8f 3b 2d 38 a2 36 3c 34 32 3a 4c 37 8c 38 cf 24 f1 38

Output: TensorProtoTensor<FLOAT,[3,4]>(name='output')
Output Numpy: [[0.11828613 0.6401367  0.14331055 0.9448242 ]

[0.52197266 0.41455078 0.26464844 0.77441406]
[0.4560547 0.5683594 0.01878357 0.6176758 ]]

Output Bytes: 00 40 f2 3d 00 e0 23 3f 00 c0 12 3e 00 e0 71 3f 00 a0 05 3f 00 40 d4 3e 00 80 87 3e 00 40 46 3f 00 80 e9 3e 00 8

0 11 3f 00 e0 99 3c 00 20 1e 3f

Test test_cast_FLOAT16_to_FLOAT4E2M1
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 4.80e-01 2.50e-01 1.05e+00 -3.50e+00 -8.00e+00]
[ 9.00e+00 inf 1.19e-07 nan inf]
[ inf -inf -4.00e+00 1.00e-02 -0.00e+00]]

Input Bytes: ae 37 00 34 33 3c 00 c3 00 c8 80 48 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 00 c4 1f 21 00 80

Output: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='y')
Output Numpy: [[0.5 0 1 -4 -6]

[6 6 0 6 6]
[6 -6 -4 0 -0]]

Output Bytes: 01 e2 7f 07 77 f7 0e 08

Test test_cast_FLOAT16_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Output Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Test test_cast_FLOAT16_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Output Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT16_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Output Bytes: 38 38 38 3b 38 3a 7b 00 7f 7b 7b fb 80 00 fb

Test test_cast_FLOAT16_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Output Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT16_to_INT4
Input: TensorProtoTensor<FLOAT16,[5,5]>(name='input')
Input Numpy: [[-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.]]

Input Bytes: 80 c8 00 c8 00 c7 00 c6 00 c5 00 c4 00 c2 00 c0 00 bc 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 48 80 48

00 49 80 49 00 4a 80 4a 00 4b 80 4b
Output: TensorProtoTensor<INT4,[5,5]>(name='output')
Output Numpy: [[-8 -8 -7 -6 -5]
[-4 -3 -2 -1 0]
[1 2 3 4 5]
[6 7 7 7 7]
[7 7 7 7 7]]

Output Bytes: 88 a9 cb ed 0f 21 43 65 77 77 77 77 07

Test test_cast_FLOAT16_to_UINT4
Input: TensorProtoTensor<FLOAT16,[5,5]>(name='input')
Input Numpy: [[-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.]]

Input Bytes: 80 c8 00 c8 00 c7 00 c6 00 c5 00 c4 00 c2 00 c0 00 bc 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 48 80 48

00 49 80 49 00 4a 80 4a 00 4b 80 4b
Output: TensorProtoTensor<UINT4,[5,5]>(name='output')
Output Numpy: [[0 0 0 0 0]
[0 0 0 0 0]
[1 2 3 4 5]
[6 7 8 9 10]
[11 12 13 14 15]]

Output Bytes: 00 00 00 00 00 21 43 65 87 a9 cb ed 0f

Test test_cast_FLOAT4E2M1_to_FLOAT
Input: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='x')
Input Numpy: [[0.5 0 1 -4 -6]
[6 6 0 6 6]
[6 -6 -4 0 -0]]

Input Bytes: 01 e2 7f 07 77 f7 0e 08

Output: TensorProtoTensor<FLOAT,[3,5]>(name='y')
Output Numpy: [[ 0.5  0.   1.  -4.  -6. ]

[ 6. 6. 0. 6. 6. ]
[ 6. -6. -4. 0. -0. ]]

Output Bytes: 00 00 00 3f 00 00 00 00 00 00 80 3f 00 00 80 c0 00 00 c0 c0 00 00 c0 40 00 00 c0 40 00 00 00 00 00 00 c0 40 00 0

0 c0 40 00 00 c0 40 00 00 c0 c0 00 00 80 c0 00 00 00 00 00 00 00 80

Test test_cast_FLOAT4E2M1_to_FLOAT16
Input: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='x')
Input Numpy: [[0.5 0 1 -4 -6]
[6 6 0 6 6]
[6 -6 -4 0 -0]]

Input Bytes: 01 e2 7f 07 77 f7 0e 08

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='y')
Output Numpy: [[ 0.5  0.   1.  -4.  -6. ]

[ 6. 6. 0. 6. 6. ]
[ 6. -6. -4. 0. -0. ]]

Output Bytes: 00 38 00 00 00 3c 00 c4 00 c6 00 46 00 46 00 00 00 46 00 46 00 46 00 c6 00 c4 00 00 00 80

Test test_cast_FLOAT8E4M3FNUZ_to_FLOAT
Input: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Input Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[   0.46875    0.46875    0.5        0.8125     0.46875]

[ 0.75 240. 0. nan 240. ]
[ 240. -240. 0. 0. -240. ]]

Output Bytes: 00 00 f0 3e 00 00 f0 3e 00 00 00 3f 00 00 50 3f 00 00 f0 3e 00 00 40 3f 00 00 70 43 00 00 00 00 00 00 c0 7f 00 0

0 70 43 00 00 70 43 00 00 70 c3 00 00 00 00 00 00 00 00 00 00 70 c3

Test test_cast_FLOAT8E4M3FNUZ_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Input Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[   0.4688    0.4688    0.5       0.8125    0.4688]

[ 0.75 240. 0. nan 240. ]
[ 240. -240. 0. 0. -240. ]]

Output Bytes: 80 37 80 37 00 38 80 3a 80 37 00 3a 80 5b 00 00 00 7e 80 5b 80 5b 80 db 00 00 00 00 80 db

Test test_cast_FLOAT8E4M3FN_to_FLOAT
Input: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Input Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[   0.46875    0.46875    0.5        0.8125     0.46875]

[ 0.75 448. 0. nan 448. ]
[ 448. -448. -0. 0. -448. ]]

Output Bytes: 00 00 f0 3e 00 00 f0 3e 00 00 00 3f 00 00 50 3f 00 00 f0 3e 00 00 40 3f 00 00 e0 43 00 00 00 00 00 00 c0 7f 00 0

0 e0 43 00 00 e0 43 00 00 e0 c3 00 00 00 80 00 00 00 00 00 00 e0 c3

Test test_cast_FLOAT8E4M3FN_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Input Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[   0.4688    0.4688    0.5       0.8125    0.4688]

[ 0.75 448. 0. nan 448. ]
[ 448. -448. -0. 0. -448. ]]

Output Bytes: 80 37 80 37 00 38 80 3a 80 37 00 3a 00 5f 00 00 00 7e 00 5f 00 5f 00 df 00 80 00 00 00 df

Test test_cast_FLOAT8E5M2FNUZ_to_FLOAT
Input: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Input Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 00 00 3f 00 00 00 3f 00 00 00 3f 00 00 60 3f 00 00 00 3f 00 00 40 3f 00 00 60 47 00 00 00 00 00 00 c0 7f 00 0

0 60 47 00 00 60 47 00 00 60 c7 00 00 00 00 00 00 00 00 00 00 60 c7

Test test_cast_FLOAT8E5M2FNUZ_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Input Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 38 00 38 00 38 00 3b 00 38 00 3a 00 7b 00 00 00 7e 00 7b 00 7b 00 fb 00 00 00 00 00 fb

Test test_cast_FLOAT8E5M2_to_FLOAT
Input: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Input Bytes: 38 38 38 3b 38 3a 7b 00 7f 7b 7b fb 80 00 fb

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 00 00 3f 00 00 00 3f 00 00 00 3f 00 00 60 3f 00 00 00 3f 00 00 40 3f 00 00 60 47 00 00 00 00 00 00 c0 7f 00 0

0 60 47 00 00 60 47 00 00 60 c7 00 00 00 80 00 00 00 00 00 00 60 c7

Test test_cast_FLOAT8E5M2_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Input Bytes: 38 38 38 3b 38 3a 7b 00 7f 7b 7b fb 80 00 fb

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 38 00 38 00 38 00 3b 00 38 00 3a 00 7b 00 00 00 7e 00 7b 00 7b 00 fb 00 80 00 00 00 fb

Test test_cast_FLOAT_to_BFLOAT16
Input: TensorProtoTensor<FLOAT,[3,4]>(name='input')
Input Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.7229038 ]
[ nan inf inf -inf]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 0c 04 51 3f d1 ee 57 3e 39 10 39 3f 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff
Output: TensorProtoTensor<UINT16,[3,4]>(name='output')
Output Numpy: [[16117 16117 16127 16209]
[16112 16209 15959 16185]
[32704 32640 32640 65408]]

Output Bytes: f5 3e f5 3e ff 3e 51 3f f0 3e 51 3f 57 3e 39 3f c0 7f 80 7f 80 7f 80 ff

Test test_cast_FLOAT_to_DOUBLE
Input: TensorProtoTensor<FLOAT,[3,4]>(name='input')
Input Numpy: [[0.56804454 0.92559665 0.07103606 0.0871293 ]
[0.0202184 0.83261985 0.77815676 0.87001216]
[0.9786183 0.7991586 0.46147937 0.7805292 ]]

Input Bytes: 5e 6b 11 3f e7 f3 6c 3f 5a 7b 91 3d d9 70 b2 3d 0d a1 a5 3c 93 26 55 3f 48 35 47 3f 1e b9 5e 3f bb 86 7a 3f a8 95

4c 3f 06 47 ec 3e c3 d0 47 3f
Output: TensorProtoTensor<DOUBLE,[3,4]>(name='output')
Output Numpy: [[0.56804454 0.92559665 0.07103606 0.0871293 ]
[0.0202184 0.83261985 0.77815676 0.87001216]
[0.97861832 0.79915857 0.46147937 0.7805292 ]]

Output Bytes: 00 00 00 c0 6b 2d e2 3f 00 00 00 e0 7c 9e ed 3f 00 00 00 40 6b 2f b2 3f 00 00 00 20 1b 4e b6 3f 00 00 00 a0 21 b

4 94 3f 00 00 00 60 d2 a4 ea 3f 00 00 00 00 a9 e6 e8 3f 00 00 00 c0 23 d7 eb 3f 00 00 00 60 d7 50 ef 3f 00 00 00 00 b5 92 e9 3f 00 00 00 c0 e0 88 dd 3f 00 00 00 60 18 fa e8 3f

Test test_cast_FLOAT_to_FLOAT16
Input: TensorProtoTensor<FLOAT,[3,4]>(name='input')
Input Numpy: [[0.5488135 0.71518934 0.60276335 0.5448832 ]
[0.4236548 0.6458941 0.4375872 0.891773 ]
[0.96366274 0.3834415 0.79172504 0.5288949 ]]

Input Bytes: 0b 7f 0c 3f a6 16 37 3f b3 4e 1a 3f 77 7d 0b 3f 48 e9 d8 3e 51 59 25 3f 6e 0b e0 3e 3c 4b 64 3f 9a b2 76 3f 72 52

c4 3e 7e ae 4a 3f a8 65 07 3f
Output: TensorProtoTensor<FLOAT16,[3,4]>(name='output')
Output Numpy: [[0.549 0.7153 0.6025 0.545 ]
[0.4236 0.646 0.4375 0.8916]
[0.964 0.3835 0.7915 0.529 ]]

Output Bytes: 64 38 b9 39 d2 38 5c 38 c7 36 2b 39 00 37 22 3b b6 3b 23 36 55 3a 3b 38

Test test_cast_FLOAT_to_FLOAT4E2M1
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 4.80e-01 2.50e-01 1.05e+00 -3.50e+00 -8.00e+00]
[ 9.00e+00 1.00e+06 1.00e-07 nan inf]
[ inf -inf -4.00e+00 1.00e-02 -0.00e+00]]

Input Bytes: 8f c2 f5 3e 00 00 80 3e 66 66 86 3f 00 00 60 c0 00 00 00 c1 00 00 10 41 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 00 00 80 c0 0a d7 23 3c 00 00 00 80
Output: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='y')
Output Numpy: [[0.5 0 1 -4 -6]
[6 6 0 6 6]
[6 -6 -4 0 -0]]

Output Bytes: 01 e2 7f 07 77 f7 0e 08

Test test_cast_FLOAT_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Output Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Test test_cast_FLOAT_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Output Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Output Bytes: 38 38 38 3b 38 3a 7b 00 7f 7b 7b fb 80 00 fb

Test test_cast_FLOAT_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Output Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT_to_INT4
Input: TensorProtoTensor<FLOAT,[5,5]>(name='input')
Input Numpy: [[-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.]]

Input Bytes: 00 00 10 c1 00 00 00 c1 00 00 e0 c0 00 00 c0 c0 00 00 a0 c0 00 00 80 c0 00 00 40 c0 00 00 00 c0 00 00 80 bf 00 00

00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 00 41 00 00 10 41 00 00 20 41 00 00 30 41 00 00 40 41 00 00 50 41 00 00 60 41 00 00 70 41
Output: TensorProtoTensor<INT4,[5,5]>(name='output')
Output Numpy: [[-8 -8 -7 -6 -5]
[-4 -3 -2 -1 0]
[1 2 3 4 5]
[6 7 7 7 7]
[7 7 7 7 7]]

Output Bytes: 88 a9 cb ed 0f 21 43 65 77 77 77 77 07

Test test_cast_FLOAT_to_UINT4
Input: TensorProtoTensor<FLOAT,[5,5]>(name='input')
Input Numpy: [[-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.]]

Input Bytes: 00 00 10 c1 00 00 00 c1 00 00 e0 c0 00 00 c0 c0 00 00 a0 c0 00 00 80 c0 00 00 40 c0 00 00 00 c0 00 00 80 bf 00 00

00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 00 41 00 00 10 41 00 00 20 41 00 00 30 41 00 00 40 41 00 00 50 41 00 00 60 41 00 00 70 41
Output: TensorProtoTensor<UINT4,[5,5]>(name='output')
Output Numpy: [[0 0 0 0 0]
[0 0 0 0 0]
[1 2 3 4 5]
[6 7 8 9 10]
[11 12 13 14 15]]

Output Bytes: 00 00 00 00 00 21 43 65 87 a9 cb ed 0f

Test test_cast_INT4_to_FLOAT
Input: TensorProtoTensor<INT4,[5,5]>(name='input')
Input Numpy: [[-8 -8 -7 -6 -5]
[-4 -3 -2 -1 0]
[1 2 3 4 5]
[6 7 7 7 7]
[7 7 7 7 7]]

Input Bytes: 88 a9 cb ed 0f 21 43 65 77 77 77 77 07

Output: TensorProtoTensor<FLOAT,[5,5]>(name='output')
Output Numpy: [[-8. -8. -7. -6. -5.]

[-4. -3. -2. -1. 0.]
[ 1. 2. 3. 4. 5.]
[ 6. 7. 7. 7. 7.]
[ 7. 7. 7. 7. 7.]]

Output Bytes: 00 00 00 c1 00 00 00 c1 00 00 e0 c0 00 00 c0 c0 00 00 a0 c0 00 00 80 c0 00 00 40 c0 00 00 00 c0 00 00 80 bf 00 0

0 00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 e0 40 00 00 e0 40 00 00 e0 40 00 00 e0 40 00 00 e0 40 00 00 e0 40 00 00 e0 40 00 00 e0 40

Test test_cast_INT4_to_FLOAT16
Input: TensorProtoTensor<INT4,[5,5]>(name='input')
Input Numpy: [[-8 -8 -7 -6 -5]
[-4 -3 -2 -1 0]
[1 2 3 4 5]
[6 7 7 7 7]
[7 7 7 7 7]]

Input Bytes: 88 a9 cb ed 0f 21 43 65 77 77 77 77 07

Output: TensorProtoTensor<FLOAT16,[5,5]>(name='output')
Output Numpy: [[-8. -8. -7. -6. -5.]

[-4. -3. -2. -1. 0.]
[ 1. 2. 3. 4. 5.]
[ 6. 7. 7. 7. 7.]
[ 7. 7. 7. 7. 7.]]

Output Bytes: 00 c8 00 c8 00 c7 00 c6 00 c5 00 c4 00 c2 00 c0 00 bc 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 47 00 4

7 00 47 00 47 00 47 00 47 00 47 00 47

Test test_cast_INT4_to_INT8
Input: TensorProtoTensor<INT4,[5,5]>(name='input')
Input Numpy: [[-8 -8 -7 -6 -5]
[-4 -3 -2 -1 0]
[1 2 3 4 5]
[6 7 7 7 7]
[7 7 7 7 7]]

Input Bytes: 88 a9 cb ed 0f 21 43 65 77 77 77 77 07

Output: TensorProtoTensor<INT8,[5,5]>(name='output')
Output Numpy: [[-8 -8 -7 -6 -5]

[-4 -3 -2 -1 0]
[ 1 2 3 4 5]
[ 6 7 7 7 7]
[ 7 7 7 7 7]]

Output Bytes: f8 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 07 07 07 07 07 07 07 07

Test test_cast_UINT4_to_FLOAT
Input: TensorProtoTensor<UINT4,[5,5]>(name='input')
Input Numpy: [[0 0 0 0 0]
[0 0 0 0 0]
[1 2 3 4 5]
[6 7 8 9 10]
[11 12 13 14 15]]

Input Bytes: 00 00 00 00 00 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<FLOAT,[5,5]>(name='output')
Output Numpy: [[ 0.  0.  0.  0.  0.]

[ 0. 0. 0. 0. 0.]
[ 1. 2. 3. 4. 5.]
[ 6. 7. 8. 9. 10.]
[11. 12. 13. 14. 15.]]

Output Bytes: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0

0 00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 00 41 00 00 10 41 00 00 20 41 00 00 30 41 00 00 40 41 00 00 50 41 00 00 60 41 00 00 70 41

Test test_cast_UINT4_to_FLOAT16
Input: TensorProtoTensor<UINT4,[5,5]>(name='input')
Input Numpy: [[0 0 0 0 0]
[0 0 0 0 0]
[1 2 3 4 5]
[6 7 8 9 10]
[11 12 13 14 15]]

Input Bytes: 00 00 00 00 00 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<FLOAT16,[5,5]>(name='output')
Output Numpy: [[ 0.  0.  0.  0.  0.]

[ 0. 0. 0. 0. 0.]
[ 1. 2. 3. 4. 5.]
[ 6. 7. 8. 9. 10.]
[11. 12. 13. 14. 15.]]

Output Bytes: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 48 80 4

8 00 49 80 49 00 4a 80 4a 00 4b 80 4b

Test test_cast_UINT4_to_UINT8
Input: TensorProtoTensor<UINT4,[5,5]>(name='input')
Input Numpy: [[0 0 0 0 0]
[0 0 0 0 0]
[1 2 3 4 5]
[6 7 8 9 10]
[11 12 13 14 15]]

Input Bytes: 00 00 00 00 00 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<UINT8,[5,5]>(name='output')
Output Numpy: [[ 0  0  0  0  0]

[ 0 0 0 0 0]
[ 1 2 3 4 5]
[ 6 7 8 9 10]
[11 12 13 14 15]]

Output Bytes: 00 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 nan 0 nan nan]
[nan nan -0 0 nan]]

Output Bytes: 2f 2f 30 35 2f 34 7f 00 7f 7f 7f ff 80 00 ff

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 37 37 38 3d 37 3c 80 00 80 80 80 80 00 00 80

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 inf 0 nan inf]
[inf -inf -0 0 -inf]]

Output Bytes: 38 38 38 3b 38 3a 7c 00 7f 7c 7c fc 80 00 fc

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 3c 3c 3c 3f 3c 3e 80 00 80 80 80 80 00 00 80

Test test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 nan 0 nan nan]
[nan nan -0 0 nan]]

Output Bytes: 2f 2f 30 35 2f 34 7f 00 7f 7f 7f ff 80 00 ff

Test test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 37 37 38 3d 37 3c 80 00 80 80 80 80 00 00 80

Test test_cast_no_saturate_FLOAT_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 inf 0 nan inf]
[inf -inf -0 0 -inf]]

Output Bytes: 38 38 38 3b 38 3a 7c 00 7f 7c 7c fc 80 00 fc

Test test_cast_no_saturate_FLOAT_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 3c 3c 3c 3f 3c 3e 80 00 80 80 80 80 00 00 80

@justinchuby
Copy link
Author

Test test_cast_BFLOAT16_to_FLOAT
Input: TensorProtoTensor<BFLOAT16,[3,4]>(name='x')
Input Numpy: [[0.478516 0.480469 0.5 0.820312]
[0.470703 0.816406 0.210938 0.722656]
[nan inf inf -inf]]

Input Bytes: f5 3e f6 3e 00 3f 52 3f f1 3e 51 3f 58 3e 39 3f c0 7f 80 7f 80 7f 80 ff

Output: TensorProtoTensor<FLOAT,[3,4]>(name='x')
Output Numpy: [[0.47851562 0.48046875 0.5        0.8203125 ]

[0.47070312 0.81640625 0.2109375 0.72265625]
[ nan inf inf -inf]]

Output Bytes: 00 00 f5 3e 00 00 f6 3e 00 00 00 3f 00 00 52 3f 00 00 f1 3e 00 00 51 3f 00 00 58 3e 00 00 39 3f 00 00 c0 7f 00 0

0 80 7f 00 00 80 7f 00 00 80 ff

Test test_cast_DOUBLE_to_FLOAT
Input: TensorProtoTensor<DOUBLE,[3,4]>(name='x')
Input Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.72290379]
[ nan inf inf -inf]]

Input Bytes: 00 00 00 00 b7 a6 de 3f 00 00 00 00 d6 bd de 3f 00 00 00 40 d6 fa df 3f 00 00 00 a0 1c 36 ea 3f 00 00 00 80 99 19

de 3f 00 00 00 80 81 20 ea 3f 00 00 00 20 da fd ca 3f 00 00 00 20 07 22 e7 3f 00 00 00 00 00 00 f8 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 ff
Output: TensorProtoTensor<FLOAT,[3,4]>(name='x')
Output Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.7229038 ]
[ nan inf inf -inf]]

Output Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 0c 04 51 3f d1 ee 57 3e 39 10 39 3f 00 00 c0 7f 00 0

0 80 7f 00 00 80 7f 00 00 80 ff

Test test_cast_DOUBLE_to_FLOAT16
Input: TensorProtoTensor<DOUBLE,[3,4]>(name='x')
Input Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.72290379]
[ nan inf inf -inf]]

Input Bytes: 00 00 00 00 b7 a6 de 3f 00 00 00 00 d6 bd de 3f 00 00 00 40 d6 fa df 3f 00 00 00 a0 1c 36 ea 3f 00 00 00 80 99 19

de 3f 00 00 00 80 81 20 ea 3f 00 00 00 20 da fd ca 3f 00 00 00 20 07 22 e7 3f 00 00 00 00 00 00 f8 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 ff
Output: TensorProtoTensor<FLOAT16,[3,4]>(name='x')
Output Numpy: [[0.479 0.4802 0.4998 0.8193]
[0.4702 0.8164 0.2108 0.723 ]
[ nan inf inf -inf]]

Output Bytes: aa 37 af 37 ff 37 8e 3a 86 37 88 3a bf 32 c9 39 00 7e 00 7c 00 7c 00 fc

Test test_cast_FLOAT16_to_DOUBLE
Input: TensorProtoTensor<FLOAT16,[3,4]>(name='x')
Input Numpy: [[0.479 0.4802 0.4998 0.8193]
[0.4702 0.8164 0.2108 0.723 ]
[ nan inf inf -inf]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 88 3a bf 32 c9 39 00 7e 00 7c 00 7c 00 fc

Output: TensorProtoTensor<DOUBLE,[3,4]>(name='x')
Output Numpy: [[0.47900391 0.48022461 0.49975586 0.81933594]

[0.47021484 0.81640625 0.21081543 0.72314453]
[ nan inf inf -inf]]

Output Bytes: 00 00 00 00 00 a8 de 3f 00 00 00 00 00 bc de 3f 00 00 00 00 00 fc df 3f 00 00 00 00 00 38 ea 3f 00 00 00 00 00 1

8 de 3f 00 00 00 00 00 20 ea 3f 00 00 00 00 00 fc ca 3f 00 00 00 00 00 24 e7 3f 00 00 00 00 00 00 f8 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 ff

Test test_cast_FLOAT16_to_FLOAT
Input: TensorProtoTensor<FLOAT16,[3,4]>(name='x')
Input Numpy: [[0.479 0.4802 0.4998 0.8193]
[0.4702 0.8164 0.2108 0.723 ]
[ nan inf inf -inf]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 88 3a bf 32 c9 39 00 7e 00 7c 00 7c 00 fc

Output: TensorProtoTensor<FLOAT,[3,4]>(name='x')
Output Numpy: [[0.4790039  0.4802246  0.49975586 0.81933594]

[0.47021484 0.81640625 0.21081543 0.72314453]
[ nan inf inf -inf]]

Output Bytes: 00 40 f5 3e 00 e0 f5 3e 00 e0 ff 3e 00 c0 51 3f 00 c0 f0 3e 00 00 51 3f 00 e0 57 3e 00 20 39 3f 00 00 c0 7f 00 0

0 80 7f 00 00 80 7f 00 00 80 ff

Test test_cast_FLOAT16_to_FLOAT4E2M1
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 4.80e-01 2.50e-01 1.05e+00 -3.50e+00 -8.00e+00]
[ 9.00e+00 inf 1.19e-07 nan inf]
[ inf -inf -4.00e+00 1.00e-02 -0.00e+00]]

Input Bytes: ae 37 00 34 33 3c 00 c3 00 c8 80 48 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 00 c4 1f 21 00 80

Output: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='x')
Output Numpy: [[0 0 -6 -6 -1]

[-6 4 0 0 0]
[-1 -6 -2 -6 0]]

Output Bytes: 01 e2 7f 07 78 f7 0e 08

Test test_cast_FLOAT16_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Output Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Test test_cast_FLOAT16_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Output Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT16_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Output Bytes: 38 38 38 3b 38 3a 7b 00 7e 7b 7b fb 80 00 fb

Test test_cast_FLOAT16_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Output Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT16_to_INT4
Input: TensorProtoTensor<FLOAT16,[5,5]>(name='x')
Input Numpy: [[-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.]]

Input Bytes: 80 c8 00 c8 00 c7 00 c6 00 c5 00 c4 00 c2 00 c0 00 bc 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 48 80 48

00 49 80 49 00 4a 80 4a 00 4b 80 4b
Output: TensorProtoTensor<INT4,[5,5]>(name='x')
Output Numpy: [[7 0 -7 -1 -5]
[-1 -3 -1 -1 -1]
[1 0 3 0 5]
[0 7 0 -7 -1]
[-5 -1 -3 -1 -1]]

Output Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Test test_cast_FLOAT16_to_UINT4
Input: TensorProtoTensor<FLOAT16,[5,5]>(name='x')
Input Numpy: [[-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.]]

Input Bytes: 80 c8 00 c8 00 c7 00 c6 00 c5 00 c4 00 c2 00 c0 00 bc 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 48 80 48

00 49 80 49 00 4a 80 4a 00 4b 80 4b
Output: TensorProtoTensor<UINT4,[5,5]>(name='x')
Output Numpy: [[7 0 9 0 11]
[0 13 0 15 0]
[1 0 3 0 5]
[0 7 0 9 0]
[11 0 13 0 15]]

Output Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Test test_cast_FLOAT4E2M1_to_FLOAT
Input: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='x')
Input Numpy: [[0 0 -6 -6 -1]
[-6 4 0 0 0]
[-1 -6 -2 -6 0]]

Input Bytes: 01 e2 7f 07 78 f7 0e 08

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[ 0.5  0.   1.  -4.  -6. ]

[ 6. 6. 0. -0. 6. ]
[ 6. -6. -4. 0. -0. ]]

Output Bytes: 00 00 00 3f 00 00 00 00 00 00 80 3f 00 00 80 c0 00 00 c0 c0 00 00 c0 40 00 00 c0 40 00 00 00 00 00 00 00 80 00 0

0 c0 40 00 00 c0 40 00 00 c0 c0 00 00 80 c0 00 00 00 00 00 00 00 80

Test test_cast_FLOAT4E2M1_to_FLOAT16
Input: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='x')
Input Numpy: [[0 0 -6 -6 -1]
[-6 4 0 0 0]
[-1 -6 -2 -6 0]]

Input Bytes: 01 e2 7f 07 78 f7 0e 08

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[ 0.5  0.   1.  -4.  -6. ]

[ 6. 6. 0. -0. 6. ]
[ 6. -6. -4. 0. -0. ]]

Output Bytes: 00 38 00 00 00 3c 00 c4 00 c6 00 46 00 46 00 00 00 80 00 46 00 46 00 c6 00 c4 00 00 00 80

Test test_cast_FLOAT8E4M3FNUZ_to_FLOAT
Input: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Input Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[   0.46875    0.46875    0.5        0.8125     0.46875]

[ 0.75 240. 0. nan 240. ]
[ 240. -240. 0. 0. -240. ]]

Output Bytes: 00 00 f0 3e 00 00 f0 3e 00 00 00 3f 00 00 50 3f 00 00 f0 3e 00 00 40 3f 00 00 70 43 00 00 00 00 00 00 c0 ff 00 0

0 70 43 00 00 70 43 00 00 70 c3 00 00 00 00 00 00 00 00 00 00 70 c3

Test test_cast_FLOAT8E4M3FNUZ_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Input Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[   0.4688    0.4688    0.5       0.8125    0.4688]

[ 0.75 240. 0. nan 240. ]
[ 240. -240. 0. 0. -240. ]]

Output Bytes: 80 37 80 37 00 38 80 3a 80 37 00 3a 80 5b 00 00 00 fe 80 5b 80 5b 80 db 00 00 00 00 80 db

Test test_cast_FLOAT8E4M3FN_to_FLOAT
Input: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Input Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[   0.46875    0.46875    0.5        0.8125     0.46875]

[ 0.75 448. 0. nan 448. ]
[ 448. -448. -0. 0. -448. ]]

Output Bytes: 00 00 f0 3e 00 00 f0 3e 00 00 00 3f 00 00 50 3f 00 00 f0 3e 00 00 40 3f 00 00 e0 43 00 00 00 00 00 00 c0 7f 00 0

0 e0 43 00 00 e0 43 00 00 e0 c3 00 00 00 80 00 00 00 00 00 00 e0 c3

Test test_cast_FLOAT8E4M3FN_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Input Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Input Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[   0.4688    0.4688    0.5       0.8125    0.4688]

[ 0.75 448. 0. nan 448. ]
[ 448. -448. -0. 0. -448. ]]

Output Bytes: 80 37 80 37 00 38 80 3a 80 37 00 3a 00 5f 00 00 00 7e 00 5f 00 5f 00 df 00 80 00 00 00 df

Test test_cast_FLOAT8E5M2FNUZ_to_FLOAT
Input: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Input Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 00 00 3f 00 00 00 3f 00 00 00 3f 00 00 60 3f 00 00 00 3f 00 00 40 3f 00 00 60 47 00 00 00 00 00 00 c0 ff 00 0

0 60 47 00 00 60 47 00 00 60 c7 00 00 00 00 00 00 00 00 00 00 60 c7

Test test_cast_FLOAT8E5M2FNUZ_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Input Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 38 00 38 00 38 00 3b 00 38 00 3a 00 7b 00 00 00 fe 00 7b 00 7b 00 fb 00 00 00 00 00 fb

Test test_cast_FLOAT8E5M2_to_FLOAT
Input: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Input Bytes: 38 38 38 3b 38 3a 7b 00 7e 7b 7b fb 80 00 fb

Output: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 00 00 3f 00 00 00 3f 00 00 00 3f 00 00 60 3f 00 00 00 3f 00 00 40 3f 00 00 60 47 00 00 00 00 00 00 c0 7f 00 0

0 60 47 00 00 60 47 00 00 60 c7 00 00 00 80 00 00 00 00 00 00 60 c7

Test test_cast_FLOAT8E5M2_to_FLOAT16
Input: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Input Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Input Bytes: 38 38 38 3b 38 3a 7b 00 7e 7b 7b fb 80 00 fb

Output: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 00 38 00 38 00 38 00 3b 00 38 00 3a 00 7b 00 00 00 7e 00 7b 00 7b 00 fb 00 80 00 00 00 fb

Test test_cast_FLOAT_to_BFLOAT16
Input: TensorProtoTensor<FLOAT,[3,4]>(name='x')
Input Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.7229038 ]
[ nan inf inf -inf]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 0c 04 51 3f d1 ee 57 3e 39 10 39 3f 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff
Output: TensorProtoTensor<BFLOAT16,[3,4]>(name='x')
Output Numpy: [[0.478516 0.480469 0.5 0.820312]
[0.470703 0.816406 0.210938 0.722656]
[nan inf inf -inf]]

Output Bytes: f5 3e f6 3e 00 3f 52 3f f1 3e 51 3f 58 3e 39 3f c0 7f 80 7f 80 7f 80 ff

Test test_cast_FLOAT_to_DOUBLE
Input: TensorProtoTensor<FLOAT,[3,4]>(name='x')
Input Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.7229038 ]
[ nan inf inf -inf]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 0c 04 51 3f d1 ee 57 3e 39 10 39 3f 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff
Output: TensorProtoTensor<DOUBLE,[3,4]>(name='x')
Output Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.72290379]
[ nan inf inf -inf]]

Output Bytes: 00 00 00 00 b7 a6 de 3f 00 00 00 00 d6 bd de 3f 00 00 00 40 d6 fa df 3f 00 00 00 a0 1c 36 ea 3f 00 00 00 80 99 1

9 de 3f 00 00 00 80 81 20 ea 3f 00 00 00 20 da fd ca 3f 00 00 00 20 07 22 e7 3f 00 00 00 00 00 00 f8 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 ff

Test test_cast_FLOAT_to_FLOAT16
Input: TensorProtoTensor<FLOAT,[3,4]>(name='x')
Input Numpy: [[0.47892547 0.48033667 0.49968487 0.81910545]
[0.47031248 0.816468 0.21087195 0.7229038 ]
[ nan inf inf -inf]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 0c 04 51 3f d1 ee 57 3e 39 10 39 3f 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff
Output: TensorProtoTensor<FLOAT16,[3,4]>(name='x')
Output Numpy: [[0.479 0.4802 0.4998 0.8193]
[0.4702 0.8164 0.2108 0.723 ]
[ nan inf inf -inf]]

Output Bytes: aa 37 af 37 ff 37 8e 3a 86 37 88 3a bf 32 c9 39 00 7e 00 7c 00 7c 00 fc

Test test_cast_FLOAT_to_FLOAT4E2M1
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 4.80e-01 2.50e-01 1.05e+00 -3.50e+00 -8.00e+00]
[ 9.00e+00 1.00e+06 1.00e-07 nan inf]
[ inf -inf -4.00e+00 1.00e-02 -0.00e+00]]

Input Bytes: 8f c2 f5 3e 00 00 80 3e 66 66 86 3f 00 00 60 c0 00 00 00 c1 00 00 10 41 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 00 00 80 c0 0a d7 23 3c 00 00 00 80
Output: TensorProtoTensor<FLOAT4E2M1,[3,5]>(name='x')
Output Numpy: [[0 0 -6 -6 -1]
[-6 4 0 0 0]
[-1 -6 -2 -6 0]]

Output Bytes: 01 e2 7f 07 78 f7 0e 08

Test test_cast_FLOAT_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 448 0 nan 448]
[448 -448 -0 0 -448]]

Output Bytes: 2f 2f 30 35 2f 34 7e 00 7f 7e 7e fe 80 00 fe

Test test_cast_FLOAT_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 240 0 nan 240]
[240 -240 0 0 -240]]

Output Bytes: 37 37 38 3d 37 3c 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 -0 0 -57344]]

Output Bytes: 38 38 38 3b 38 3a 7b 00 7e 7b 7b fb 80 00 fb

Test test_cast_FLOAT_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 57344 0 nan 57344]
[57344 -57344 0 0 -57344]]

Output Bytes: 3c 3c 3c 3f 3c 3e 7f 00 80 7f 7f ff 00 00 ff

Test test_cast_FLOAT_to_INT4
Input: TensorProtoTensor<FLOAT,[5,5]>(name='x')
Input Numpy: [[-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.]]

Input Bytes: 00 00 10 c1 00 00 00 c1 00 00 e0 c0 00 00 c0 c0 00 00 a0 c0 00 00 80 c0 00 00 40 c0 00 00 00 c0 00 00 80 bf 00 00

00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 00 41 00 00 10 41 00 00 20 41 00 00 30 41 00 00 40 41 00 00 50 41 00 00 60 41 00 00 70 41
Output: TensorProtoTensor<INT4,[5,5]>(name='x')
Output Numpy: [[7 0 -7 -1 -5]
[-1 -3 -1 -1 -1]
[1 0 3 0 5]
[0 7 0 -7 -1]
[-5 -1 -3 -1 -1]]

Output Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Test test_cast_FLOAT_to_UINT4
Input: TensorProtoTensor<FLOAT,[5,5]>(name='x')
Input Numpy: [[-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.]]

Input Bytes: 00 00 10 c1 00 00 00 c1 00 00 e0 c0 00 00 c0 c0 00 00 a0 c0 00 00 80 c0 00 00 40 c0 00 00 00 c0 00 00 80 bf 00 00

00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 00 41 00 00 10 41 00 00 20 41 00 00 30 41 00 00 40 41 00 00 50 41 00 00 60 41 00 00 70 41
Output: TensorProtoTensor<UINT4,[5,5]>(name='x')
Output Numpy: [[7 0 9 0 11]
[0 13 0 15 0]
[1 0 3 0 5]
[0 7 0 9 0]
[11 0 13 0 15]]

Output Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Test test_cast_INT4_to_FLOAT
Input: TensorProtoTensor<INT4,[5,5]>(name='x')
Input Numpy: [[7 0 -7 -1 -5]
[-1 -3 -1 -1 -1]
[1 0 3 0 5]
[0 7 0 -7 -1]
[-5 -1 -3 -1 -1]]

Input Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<FLOAT,[5,5]>(name='x')
Output Numpy: [[ 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.]]

Output Bytes: 00 00 e0 40 00 00 00 c1 00 00 e0 c0 00 00 c0 c0 00 00 a0 c0 00 00 80 c0 00 00 40 c0 00 00 00 c0 00 00 80 bf 00 0

0 00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 00 c1 00 00 e0 c0 00 00 c0 c0 00 00 a0 c0 00 00 80 c0 00 00 40 c0 00 00 00 c0 00 00 80 bf

Test test_cast_INT4_to_FLOAT16
Input: TensorProtoTensor<INT4,[5,5]>(name='x')
Input Numpy: [[7 0 -7 -1 -5]
[-1 -3 -1 -1 -1]
[1 0 3 0 5]
[0 7 0 -7 -1]
[-5 -1 -3 -1 -1]]

Input Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<FLOAT16,[5,5]>(name='x')
Output Numpy: [[ 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.]]

Output Bytes: 00 47 00 c8 00 c7 00 c6 00 c5 00 c4 00 c2 00 c0 00 bc 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 c8 00 c

7 00 c6 00 c5 00 c4 00 c2 00 c0 00 bc

Test test_cast_INT4_to_INT8
Input: TensorProtoTensor<INT4,[5,5]>(name='x')
Input Numpy: [[7 0 -7 -1 -5]
[-1 -3 -1 -1 -1]
[1 0 3 0 5]
[0 7 0 -7 -1]
[-5 -1 -3 -1 -1]]

Input Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<INT8,[5,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 07 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 f8 f9 fa fb fc fd fe ff

Test test_cast_UINT4_to_FLOAT
Input: TensorProtoTensor<UINT4,[5,5]>(name='x')
Input Numpy: [[7 0 9 0 11]
[0 13 0 15 0]
[1 0 3 0 5]
[0 7 0 9 0]
[11 0 13 0 15]]

Input Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<FLOAT,[5,5]>(name='x')
Output Numpy: [[ 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.]]

Output Bytes: 00 00 e0 40 00 00 00 41 00 00 10 41 00 00 20 41 00 00 30 41 00 00 40 41 00 00 50 41 00 00 60 41 00 00 70 41 00 0

0 00 00 00 00 80 3f 00 00 00 40 00 00 40 40 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 00 00 00 41 00 00 10 41 00 00 20 41 00 00 30 41 00 00 40 41 00 00 50 41 00 00 60 41 00 00 70 41

Test test_cast_UINT4_to_FLOAT16
Input: TensorProtoTensor<UINT4,[5,5]>(name='x')
Input Numpy: [[7 0 9 0 11]
[0 13 0 15 0]
[1 0 3 0 5]
[0 7 0 9 0]
[11 0 13 0 15]]

Input Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<FLOAT16,[5,5]>(name='x')
Output Numpy: [[ 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.]]

Output Bytes: 00 47 00 48 80 48 00 49 80 49 00 4a 80 4a 00 4b 80 4b 00 00 00 3c 00 40 00 42 00 44 00 45 00 46 00 47 00 48 80 4

8 00 49 80 49 00 4a 80 4a 00 4b 80 4b

Test test_cast_UINT4_to_UINT8
Input: TensorProtoTensor<UINT4,[5,5]>(name='x')
Input Numpy: [[7 0 9 0 11]
[0 13 0 15 0]
[1 0 3 0 5]
[0 7 0 9 0]
[11 0 13 0 15]]

Input Bytes: 87 a9 cb ed 0f 21 43 65 87 a9 cb ed 0f

Output: TensorProtoTensor<UINT8,[5,5]>(name='x')
Output Numpy: [[ 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]]

Output Bytes: 07 08 09 0a 0b 0c 0d 0e 0f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 nan 0 nan nan]
[nan nan -0 0 nan]]

Output Bytes: 2f 2f 30 35 2f 34 7f 00 7f 7f 7f ff 80 00 ff

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]

[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 37 37 38 3d 37 3c 80 00 80 80 80 80 00 00 80

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 inf 0 nan inf]
[inf -inf -0 0 -inf]]

Output Bytes: 38 38 38 3b 38 3a 7c 00 7e 7c 7c fc 80 00 fc

Test test_cast_no_saturate_FLOAT16_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT16,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: aa 37 af 37 ff 37 8e 3a 86 37 c9 39 00 7c 02 00 00 7e 00 7c 00 7c 00 fc 02 80 02 00 00 fc

Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]

[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 3c 3c 3c 3f 3c 3e 80 00 80 80 80 80 00 00 80

Test test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FN
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FN,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 nan 0 nan nan]
[nan nan -0 0 nan]]

Output Bytes: 2f 2f 30 35 2f 34 7f 00 7f 7f 7f ff 80 00 ff

Test test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E4M3FNUZ,[3,5]>(name='x')
Output Numpy: [[0.46875 0.46875 0.5 0.8125 0.46875]
[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 37 37 38 3d 37 3c 80 00 80 80 80 80 00 00 80

Test test_cast_no_saturate_FLOAT_to_FLOAT8E5M2
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 inf 0 nan inf]
[inf -inf -0 0 -inf]]

Output Bytes: 38 38 38 3b 38 3a 7c 00 7e 7c 7c fc 80 00 fc

Test test_cast_no_saturate_FLOAT_to_FLOAT8E5M2FNUZ
Input: TensorProtoTensor<FLOAT,[3,5]>(name='x')
Input Numpy: [[ 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]]

Input Bytes: b8 35 f5 3e b0 ee f5 3e b2 d6 ff 3e e5 b0 51 3f cc cc f0 3e 39 10 39 3f 00 24 74 49 95 bf d6 33 00 00 c0 7f 00 00

80 7f 00 00 80 7f 00 00 80 ff 95 bf d6 b3 95 bf d6 33 00 24 74 c9
Output: TensorProtoTensor<FLOAT8E5M2FNUZ,[3,5]>(name='x')
Output Numpy: [[0.5 0.5 0.5 0.875 0.5]
[0.75 nan 0 nan nan]
[nan nan 0 0 nan]]

Output Bytes: 3c 3c 3c 3f 3c 3e 80 00 80 80 80 80 00 00 80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment