Skip to content

Commit

Permalink
Add ingestion support for pad opset 19 (#2482)
Browse files Browse the repository at this point in the history
Signed-off-by: philass <[email protected]>
  • Loading branch information
philass authored Sep 7, 2023
1 parent 49233b0 commit 87fb4ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Builder/OpBuildTable.inc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ op_dialect_version_map_["OptionalGetElement"] = {18};
op_dialect_version_map_["OptionalHasElement"] = {18};
op_dialect_version_map_["Or"] = {7};
op_dialect_version_map_["PRelu"] = {16};
op_dialect_version_map_["Pad"] = {18, 13, 11, 2};
op_dialect_version_map_["Pad"] = {19, 13, 11, 2};
op_dialect_version_map_["Pow"] = {15};
op_dialect_version_map_["QLinearConv"] = {10};
op_dialect_version_map_["QLinearMatMul"] = {10};
Expand Down
25 changes: 25 additions & 0 deletions src/Dialect/ONNX/ONNXOps.td.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5168,6 +5168,8 @@ def ONNXPadOp:ONNX_Op<"Pad",

3) `edge` - pads with the edge values of array

4) `wrap` - wrap-around padding as if the data tensor forms a torus


Example 1 (`constant` mode):

Expand Down Expand Up @@ -5232,6 +5234,29 @@ def ONNXPadOp:ONNX_Op<"Pad",
[4.5, 4.5, 4.5, 5.7],
]
```

Example 4 (`wrap` mode):

```
data = [
[1.0, 1.2],
[2.3, 3.4],
[4.5, 5.7],
]

pads = [2, 1, 1, 1]

mode = 'wrap'

output = [
[3.4, 2.3, 3.4, 2.3],
[5.7, 4.5, 5.7, 4.5],
[1.2, 1.0, 1.2, 1.0],
[3.4, 2.3, 3.4, 2.3],
[5.7, 4.5, 5.7, 4.5],
[1.2, 1.0, 1.2, 1.0],
]
```
}];
let arguments = (ins AnyTypeOf<[TensorOf<[UI8]>, TensorOf<[UI16]>, TensorOf<[UI32]>, TensorOf<[UI64]>, TensorOf<[I8]>, TensorOf<[I16]>, TensorOf<[I32]>, TensorOf<[I64]>, TensorOf<[BF16]>, TensorOf<[F16]>, TensorOf<[F32]>, TensorOf<[F64]>, TensorOf<[StringType]>, TensorOf<[I1]>, TensorOf<[Complex<F32>]>, TensorOf<[Complex<F64>]>]>:$data,
TensorOf<[I64]>:$pads,
Expand Down
2 changes: 1 addition & 1 deletion utils/gen_onnx_mlir.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
'OptionalHasElement' : [18],
'Or': [7],
'PRelu': [16],
'Pad': [18, 13, 11, 2],
'Pad': [19, 13, 11, 2],
'Pow': [15],
'QLinearConv': [10],
'QLinearMatMul': [10],
Expand Down

0 comments on commit 87fb4ec

Please sign in to comment.