Skip to content

Commit

Permalink
Make release 1.12.0 candidate rc4 for testing (#4267)
Browse files Browse the repository at this point in the history
* Use op name rather than hard-coding Hann in window op doc strings. (#4248)

And strip trailing spaces.

Signed-off-by: Gary Miguel <garymiguel@microsoft.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* Fix: Window functions generate incorrect shape for with symmetric attribute (#4256)

* fix symmetric function definition, and add shape inference test

Signed-off-by: Sheil Kumar <smk2007@gmail.com>

* whitespace...

Signed-off-by: Sheil Kumar <smk2007@gmail.com>

* whitespace...

Signed-off-by: Sheil Kumar <smk2007@gmail.com>

* flake8 whitespace error

Signed-off-by: Sheil Kumar <smk2007@gmail.com>

* fix stft test

Signed-off-by: Sheil Kumar <smk2007@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* support truncation & fix big-endian support (#4238)

Signed-off-by: Ian Bearman <ianb@microsoft.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* Fix layer normalization's reference outputs (#4263)

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* handle raw types correctly in helper.make_tensor (#4262)

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* bump to 1.12.0rc4 for cherry-picks

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* Fix sub-graph generation for LN (#4268)

Signed-off-by: Wei-Sheng Chin <wschin@outlook.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

Co-authored-by: Gary Miguel <garymiguel@microsoft.com>
Co-authored-by: Sheil Kumar <smk2007@gmail.com>
Co-authored-by: Ian Bearman <ianb@microsoft.com>
Co-authored-by: Wei-Sheng Chin <wschin@outlook.com>
  • Loading branch information
5 people committed Jun 10, 2022
1 parent 19944f1 commit b2845aa
Show file tree
Hide file tree
Showing 46 changed files with 144 additions and 90 deletions.
2 changes: 1 addition & 1 deletion VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0rc3
1.12.0rc4
4 changes: 2 additions & 2 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20845,7 +20845,7 @@ This version of the operator has been available since version 17 of the default

<dl>
<dt><tt>output</tt> (non-differentiable) : T2</dt>
<dd>A Hann window with length: size. The output has the shape: [size].</dd>
<dd>A Blackman window with length: size. The output has the shape: [size].</dd>
</dl>

#### Type Constraints
Expand Down Expand Up @@ -20929,7 +20929,7 @@ This version of the operator has been available since version 17 of the default

<dl>
<dt><tt>output</tt> (non-differentiable) : T2</dt>
<dd>A Hann window with length: size. The output has the shape: [size].</dd>
<dd>A Hamming window with length: size. The output has the shape: [size].</dd>
</dl>

#### Type Constraints
Expand Down
15 changes: 8 additions & 7 deletions docs/Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,7 @@ This version of the operator has been available since version 17 of the default

<dl>
<dt><tt>output</tt> (non-differentiable) : T2</dt>
<dd>A Hann window with length: size. The output has the shape: [size].</dd>
<dd>A Blackman window with length: size. The output has the shape: [size].</dd>
</dl>

#### Type Constraints
Expand Down Expand Up @@ -8232,7 +8232,7 @@ This version of the operator has been available since version 17 of the default

<dl>
<dt><tt>output</tt> (non-differentiable) : T2</dt>
<dd>A Hann window with length: size. The output has the shape: [size].</dd>
<dd>A Hamming window with length: size. The output has the shape: [size].</dd>
</dl>

#### Type Constraints
Expand Down Expand Up @@ -9796,19 +9796,20 @@ for i in range(len(X.shape)):
<summary>d_epsilon</summary>

```python
epsilon = 1e-1
X = np.random.randn(2, 3, 5).astype(np.float32)

def case(axis: int) -> None:
normalized_shape = calculate_normalized_shape(X.shape, axis)
W = np.random.randn(*normalized_shape).astype(np.float32)
B = np.random.randn(*normalized_shape).astype(np.float32)
Y, mean, inv_std_dev = _layer_normalization(X, W, B, axis)
Y, mean, inv_std_dev = _layer_normalization(X, W, B, axis, epsilon)
node = onnx.helper.make_node(
'LayerNormalization',
inputs=['X', 'W', 'B'],
outputs=['Y', 'Mean', 'InvStdDev'],
axis=axis,
epsilon=1e-1
epsilon=epsilon
)

if axis < 0:
Expand Down Expand Up @@ -9848,7 +9849,7 @@ node = onnx.helper.make_node(
)

expect(node, inputs=[X, W, B], outputs=[Y, mean, inv_std_dev],
name='test_layer_normalization_default_axis')
name='test_layer_normalization_default_axis')
```

</details>
Expand Down Expand Up @@ -19263,8 +19264,8 @@ nstfts = ((signal.shape[1] - length) // step) + 1
output = np.empty([1, nstfts, onesided_length, 2], dtype=np.float32)
for i in range(nstfts):
start = i * step
stop = i * step + onesided_length
complex_out = np.fft.fft(signal[0, start:stop, 0])
stop = i * step + length
complex_out = np.fft.fft(signal[0, start:stop, 0])[0:onesided_length]
output[0, i] = np.stack((complex_out.real, complex_out.imag), axis=1)

expect(node, inputs=[signal, step, length], outputs=[output],
Expand Down
11 changes: 6 additions & 5 deletions docs/TestCoverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6017,19 +6017,20 @@ for i in range(len(X.shape)):
<summary>d_epsilon</summary>

```python
epsilon = 1e-1
X = np.random.randn(2, 3, 5).astype(np.float32)

def case(axis: int) -> None:
normalized_shape = calculate_normalized_shape(X.shape, axis)
W = np.random.randn(*normalized_shape).astype(np.float32)
B = np.random.randn(*normalized_shape).astype(np.float32)
Y, mean, inv_std_dev = _layer_normalization(X, W, B, axis)
Y, mean, inv_std_dev = _layer_normalization(X, W, B, axis, epsilon)
node = onnx.helper.make_node(
'LayerNormalization',
inputs=['X', 'W', 'B'],
outputs=['Y', 'Mean', 'InvStdDev'],
axis=axis,
epsilon=1e-1
epsilon=epsilon
)

if axis < 0:
Expand Down Expand Up @@ -6067,7 +6068,7 @@ node = onnx.helper.make_node(
)

expect(node, inputs=[X, W, B], outputs=[Y, mean, inv_std_dev],
name='test_layer_normalization_default_axis')
name='test_layer_normalization_default_axis')
```

</details>
Expand Down Expand Up @@ -12138,8 +12139,8 @@ nstfts = ((signal.shape[1] - length) // step) + 1
output = np.empty([1, nstfts, onesided_length, 2], dtype=np.float32)
for i in range(nstfts):
start = i * step
stop = i * step + onesided_length
complex_out = np.fft.fft(signal[0, start:stop, 0])
stop = i * step + length
complex_out = np.fft.fft(signal[0, start:stop, 0])[0:onesided_length]
output[0, i] = np.stack((complex_out.real, complex_out.imag), axis=1)

expect(node, inputs=[signal, step, length], outputs=[output],
Expand Down
9 changes: 5 additions & 4 deletions onnx/backend/test/case/node/layernormalization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore

import onnx

from ..base import Base
from . import expect

Expand Down Expand Up @@ -112,7 +112,7 @@ def export_default_axis() -> None:
)

expect(node, inputs=[X, W, B], outputs=[Y, mean, inv_std_dev],
name='test_layer_normalization_default_axis')
name='test_layer_normalization_default_axis')

@staticmethod
def export2d() -> None:
Expand Down Expand Up @@ -145,19 +145,20 @@ def case(axis: int) -> None:

@staticmethod
def export3d_epsilon() -> None:
epsilon = 1e-1
X = np.random.randn(2, 3, 5).astype(np.float32)

def case(axis: int) -> None:
normalized_shape = calculate_normalized_shape(X.shape, axis)
W = np.random.randn(*normalized_shape).astype(np.float32)
B = np.random.randn(*normalized_shape).astype(np.float32)
Y, mean, inv_std_dev = _layer_normalization(X, W, B, axis)
Y, mean, inv_std_dev = _layer_normalization(X, W, B, axis, epsilon)
node = onnx.helper.make_node(
'LayerNormalization',
inputs=['X', 'W', 'B'],
outputs=['Y', 'Mean', 'InvStdDev'],
axis=axis,
epsilon=1e-1
epsilon=epsilon
)

if axis < 0:
Expand Down
4 changes: 2 additions & 2 deletions onnx/backend/test/case/node/stft.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def export() -> None:
output = np.empty([1, nstfts, onesided_length, 2], dtype=np.float32)
for i in range(nstfts):
start = i * step
stop = i * step + onesided_length
complex_out = np.fft.fft(signal[0, start:stop, 0])
stop = i * step + length
complex_out = np.fft.fft(signal[0, start:stop, 0])[0:onesided_length]
output[0, i] = np.stack((complex_out.real, complex_out.imag), axis=1)

expect(node, inputs=[signal, step, length], outputs=[output],
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified onnx/backend/test/data/node/test_hannwindow_expanded/model.onnx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJX�l?
B InvStdDevJp!c?
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJX�l?
B InvStdDevJp!c?
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BYJx��A? �ʿ����-���F7>��@�+?w;�?f��>�c�MT�?�1t?�*�����>==V?l N?$k���:�?�o�>)�@$N<?pQ�>�|h>b��l�?���J�|�n����ܟ
BYJxF?C?��ſĢ���t�[I@>4x @l�%?�u�?N��>�Vf� k{?ӀW?������@{�>�LV?>{??�g��䉎?|�>w�@4�8?���>�&L>��߿�?�?8����fz�� ����
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ6�?5P?
B InvStdDevJ�>�?K�I?
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BYJx��A? �ʿ����-���F7>��@�+?w;�?f��>�c�MT�?�1t?�*�����>==V?l N?$k���:�?�o�>)�@$N<?pQ�>�|h>b��l�?���J�|�n����ܟ
BYJxF?C?��ſĢ���t�[I@>4x @l�%?�u�?N��>�Vf� k{?ӀW?������@{�>�LV?>{??�g��䉎?|�>w�@4�8?���>�&L>��߿�?�?8����fz�� ����
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ6�?5P?
B InvStdDevJ�>�?K�I?
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ��?���?��@ ҥ?�?�d?
B InvStdDevJ�t�?X�?���?�q�?�?\?
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ��?���?��@ ҥ?�?�d?
B InvStdDevJ�t�?X�?���?�q�?�?\?
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ��?���?��@ ҥ?�?�d?
B InvStdDevJ�t�?X�?���?�q�?�?\?
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ��?���?��@ ҥ?�?�d?
B InvStdDevJ�t�?X�?���?�q�?�?\?
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
BYJxc�����? �?���G�@"�2@J����??� >ءH��#`>��=�~)�?L'�ktW�EA-��w�?Vl�?�M?�M@d�%�*_�?�O�?�NO@K�=��k���9�8�|�l��>
BYJx�a�3�?�f?��ֿ�
@3&@�����?<�?�&*>m<V��AP>c�=�mÁ?qJu�c3V�k�!����?�A�?LkQ?͚F@v�"��A�?��?�J@��=�jg��9���r����>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ6�?5P?
B InvStdDevJ�>�?K�I?
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
BYJxc�����? �?���G�@"�2@J����??� >ءH��#`>��=�~)�?L'�ktW�EA-��w�?Vl�?�M?�M@d�%�*_�?�O�?�NO@K�=��k���9�8�|�l��>
BYJx�a�3�?�f?��ֿ�
@3&@�����?<�?�&*>m<V��AP>c�=�mÁ?qJu�c3V�k�!����?�A�?LkQ?͚F@v�"��A�?��?�J@��=�jg��9���r����>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJ6�?5P?
B InvStdDevJ�>�?K�I?
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BYJx�y��/撿��>��<@z�f�@���,GܾLL^?6�?�{�>� ���8��$��P��[#����>��2>+u>G)>��7��6���?��,�܅����?��쾰X�����?F~2�ׯ�>
BYJx��Ľ�����e�>ԙ8@`�y����aܾbh?�]?ں�>t����+�9���Fz�| #����>�eC>o�b>��2>��2�D���l�?;0�vį�tp�?�о�����?��8����>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJX�l?
B InvStdDevJp!c?
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BYJx�y��/撿��>��<@z�f�@���,GܾLL^?6�?�{�>� ���8��$��P��[#����>��2>+u>G)>��7��6���?��,�܅����?��쾰X�����?F~2�ׯ�>
BYJx��Ľ�����e�>ԙ8@`�y����aܾbh?�]?ں�>t����+�9���Fz�| #����>�eC>o�b>��2>��2�D���l�?;0�vį�tp�?�о�����?��8����>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
B InvStdDevJX�l?
B InvStdDevJp!c?
Binary file not shown.
Binary file not shown.
39 changes: 16 additions & 23 deletions onnx/defs/math/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ ONNX_OPERATOR_SET_SCHEMA(
.TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)
.FunctionBody(R"ONNX(
{
HS_X = HardSigmoid<alpha = 0.16666667163372, beta = 0.5>(X)
HS_X = HardSigmoid<alpha = 0.16666667163372, beta = 0.5>(X)
Y = Mul (X, HS_X)
}
)ONNX"));
Expand Down Expand Up @@ -1708,14 +1708,14 @@ ONNX_OPERATOR_SET_SCHEMA(

static const char* QLinearMatMul_ver10_doc = R"DOC(
Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html.
It consumes two quantized input tensors, their scales and zero points, scale and zero point of output,
and computes the quantized output. The quantization formula is y = saturate((x / y_scale) + y_zero_point).
For (x / y_scale), it is rounding to nearest ties to even. Refer to https://en.wikipedia.org/wiki/Rounding for details.
Scale and zero point must have same shape. They must be either scalar (per tensor) or N-D tensor
(per row for 'a' and per column for 'b'). Scalar refers to per tensor quantization whereas N-D refers to per row
or per column quantization. If the input is 2D of shape [M, K] then zero point and scale tensor may be
an M element vector [v_1, v_2, ..., v_M] for per row quantization and K element vector of shape [v_1, v_2, ..., v_K]
for per column quantization. If the input is N-D tensor with shape [D1, D2, M, K] then zero point and scale tensor may
It consumes two quantized input tensors, their scales and zero points, scale and zero point of output,
and computes the quantized output. The quantization formula is y = saturate((x / y_scale) + y_zero_point).
For (x / y_scale), it is rounding to nearest ties to even. Refer to https://en.wikipedia.org/wiki/Rounding for details.
Scale and zero point must have same shape. They must be either scalar (per tensor) or N-D tensor
(per row for 'a' and per column for 'b'). Scalar refers to per tensor quantization whereas N-D refers to per row
or per column quantization. If the input is 2D of shape [M, K] then zero point and scale tensor may be
an M element vector [v_1, v_2, ..., v_M] for per row quantization and K element vector of shape [v_1, v_2, ..., v_K]
for per column quantization. If the input is N-D tensor with shape [D1, D2, M, K] then zero point and scale tensor may
have shape [D1, D2, M, 1] for per row quantization and shape [D1, D2, 1, K] for per column quantization.
Production must never overflow, and accumulation may overflow if and only if in 32 bits.
)DOC";
Expand Down Expand Up @@ -2858,16 +2858,9 @@ Generates a {name} window as described in the paper https://ieeexplore.ieee.org/
true,
1,
OpSchema::NonDifferentiable);
schema.Output(
0,
"output",
"A Hann window with length: size. "
"The output has the shape: [size].",
"T2",
OpSchema::Single,
true,
1,
OpSchema::NonDifferentiable);
std::string output_doc("A {name} window with length: size. The output has the shape: [size].");
ReplaceAll(output_doc, "{name}", name);
schema.Output(0, "output", output_doc, "T2", OpSchema::Single, true, 1, OpSchema::NonDifferentiable);
schema.TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) {
// Update the output data type to the output_datatype
auto output_datatype = getAttribute(ctx, "output_datatype", static_cast<int64_t>(TensorProto_DataType_FLOAT));
Expand Down Expand Up @@ -2925,7 +2918,7 @@ ONNX_OPERATOR_SET_SCHEMA(
Symmetric_Component = Mul(Symmetric_Size_FP, IsSymmetric_FP)
Size_FP = Add(Periodic_Component, Symmetric_Component)
AngularIncrement = Div (Tau, Size_FP)
Range = Range (Zero, Size_FP, One)
Range = Range (Zero, Periodic_Size_FP, One)
RangeAngular = Mul (Range, AngularIncrement)
TwoRangeAngular = Mul (RangeAngular, Two)
CosTwoRangeAngular = Cos (TwoRangeAngular)
Expand Down Expand Up @@ -2963,7 +2956,7 @@ ONNX_OPERATOR_SET_SCHEMA(
Symmetric_Component = Mul(Symmetric_Size_FP, IsSymmetric_FP)
Size_FP = Add(Periodic_Component, Symmetric_Component)
AngularIncrement = Div (Tau, Size_FP)
Range = Range (Zero, Size_FP, One)
Range = Range (Zero, Periodic_Size_FP, One)
RangeAngular = Mul (Range, AngularIncrement)
TwoRangeAngular = Mul (RangeAngular, Two)
CosTwoRangeAngular = Cos (TwoRangeAngular)
Expand Down Expand Up @@ -3001,7 +2994,7 @@ ONNX_OPERATOR_SET_SCHEMA(
Symmetric_Component = Mul(Symmetric_Size_FP, IsSymmetric_FP)
Size_FP = Add(Periodic_Component, Symmetric_Component)
AngularIncrement = Div (Tau, Size_FP)
Range = Range (Zero, Size_FP, One)
Range = Range (Zero, Periodic_Size_FP, One)
RangeAngular = Mul (Range, AngularIncrement)
TwoRangeAngular = Mul (RangeAngular, Two)
CosTwoRangeAngular = Cos (TwoRangeAngular)
Expand All @@ -3017,7 +3010,7 @@ ONNX_OPERATOR_SET_SCHEMA(
static const char* MelWeightMatrix_ver17_doc = R"DOC(
Generate a MelWeightMatrix that can be used to re-weight a Tensor containing a linearly sampled frequency spectra (from DFT or STFT) into num_mel_bins frequency information based on the [lower_edge_hertz, upper_edge_hertz] range on the mel scale.
This function defines the mel scale in terms of a frequency in hertz according to the following formula:

mel(f) = 2595 * log10(1 + f/700)

In the returned matrix, all the triangles (filterbanks) have a peak value of 1.0.
Expand Down
2 changes: 1 addition & 1 deletion onnx/defs/nn/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ ONNX_OPERATOR_SET_SCHEMA(
.Add("Axis1D = Constant()", "value", mktensor(axis)) // [axis] : 1D tensor
.Add("PrefixShape = Slice (XShape, Zero1D, Axis1D)") // [d[0], ..., d[axis-1]]
.Add(
axis > 0 // number of axes that are reduced =
axis >= 0 // number of axes that are reduced =
? "NumReducedAxes = Sub (Rank, Axis1D)" // [rank - axis]: 1D tensor
: "NumReducedAxes = Neg (Axis1D)") // [-axis] : 1D tensor
.Add(
Expand Down

0 comments on commit b2845aa

Please sign in to comment.