Skip to content

Commit

Permalink
Fix input names for quantize/dequantize ONNX backend tests (onnx#6122)
Browse files Browse the repository at this point in the history
### Description
onnx#6123
The input pb files for the following ONNX backend node tests have
incorrect names that do not match the ONNX model:
- test_dequantizelinear_uint4
- test_dequantizelinear_int4
- test_quantizelinear_e4m3fn
- test_quantizelinear_e5m2
- test_quantizelinear_uint4
- test_quantizelinear_int4

### Motivation and Context
The mismatch in input names causes issues when running these backend
tests via ONNX Runtime.

---------

Signed-off-by: adrianlizarraga <adlizarraga@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
  • Loading branch information
adrianlizarraga authored and gramalingam committed Jun 6, 2024
1 parent 5f2894d commit 24d38e3
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 26 deletions.
12 changes: 6 additions & 6 deletions docs/Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -7700,7 +7700,7 @@ node = onnx.helper.make_node(
# scalar zero point and scale
x = make_tensor("x", TensorProto.INT4, [5], [0, 1, 7, -4, -8])
x_scale = np.float32(2)
x_zero_point = make_tensor("zero_point", TensorProto.INT4, (1,), [1])
x_zero_point = make_tensor("x_zero_point", TensorProto.INT4, (1,), [1])
y = np.array([-2, 0, 12, -10, -18], dtype=np.float32)

expect(
Expand Down Expand Up @@ -7754,7 +7754,7 @@ node = onnx.helper.make_node(
# scalar zero point and scale
x = make_tensor("x", TensorProto.UINT4, [5], [0, 1, 7, 10, 15])
x_scale = np.float32(2)
x_zero_point = make_tensor("zero_point", TensorProto.UINT4, (1,), [1])
x_zero_point = make_tensor("x_zero_point", TensorProto.UINT4, (1,), [1])
y = np.array([-2, 0, 12, 18, 28], dtype=np.float32)

expect(
Expand Down Expand Up @@ -20532,7 +20532,7 @@ node = onnx.helper.make_node(

x = np.array([0.0, 1.0, 2.0, 100000.0, 200.0]).astype(np.float32)
y_scale = np.float32(2)
y_zero_point = make_tensor("zero_point", TensorProto.FLOAT8E4M3FN, [1], [0])
y_zero_point = make_tensor("y_zero_point", TensorProto.FLOAT8E4M3FN, [1], [0])
y = make_tensor("y", TensorProto.FLOAT8E4M3FN, [5], [0, 0.5, 1, 448, 96])

expect(
Expand All @@ -20558,7 +20558,7 @@ node = onnx.helper.make_node(

x = np.array([0.0, 1.0, 2.0, 100000.0, 200.0]).astype(np.float32)
y_scale = np.float32(2)
y_zero_point = make_tensor("zero_point", TensorProto.FLOAT8E5M2, [1], [0.0])
y_zero_point = make_tensor("y_zero_point", TensorProto.FLOAT8E5M2, [1], [0.0])
y = make_tensor("y", TensorProto.FLOAT8E5M2, [5], [0, 0.5, 1, 49152, 96])

expect(
Expand Down Expand Up @@ -20657,7 +20657,7 @@ x = np.array(

y_scale = np.asarray([2.0, 3.0, 4.0], dtype=np.float32)
y_zero_point = make_tensor(
"zero_point", TensorProto.INT4, y_scale.shape, np.ones_like(y_scale)
"y_zero_point", TensorProto.INT4, y_scale.shape, np.ones_like(y_scale)
)
y = make_tensor(
"y", TensorProto.INT4, x.shape, [1, 2, 3, 5, -8, -6, 3, 4, 4, 5, 5, 7]
Expand Down Expand Up @@ -20777,7 +20777,7 @@ x = np.array(

y_scale = np.asarray([2.0, 3.0, 4.0], dtype=np.float32)
y_zero_point = make_tensor(
"zero_point", TensorProto.UINT4, y_scale.shape, np.ones_like(y_scale)
"y_zero_point", TensorProto.UINT4, y_scale.shape, np.ones_like(y_scale)
)
y = make_tensor(
"y", TensorProto.UINT4, x.shape, [1, 2, 3, 5, -1, -1, 3, 4, 4, 5, 5, 11]
Expand Down
12 changes: 6 additions & 6 deletions docs/TestCoverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5449,7 +5449,7 @@ node = onnx.helper.make_node(
# scalar zero point and scale
x = make_tensor("x", TensorProto.INT4, [5], [0, 1, 7, -4, -8])
x_scale = np.float32(2)
x_zero_point = make_tensor("zero_point", TensorProto.INT4, (1,), [1])
x_zero_point = make_tensor("x_zero_point", TensorProto.INT4, (1,), [1])
y = np.array([-2, 0, 12, -10, -18], dtype=np.float32)

expect(
Expand Down Expand Up @@ -5499,7 +5499,7 @@ node = onnx.helper.make_node(
# scalar zero point and scale
x = make_tensor("x", TensorProto.UINT4, [5], [0, 1, 7, 10, 15])
x_scale = np.float32(2)
x_zero_point = make_tensor("zero_point", TensorProto.UINT4, (1,), [1])
x_zero_point = make_tensor("x_zero_point", TensorProto.UINT4, (1,), [1])
y = np.array([-2, 0, 12, 18, 28], dtype=np.float32)

expect(
Expand Down Expand Up @@ -13955,7 +13955,7 @@ node = onnx.helper.make_node(

x = np.array([0.0, 1.0, 2.0, 100000.0, 200.0]).astype(np.float32)
y_scale = np.float32(2)
y_zero_point = make_tensor("zero_point", TensorProto.FLOAT8E4M3FN, [1], [0])
y_zero_point = make_tensor("y_zero_point", TensorProto.FLOAT8E4M3FN, [1], [0])
y = make_tensor("y", TensorProto.FLOAT8E4M3FN, [5], [0, 0.5, 1, 448, 96])

expect(
Expand All @@ -13979,7 +13979,7 @@ node = onnx.helper.make_node(

x = np.array([0.0, 1.0, 2.0, 100000.0, 200.0]).astype(np.float32)
y_scale = np.float32(2)
y_zero_point = make_tensor("zero_point", TensorProto.FLOAT8E5M2, [1], [0.0])
y_zero_point = make_tensor("y_zero_point", TensorProto.FLOAT8E5M2, [1], [0.0])
y = make_tensor("y", TensorProto.FLOAT8E5M2, [5], [0, 0.5, 1, 49152, 96])

expect(
Expand Down Expand Up @@ -14074,7 +14074,7 @@ x = np.array(

y_scale = np.asarray([2.0, 3.0, 4.0], dtype=np.float32)
y_zero_point = make_tensor(
"zero_point", TensorProto.INT4, y_scale.shape, np.ones_like(y_scale)
"y_zero_point", TensorProto.INT4, y_scale.shape, np.ones_like(y_scale)
)
y = make_tensor(
"y", TensorProto.INT4, x.shape, [1, 2, 3, 5, -8, -6, 3, 4, 4, 5, 5, 7]
Expand Down Expand Up @@ -14188,7 +14188,7 @@ x = np.array(

y_scale = np.asarray([2.0, 3.0, 4.0], dtype=np.float32)
y_zero_point = make_tensor(
"zero_point", TensorProto.UINT4, y_scale.shape, np.ones_like(y_scale)
"y_zero_point", TensorProto.UINT4, y_scale.shape, np.ones_like(y_scale)
)
y = make_tensor(
"y", TensorProto.UINT4, x.shape, [1, 2, 3, 5, -1, -1, 3, 4, 4, 5, 5, 11]
Expand Down
4 changes: 2 additions & 2 deletions onnx/backend/test/case/node/dequantizelinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def export_uint4() -> None:
# scalar zero point and scale
x = make_tensor("x", TensorProto.UINT4, [5], [0, 1, 7, 10, 15])
x_scale = np.float32(2)
x_zero_point = make_tensor("zero_point", TensorProto.UINT4, (1,), [1])
x_zero_point = make_tensor("x_zero_point", TensorProto.UINT4, (1,), [1])
y = np.array([-2, 0, 12, 18, 28], dtype=np.float32)

expect(
Expand All @@ -225,7 +225,7 @@ def export_int4() -> None:
# scalar zero point and scale
x = make_tensor("x", TensorProto.INT4, [5], [0, 1, 7, -4, -8])
x_scale = np.float32(2)
x_zero_point = make_tensor("zero_point", TensorProto.INT4, (1,), [1])
x_zero_point = make_tensor("x_zero_point", TensorProto.INT4, (1,), [1])
y = np.array([-2, 0, 12, -10, -18], dtype=np.float32)

expect(
Expand Down
8 changes: 4 additions & 4 deletions onnx/backend/test/case/node/quantizelinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def export_e4m3fn() -> None:

x = np.array([0.0, 1.0, 2.0, 100000.0, 200.0]).astype(np.float32)
y_scale = np.float32(2)
y_zero_point = make_tensor("zero_point", TensorProto.FLOAT8E4M3FN, [1], [0])
y_zero_point = make_tensor("y_zero_point", TensorProto.FLOAT8E4M3FN, [1], [0])
y = make_tensor("y", TensorProto.FLOAT8E4M3FN, [5], [0, 0.5, 1, 448, 96])

expect(
Expand All @@ -94,7 +94,7 @@ def export_e5m2() -> None:

x = np.array([0.0, 1.0, 2.0, 100000.0, 200.0]).astype(np.float32)
y_scale = np.float32(2)
y_zero_point = make_tensor("zero_point", TensorProto.FLOAT8E5M2, [1], [0.0])
y_zero_point = make_tensor("y_zero_point", TensorProto.FLOAT8E5M2, [1], [0.0])
y = make_tensor("y", TensorProto.FLOAT8E5M2, [5], [0, 0.5, 1, 49152, 96])

expect(
Expand Down Expand Up @@ -231,7 +231,7 @@ def export_uint4() -> None:

y_scale = np.asarray([2.0, 3.0, 4.0], dtype=np.float32)
y_zero_point = make_tensor(
"zero_point", TensorProto.UINT4, y_scale.shape, np.ones_like(y_scale)
"y_zero_point", TensorProto.UINT4, y_scale.shape, np.ones_like(y_scale)
)
y = make_tensor(
"y", TensorProto.UINT4, x.shape, [1, 2, 3, 5, -1, -1, 3, 4, 4, 5, 5, 11]
Expand Down Expand Up @@ -263,7 +263,7 @@ def export_int4() -> None:

y_scale = np.asarray([2.0, 3.0, 4.0], dtype=np.float32)
y_zero_point = make_tensor(
"zero_point", TensorProto.INT4, y_scale.shape, np.ones_like(y_scale)
"y_zero_point", TensorProto.INT4, y_scale.shape, np.ones_like(y_scale)
)
y = make_tensor(
"y", TensorProto.INT4, x.shape, [1, 2, 3, 5, -8, -6, 3, 4, 4, 5, 5, 7]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*B
zero_point
*B x_zero_point
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*B
zero_point
*B x_zero_point
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*B
zero_point
*B y_zero_point
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*B
zero_point
*B y_zero_point

0 comments on commit 24d38e3

Please sign in to comment.