From 68efd2106482166e8439695708d0e8ed3b1c230c Mon Sep 17 00:00:00 2001 From: Doru Bercea Date: Wed, 22 Jan 2020 16:34:59 -0500 Subject: [PATCH] Fix dilation formula in the code. --- src/dialect/onnx/onnx_ops.cpp | 2 +- test/mlir/onnx/onnx_shape_inference.mlir | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dialect/onnx/onnx_ops.cpp b/src/dialect/onnx/onnx_ops.cpp index 83059cd..6fcb241 100644 --- a/src/dialect/onnx/onnx_ops.cpp +++ b/src/dialect/onnx/onnx_ops.cpp @@ -540,7 +540,7 @@ void ONNXConvNoBiasOp::inferShapes() { emitError("dilations length incompatible with spatial dimensions."); for (int i = 0; i < nDims; ++i) kernelDims[i] = (kernelDims[i] + 1) * - (dilations.getValue()[i]).cast().getInt() + 1; + (dilations.getValue()[i]).cast().getInt() - 1; } // Subtract kernel dimensions from input data dimensions. diff --git a/test/mlir/onnx/onnx_shape_inference.mlir b/test/mlir/onnx/onnx_shape_inference.mlir index 5b7530f..9022b05 100644 --- a/test/mlir/onnx/onnx_shape_inference.mlir +++ b/test/mlir/onnx/onnx_shape_inference.mlir @@ -125,8 +125,8 @@ func @test_conv_no_bias_9(%arg0 : tensor<1x2x32x64xf32>, %arg1 : tensor<5x2x6x7x } // CHECK-LABEL: test_conv_no_bias_9 -// CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", dilations = [2, 3], group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x18x40xf32> -// CHECK: return [[RES_ATTR]] : tensor<1x5x18x40xf32> +// CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", dilations = [2, 3], group = 1 : i32} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x20x42xf32> +// CHECK: return [[RES_ATTR]] : tensor<1x5x20x42xf32> /// dilations attribute with stride. @@ -136,5 +136,5 @@ func @test_conv_no_bias_10(%arg0 : tensor<1x2x32x64xf32>, %arg1 : tensor<5x2x6x7 } // CHECK-LABEL: test_conv_no_bias_10 -// CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", dilations = [2, 3], group = 1 : i32, strides = [2, 2]} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x9x20xf32> -// CHECK: return [[RES_ATTR]] : tensor<1x5x9x20xf32> +// CHECK: [[RES_ATTR:%.+]] = "onnx.ConvNoBias"(%arg0, %arg1) {auto_pad = "NOTSET", dilations = [2, 3], group = 1 : i32, strides = [2, 2]} : (tensor<1x2x32x64xf32>, tensor<5x2x6x7xf32>) -> tensor<1x5x10x21xf32> +// CHECK: return [[RES_ATTR]] : tensor<1x5x10x21xf32>