Skip to content

Commit

Permalink
Specify axis parameter for DequantizeLinear when input rank is 1 (#6095)
Browse files Browse the repository at this point in the history
### Description

Close #6067

Signed-off-by: isdanni <leedanni@gmail.com>
  • Loading branch information
isdanni committed May 6, 2024
1 parent aa2cdac commit 09dc4ab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/Changelog.md
Expand Up @@ -22955,7 +22955,7 @@ This version of the operator has been available since version 19 of the default

<dl>
<dt><tt>axis</tt> : int (default is 1)</dt>
<dd>(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).</dd>
<dd>(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.</dd>
</dl>

#### Inputs (2 - 3)
Expand Down Expand Up @@ -25406,7 +25406,7 @@ This version of the operator has been available since version 21 of the default

<dl>
<dt><tt>axis</tt> : int (default is 1)</dt>
<dd>(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)`.</dd>
<dd>(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.</dd>
<dt><tt>block_size</tt> : int (default is 0)</dt>
<dd>(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]`</dd>
<dt><tt>output_dtype</tt> : int (default is 0)</dt>
Expand Down
2 changes: 1 addition & 1 deletion docs/Operators.md
Expand Up @@ -20309,7 +20309,7 @@ Other versions of this operator: <a href="Changelog.md#QuantizeLinear-10">10</a>

<dl>
<dt><tt>axis</tt> : int (default is 1)</dt>
<dd>(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)`.</dd>
<dd>(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.</dd>
<dt><tt>block_size</tt> : int (default is 0)</dt>
<dd>(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]`</dd>
<dt><tt>output_dtype</tt> : int (default is 0)</dt>
Expand Down
5 changes: 3 additions & 2 deletions onnx/defs/quantization/defs.cc
Expand Up @@ -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<int64_t>(1))
.Attr(
Expand Down
5 changes: 4 additions & 1 deletion onnx/defs/quantization/old.cc
Expand Up @@ -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<int64_t>(1))
.TypeConstraint(
Expand Down

0 comments on commit 09dc4ab

Please sign in to comment.