From c26fffd88c2b6a0f304e28274ac4a85b96a65933 Mon Sep 17 00:00:00 2001 From: isdanni Date: Sun, 5 May 2024 20:18:01 -0500 Subject: [PATCH] Specify axis parameter for DequantizeLinear when input rank is 1 Signed-off-by: isdanni --- docs/Changelog.md | 4 ++-- docs/Operators.md | 2 +- onnx/defs/quantization/defs.cc | 5 +++-- onnx/defs/quantization/old.cc | 5 ++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 8107fbfd86c..6668268839f 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -22955,7 +22955,7 @@ This version of the operator has been available since version 19 of the default
axis : int (default is 1)
-
(Optional) The axis of the dequantizing dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).
+
(Optional) The axis of the dequantizing dimension of the input tensor. Used only for per-axis and blocked quantization. Negative value means counting dimensions from the back. Accepted range is `[-r, r-1]` where `r = rank(input)`. When the rank of the input is 1, per-tensor quantization is applied, rendering the axis unnecessary in this scenario.
#### Inputs (2 - 3) @@ -24785,7 +24785,7 @@ This version of the operator has been available since version 21 of the default
axis : int (default is 1)
-
(Optional) The axis of the dequantizing dimension of the input tensor. Used for per-axis and blocked quantization. Negative value means counting dimensions from the back. Accepted range is `[-r, r-1]` where `r = rank(input)`.
+
(Optional) The axis of the dequantizing dimension of the input tensor. Used only for per-axis and blocked quantization. Negative value means counting dimensions from the back. Accepted range is `[-r, r-1]` where `r = rank(input)`. When the rank of the input is 1, per-tensor quantization is applied, rendering the axis unnecessary in this scenario.
block_size : int (default is 0)
(Optional) The size of the quantization block (number of times every scale is replicated). Used only for blocked quantization. The block size is a positive integer. Given `x` shape `(D0, ..., Di, ..., Dn)`, `y_scale` shape `(S0, ... Si, ...Sn)` and `axis=i`, the accepted range is `[ceil(Di/Si), ceil(Di/(Si-1))-1]`
diff --git a/docs/Operators.md b/docs/Operators.md index dab7130c381..246853b82dc 100644 --- a/docs/Operators.md +++ b/docs/Operators.md @@ -7374,7 +7374,7 @@ Other versions of this operator: 10
axis : int (default is 1)
-
(Optional) The axis of the dequantizing dimension of the input tensor. Used for per-axis and blocked quantization. Negative value means counting dimensions from the back. Accepted range is `[-r, r-1]` where `r = rank(input)`.
+
(Optional) The axis of the dequantizing dimension of the input tensor. Used only for per-axis and blocked quantization. Negative value means counting dimensions from the back. Accepted range is `[-r, r-1]` where `r = rank(input)`. When the rank of the input is 1, per-tensor quantization is applied, rendering the axis unnecessary in this scenario.
block_size : int (default is 0)
(Optional) The size of the quantization block (number of times every scale is replicated). Used only for blocked quantization. The block size is a positive integer. Given `x` shape `(D0, ..., Di, ..., Dn)`, `y_scale` shape `(S0, ... Si, ...Sn)` and `axis=i`, the accepted range is `[ceil(Di/Si), ceil(Di/(Si-1))-1]`
diff --git a/onnx/defs/quantization/defs.cc b/onnx/defs/quantization/defs.cc index 98c1154532d..a68e076b3dd 100644 --- a/onnx/defs/quantization/defs.cc +++ b/onnx/defs/quantization/defs.cc @@ -57,9 +57,10 @@ ONNX_OPERATOR_SET_SCHEMA( .Output(0, "y", "N-D quantized output tensor. It has same shape as input `x`.", "T2") .Attr( "axis", - "(Optional) The axis of the dequantizing dimension of the input tensor. Used for per-axis and blocked " + "(Optional) The axis of the dequantizing dimension of the input tensor. Used only for per-axis and blocked " "quantization. Negative value means counting dimensions from the back. Accepted range is `[-r, r-1]` " - "where `r = rank(input)`.", + "where `r = rank(input)`. When the rank of the input is 1, per-tensor quantization is applied, " + "rendering the axis unnecessary in this scenario.", AttributeProto::INT, static_cast(1)) .Attr( diff --git a/onnx/defs/quantization/old.cc b/onnx/defs/quantization/old.cc index d2f7cfd8d4a..12be8ad03cb 100644 --- a/onnx/defs/quantization/old.cc +++ b/onnx/defs/quantization/old.cc @@ -110,7 +110,10 @@ ONNX_OPERATOR_SET_SCHEMA( .Output(0, "y", "N-D full precision output tensor. It has same shape as input 'x'.", "T2") .Attr( "axis", - "(Optional) The axis of the dequantizing dimension of the input tensor. Ignored for per-tensor quantization. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input).", + "(Optional) The axis of the dequantizing dimension of the input tensor. Used only for per-axis quantization. " + "Negative value means counting dimensions from the back. Accepted range is `[-r, r-1]` " + "where `r = rank(input)`. When the rank of the input is 1, per-tensor quantization is applied, " + "rendering the axis unnecessary in this scenario.", AttributeProto::INT, static_cast(1)) .TypeConstraint(