diff --git a/src/Builder/OpBuildTable.inc b/src/Builder/OpBuildTable.inc index fb12f255d8..5867fc7e1a 100644 --- a/src/Builder/OpBuildTable.inc +++ b/src/Builder/OpBuildTable.inc @@ -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}; diff --git a/src/Dialect/ONNX/ONNXOps.td.inc b/src/Dialect/ONNX/ONNXOps.td.inc index 445f88e318..d75ee6b66d 100644 --- a/src/Dialect/ONNX/ONNXOps.td.inc +++ b/src/Dialect/ONNX/ONNXOps.td.inc @@ -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): @@ -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]>, TensorOf<[Complex]>]>:$data, TensorOf<[I64]>:$pads, diff --git a/utils/gen_onnx_mlir.py b/utils/gen_onnx_mlir.py index a793508896..95f4bb2253 100755 --- a/utils/gen_onnx_mlir.py +++ b/utils/gen_onnx_mlir.py @@ -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],