Skip to content

Commit

Permalink
upgrade to ONNX 1.17.0 (opset 22) (#3004)
Browse files Browse the repository at this point in the history
Signed-off-by: Gong Su <[email protected]>
  • Loading branch information
gongsu832 authored Nov 11, 2024
1 parent ba08e0f commit 7411403
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/Dialects/krnl.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ in the `value` dense element attribute.

Traits: `AlwaysSpeculatableImplTrait`, `MemRefsNormalizable`

Interfaces: `ConditionallySpeculatable`, `NoMemoryEffect (MemoryEffectOpInterface)`
Interfaces: `ConditionallySpeculatable`, `KrnlGlobalOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)`

Effects: `MemoryEffects::Effect{}`

Expand Down
30 changes: 15 additions & 15 deletions docs/Dialects/onnx.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ AveragePool consumes an input tensor X and applies average pooling across
```
output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)
```
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored.
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`.

`auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:
```
Expand Down Expand Up @@ -1701,15 +1701,15 @@ Effects: `MemoryEffects::Effect{}`

| Operand | Description |
| :-----: | ----------- |
| `X` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values
| `W` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values
| `B` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values or none type
| `X` | tensor of 16-bit float values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values
| `W` | tensor of 16-bit float values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values
| `B` | tensor of 16-bit float values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values or none type

#### Results:

| Result | Description |
| :----: | ----------- |
| `Y` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values
| `Y` | tensor of 16-bit float values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values

### `onnx.ConvTranspose` (ONNXConvTransposeOp)

Expand Down Expand Up @@ -2610,13 +2610,13 @@ Effects: `MemoryEffects::Effect{}`

| Operand | Description |
| :-----: | ----------- |
| `input` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values or tensor of bfloat16 type values
| `input` | tensor of bfloat16 type values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values

#### Results:

| Result | Description |
| :----: | ----------- |
| `output` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values or tensor of bfloat16 type values
| `output` | tensor of bfloat16 type values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values

### `onnx.Expand` (ONNXExpandOp)

Expand Down Expand Up @@ -3282,13 +3282,13 @@ Effects: `MemoryEffects::Effect{}`

| Operand | Description |
| :-----: | ----------- |
| `X` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values
| `X` | tensor of bfloat16 type values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values

#### Results:

| Result | Description |
| :----: | ----------- |
| `Y` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values
| `Y` | tensor of bfloat16 type values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values

### `onnx.GlobalMaxPool` (ONNXGlobalMaxPoolOp)

Expand Down Expand Up @@ -4817,7 +4817,7 @@ Effects: `MemoryEffects::Effect{}`

_ONNX MatMulInteger operation_

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html.
Matrix product that behaves like [numpy.matmul](https://numpy.org/doc/stable/reference/generated/numpy.matmul.html).
The production MUST never overflow. The accumulation may overflow if and only if in 32 bits.

Traits: `AlwaysSpeculatableImplTrait`
Expand Down Expand Up @@ -4845,7 +4845,7 @@ Effects: `MemoryEffects::Effect{}`

_ONNX MatMul operation_

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html
Matrix product that behaves like [numpy.matmul](https://numpy.org/doc/stable/reference/generated/numpy.matmul.html).

Traits: `AlwaysSpeculatableImplTrait`

Expand Down Expand Up @@ -4910,7 +4910,7 @@ MaxPool consumes an input tensor X and applies max pooling across
```
output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)
```
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored.
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`.

`auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:
```
Expand Down Expand Up @@ -6611,7 +6611,7 @@ Effects: `MemoryEffects::Effect{}`

