Skip to content

Commit

Permalink
Fix input names for quantize/dequantize ONNX backend tests (#6122)
Browse files Browse the repository at this point in the history
### Description
#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>
(cherry picked from commit 3bddb4d)
  • Loading branch information
adrianlizarraga authored and cjvolzka committed May 3, 2024
1 parent 1fc5eb8 commit e310ba8
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 @@ -7681,7 +7681,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 @@ -7735,7 +7735,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 @@ -20495,7 +20495,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 @@ -20521,7 +20521,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 @@ -20620,7 +20620,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 @@ -20740,7 +20740,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 @@ -5451,7 +5451,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 @@ -5501,7 +5501,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 @@ -13957,7 +13957,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 @@ -13981,7 +13981,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 @@ -14076,7 +14076,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 @@ -14190,7 +14190,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 @@ -202,7 +202,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 @@ -224,7 +224,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 @@ -73,7 +73,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 @@ -93,7 +93,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 @@ -230,7 +230,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 @@ -262,7 +262,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 e310ba8

Please sign in to comment.