Skip to content

Commit

Permalink
Fix onnx.PadV13 to onnx.Pad transformation issue. (onnx#2177)
Browse files Browse the repository at this point in the history
* Enable transform from onnx.PadV13 to onnx.Pad.

Signed-off-by: Yasushi Negishi <[email protected]>
  • Loading branch information
negiyas authored Apr 19, 2023
1 parent d10978c commit 35b623d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Transform/ONNX/Decompose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ void DecomposeONNXToONNXPass::runOnOperation() {
target.addIllegalOp<ONNXLogSoftmaxOp>();
target.addIllegalOp<ONNXPadV2Op>();
target.addIllegalOp<ONNXPadV11Op>();
target.addIllegalOp<ONNXPadV13Op>();
target.addIllegalOp<ONNXReduceL1Op>();
target.addIllegalOp<ONNXReduceL2Op>();
target.addIllegalOp<ONNXReduceLogSumOp>();
Expand Down
13 changes: 13 additions & 0 deletions test/mlir/onnx/onnx_decompose.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,19 @@ func.func @test_unsqueezeV11(%arg0 : tensor<*xf32>) -> () {

// -----

func.func @test_padV13(%arg0 : tensor<*xi64>, %arg1 : tensor<2xi64>) -> () {
%0 = "onnx.NoValue"() {value} : () -> none
%1 = "onnx.PadV13"(%arg0, %arg1, %0) : (tensor<*xi64>, tensor<2xi64>, none) -> tensor<*xi64>
return
// CHECK-LABEL: func @test_padV13
// CHECK: [[VAR_0_:%.+]] = "onnx.NoValue"() {value} : () -> none
// CHECK: [[VAR_1_:%.+]] = "onnx.NoValue"() {value} : () -> none
// CHECK: [[VAR_2_:%.+]] = "onnx.Pad"(%arg0, %arg1, [[VAR_0_]], [[VAR_1_]]) {mode = "constant"} : (tensor<*xi64>, tensor<2xi64>, none, none) -> tensor<*xi64>
// CHECK: return
}

// -----

func.func @test_scatter(%arg0: tensor<64x25600xf32>, %arg1: tensor<64x100xi64>, %arg2: tensor<64x100xf32>) -> tensor<*xf32> {
%0 = "onnx.Scatter"(%arg0, %arg1, %arg2) {axis = 1 : si64} : (tensor<64x25600xf32>, tensor<64x100xi64>, tensor<64x100xf32>) -> tensor<*xf32>
return %0 : tensor<*xf32>
Expand Down

0 comments on commit 35b623d

Please sign in to comment.