_ONNX QLinearMatMul operation_

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html.
Matrix product that behaves like [numpy.matmul](https://numpy.org/doc/stable/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.
Expand Down Expand Up @@ -10215,13 +10215,13 @@ Effects: `MemoryEffects::Effect{}`

| Operand | Description |
| :-----: | ----------- |
| `input` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values or tensor of bfloat16 type values
| `input` | tensor of bfloat16 type values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values

#### Results:

| Result | Description |
| :----: | ----------- |
| `output` | tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values or tensor of bfloat16 type values
| `output` | tensor of bfloat16 type values or tensor of 16-bit float values or tensor of 32-bit float values or tensor of 64-bit float values

### `onnx.TfIdfVectorizer` (ONNXTfIdfVectorizerOp)

Expand Down
3 changes: 3 additions & 0 deletions docs/Dialects/zhigh.md
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ Effects: `MemoryEffects::Effect{}`
_ZHigh Stickified Constant operation_

This operator produces a constant tensor to store stickified data.
`value` attribute has original constant or stickified constant.
`stickified` attribute indicates the `value` is already stickified or not.
Stickified data is opaque and must be 4K-aligned. One who produces
the stickified data must make sure its size in bytes consistent with
the output tensor's size.
Expand All @@ -807,6 +809,7 @@ Effects: `MemoryEffects::Effect{}`

<table>
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
<tr><td><code>stickified</code></td><td>::mlir::BoolAttr</td><td>bool attribute</td></tr>
<tr><td><code>value</code></td><td>::mlir::Attribute</td><td>any attribute</td></tr>
<tr><td><code>alignment</code></td><td>::mlir::IntegerAttr</td><td>64-bit signless integer attribute</td></tr>
</table>
Expand Down
28 changes: 28 additions & 0 deletions docs/Dialects/zlow.md
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,34 @@ Interfaces: `MemoryEffectOpInterface`
| `X` | memref of 16-bit float or 32-bit float values
| `Out` | memref of dlfloat16 type values

### `zlow.stickifiedConstant` (::onnx_mlir::zlow::ZLowStickifiedConstantOp)

_ZLow Stickified Constant operation._


Traits: `MemRefsNormalizable`

Interfaces: `KrnlGlobalOpInterface`

#### Attributes:

<table>
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
<tr><td><code>shape</code></td><td>::mlir::Attribute</td><td>any attribute</td></tr>
<tr><td><code>name</code></td><td>::mlir::StringAttr</td><td>string attribute</td></tr>
<tr><td><code>stickified</code></td><td>::mlir::BoolAttr</td><td>bool attribute</td></tr>
<tr><td><code>value</code></td><td>::mlir::Attribute</td><td>any attribute</td></tr>
<tr><td><code>layout</code></td><td>::mlir::StringAttr</td><td>string attribute</td></tr>
<tr><td><code>offset</code></td><td>::mlir::IntegerAttr</td><td>64-bit signless integer attribute</td></tr>
<tr><td><code>alignment</code></td><td>::mlir::IntegerAttr</td><td>64-bit signless integer attribute</td></tr>
</table>

#### Results:

| Result | Description |
| :----: | ----------- |
| `output` | memref of dlfloat16 type values

### `zlow.sub` (::onnx_mlir::zlow::ZLowSubOp)

_ZLow sub operation_
Expand Down
30 changes: 15 additions & 15 deletions src/Dialect/ONNX/ONNXOps.td.inc
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def ONNXAveragePoolOp:ONNX_Op<"AveragePool",
```
output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)
```
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored.
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`.

`auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:
```
Expand Down Expand Up @@ -1400,16 +1400,16 @@ def ONNXConvOp:ONNX_Op<"Conv",
The convolution operator consumes an input tensor and a filter, and
computes the output.
}];
let arguments = (ins AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$X,
AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$W,
AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, NoneType]>:$B,
let arguments = (ins AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$X,
AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$W,
AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, NoneType]>:$B,
DefaultValuedStrAttr<StrAttr, "NOTSET">:$auto_pad,
OptionalAttr<I64ArrayAttr>:$dilations,
DefaultValuedAttr<SI64Attr, "1">:$group,
OptionalAttr<I64ArrayAttr>:$kernel_shape,
OptionalAttr<I64ArrayAttr>:$pads,
OptionalAttr<I64ArrayAttr>:$strides);
let results = (outs AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$Y);
let results = (outs AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$Y);
let builders = [
OpBuilder<(ins "Value":$X, "Value":$W, "Value":$B, "StringAttr":$auto_pad, "ArrayAttr":$dilations, "IntegerAttr":$group, "ArrayAttr":$kernel_shape, "ArrayAttr":$pads, "ArrayAttr":$strides), [{
auto resultType = UnrankedTensorType::get(mlir::cast<ShapedType>(X.getType()).getElementType());
Expand Down Expand Up @@ -2231,8 +2231,8 @@ def ONNXExpOp:ONNX_Op<"Exp",
let description = [{
Calculates the exponential of the given input tensor, element-wise.
}];
let arguments = (ins AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, TensorOf<[BF16]>]>:$input);
let results = (outs AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, TensorOf<[BF16]>]>:$output);
let arguments = (ins AnyTypeOf<[TensorOf<[BF16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$input);
let results = (outs AnyTypeOf<[TensorOf<[BF16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$output);
let builders = [
OpBuilder<(ins "Value":$input), [{
auto resultType = UnrankedTensorType::get(mlir::cast<ShapedType>(input.getType()).getElementType());
Expand Down Expand Up @@ -2892,9 +2892,9 @@ def ONNXGlobalLpPoolOp:ONNX_Op<"GlobalLpPool",
the values in the same channel. This is equivalent to LpPool with kernel size
equal to the spatial dimension of input tensor.
}];
let arguments = (ins AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$X,
let arguments = (ins AnyTypeOf<[TensorOf<[BF16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$X,
DefaultValuedAttr<SI64Attr, "2">:$p);
let results = (outs AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$Y);
let results = (outs AnyTypeOf<[TensorOf<[BF16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$Y);
let extraClassDeclaration = [{
static int getNumberOfOperands() {
return 1;
Expand Down Expand Up @@ -4242,7 +4242,7 @@ def ONNXMatMulOp:ONNX_Op<"MatMul",
[Pure, DeclareOpInterfaceMethods<ShapeInferenceOpInterface>, DeclareOpInterfaceMethods<ShapeHelperOpInterface>]> {
let summary = "ONNX MatMul operation";
let description = [{
Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html
Matrix product that behaves like [numpy.matmul](https://numpy.org/doc/stable/reference/generated/numpy.matmul.html).
}];
let arguments = (ins AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, TensorOf<[UI32]>, TensorOf<[UI64]>, TensorOf<[I32]>, TensorOf<[I64]>, TensorOf<[BF16]>]>:$A,
AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, TensorOf<[UI32]>, TensorOf<[UI64]>, TensorOf<[I32]>, TensorOf<[I64]>, TensorOf<[BF16]>]>:$B);
Expand Down Expand Up @@ -4272,7 +4272,7 @@ def ONNXMatMulIntegerOp:ONNX_Op<"MatMulInteger",
[Pure, DeclareOpInterfaceMethods<ShapeInferenceOpInterface>, DeclareOpInterfaceMethods<ShapeHelperOpInterface>]> {
let summary = "ONNX MatMulInteger operation";
let description = [{
Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html.
Matrix product that behaves like [numpy.matmul](https://numpy.org/doc/stable/reference/generated/numpy.matmul.html).
The production MUST never overflow. The accumulation may overflow if and only if in 32 bits.
}];
let arguments = (ins AnyTypeOf<[TensorOf<[I8]>, TensorOf<[UI8]>]>:$A,
Expand Down Expand Up @@ -4352,7 +4352,7 @@ def ONNXMaxPoolOp:ONNX_Op<"MaxPool",
```
output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1)
```
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored.
if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`.

`auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled:
```
Expand Down Expand Up @@ -5921,7 +5921,7 @@ def ONNXQLinearMatMulOp:ONNX_Op<"QLinearMatMul",
[Pure, DeclareOpInterfaceMethods<ShapeInferenceOpInterface>, DeclareOpInterfaceMethods<ShapeHelperOpInterface>]> {
let summary = "ONNX QLinearMatMul operation";
let description = [{
Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html.
Matrix product that behaves like [numpy.matmul](https://numpy.org/doc/stable/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.
Expand Down Expand Up @@ -9511,8 +9511,8 @@ def ONNXTanhOp:ONNX_Op<"Tanh",
let description = [{
Calculates the hyperbolic tangent of the given input tensor element-wise.
}];
let arguments = (ins AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, TensorOf<[BF16]>]>:$input);
let results = (outs AnyTypeOf<[TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, TensorOf<[BF16]>]>:$output);
let arguments = (ins AnyTypeOf<[TensorOf<[BF16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$input);
let results = (outs AnyTypeOf<[TensorOf<[BF16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>]>:$output);
let extraClassDeclaration = [{
static int getNumberOfOperands() {
return 1;
Expand Down
8 changes: 7 additions & 1 deletion test/backend/all_test_names.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is automatically generated by "make check-onnx-backend-case"
# From onnx 1.16.2
# From onnx 1.17.0
# All test cases for cpu target
test_bvlc_alexnet_cpu
test_densenet121_cpu
Expand Down Expand Up @@ -303,6 +303,8 @@ test_convtranspose_3d_cpu
test_convtranspose_autopad_same_cpu
test_convtranspose_cpu
test_convtranspose_dilations_cpu
test_convtranspose_group_2_cpu
test_convtranspose_group_2_image_3_cpu
test_convtranspose_kernel_shape_cpu
test_convtranspose_output_shape_cpu
test_convtranspose_pad_cpu
Expand Down Expand Up @@ -880,6 +882,7 @@ test_reduce_max_default_axes_keepdim_example_cpu
test_reduce_max_default_axes_keepdims_random_cpu
test_reduce_max_do_not_keepdims_example_cpu
test_reduce_max_do_not_keepdims_random_cpu
test_reduce_max_empty_set_cpu
test_reduce_max_keepdims_example_cpu
test_reduce_max_keepdims_random_cpu
test_reduce_max_negative_axes_keepdims_example_cpu
Expand Down Expand Up @@ -915,6 +918,7 @@ test_reduce_sum_default_axes_keepdims_example_cpu
test_reduce_sum_default_axes_keepdims_random_cpu
test_reduce_sum_do_not_keepdims_example_cpu
test_reduce_sum_do_not_keepdims_random_cpu
test_reduce_sum_empty_axes_input_noop_cpu
test_reduce_sum_empty_axes_input_noop_example_cpu
test_reduce_sum_empty_set_cpu
test_reduce_sum_empty_set_non_reduced_axis_zero_cpu
Expand Down Expand Up @@ -975,6 +979,7 @@ test_resize_downsample_sizes_nearest_not_smaller_cpu
test_resize_tf_crop_and_resize_axes_2_3_cpu
test_resize_tf_crop_and_resize_axes_3_2_cpu
test_resize_tf_crop_and_resize_cpu
test_resize_tf_crop_and_resize_extrapolation_value_cpu
test_resize_upsample_scales_cubic_A_n0p5_exclude_outside_cpu
test_resize_upsample_scales_cubic_align_corners_cpu
test_resize_upsample_scales_cubic_asymmetric_cpu
Expand All @@ -992,6 +997,7 @@ test_resize_upsample_sizes_nearest_ceil_half_pixel_cpu
test_resize_upsample_sizes_nearest_cpu
test_resize_upsample_sizes_nearest_floor_align_corners_cpu
test_resize_upsample_sizes_nearest_not_larger_cpu
test_resize_upsample_sizes_nearest_not_smaller_cpu
test_resize_upsample_sizes_nearest_round_prefer_ceil_asymmetric_cpu
test_reversesequence_batch_cpu
test_reversesequence_time_cpu
Expand Down
2 changes: 1 addition & 1 deletion third_party/onnx
Submodule onnx updated 910 files
2 changes: 1 addition & 1 deletion utils/gen_onnx_mlir.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

# ==UPDATE_ONNX_VERSION_OPSET==
# Look for tag above and update all references when upgrading the ONNX support within ONNX-MLIR.
current_onnx_version = "1.16.2"
current_onnx_version = "1.17.0"

# Check the version of onnx package being used.
if (
Expand Down

0 comments on commit 7411403

Please sign in to comment.