Skip to content

Commit 7071324

Browse files
Merge branch 'main' into arch-native-mac
2 parents fa1b30e + e23d8ed commit 7071324

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Dialect/ONNX/ONNXOps/Canonicalize.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def ReorderReluMaxPoolPattern : Pattern<
707707
$X,
708708
$auto_pad, $ceil_mode, $dilations, $kernel_shape,
709709
$pads, $storage_order, $strides,
710-
(returnType (GetReturnTypeForMaxPool2D $X))))],
710+
(returnType (GetReturnTypeForMaxPool2D $X)), (location $maxpool)), (location $relu))],
711711
[
712712
(HasRankOf<4> $X),
713713
(IsStaticShapeTensor:$maxpool),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: onnx-mlir-opt --shape-inference --canonicalize="test-convergence=true" --shape-inference --cse %s -split-input-file --mlir-print-debuginfo | FileCheck %s
2+
3+
4+
func.func @test_reorder_relu_maxpool(%arg0: tensor<1x64x32x32xf32>) -> tensor<1x64x16x16xf32> {
5+
%0 = "onnx.Relu"(%arg0) : (tensor<1x64x32x32xf32>) -> tensor<1x64x32x32xf32> loc("Relu")
6+
%1 = "onnx.MaxPoolSingleOut"(%0) {auto_pad = "NOTSET", ceil_mode = 0 : si64, kernel_shape = [2, 2], onnx_node_name = "onnx.MaxPoolSingleOut_1", storage_order = 0 : si64, strides = [2, 2]} : (tensor<1x64x32x32xf32>) -> tensor<1x64x16x16xf32> loc("MaxPool")
7+
return %1 : tensor<1x64x16x16xf32>
8+
9+
// CHECK-LABEL: func @test_reorder_relu_maxpool
10+
// CHECK: [[VAR_0_:%.+]] = "onnx.MaxPoolSingleOut"(%arg0) {auto_pad = "NOTSET", ceil_mode = 0 : si64, kernel_shape = [2, 2], storage_order = 0 : si64, strides = [2, 2]} : (tensor<1x64x32x32xf32>) -> tensor<1x64x16x16xf32> loc([[LOC_MAX_POOL:#.+]])
11+
// CHECK: [[VAR_1_:%.+]] = "onnx.Relu"([[VAR_0_]]) : (tensor<1x64x16x16xf32>) -> tensor<1x64x16x16xf32> loc([[LOC_RELU:#.+]])
12+
// CHECK-DAG: [[LOC_MAX_POOL:#.+]] = loc("MaxPool")
13+
// CHECK-DAG: [[LOC_RELU:#.+]] = loc("Relu")
14+
}
15+

0 commit comments

Comments
 (0)