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<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