From faaa8ce78d5d77bcc49af9921240bacfc78e5e12 Mon Sep 17 00:00:00 2001 From: Yizhuo Zhang Date: Thu, 19 Sep 2024 11:47:45 -0700 Subject: [PATCH 1/3] Fix stablehlo pad converter --- mlir-tensorrt/Version.cmake | 2 +- .../lib/Conversion/StablehloToTensorRT/StablehloToTensorRT.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mlir-tensorrt/Version.cmake b/mlir-tensorrt/Version.cmake index 397a35aa9..896845e1a 100644 --- a/mlir-tensorrt/Version.cmake +++ b/mlir-tensorrt/Version.cmake @@ -1,6 +1,6 @@ set(MLIR_TENSORRT_VERSION_MAJOR "0") set(MLIR_TENSORRT_VERSION_MINOR "1") -set(MLIR_TENSORRT_VERSION_PATCH "32") +set(MLIR_TENSORRT_VERSION_PATCH "33") set(MLIR_TENSORRT_VERSION "${MLIR_TENSORRT_VERSION_MAJOR}.${MLIR_TENSORRT_VERSION_MINOR}.${MLIR_TENSORRT_VERSION_PATCH}") diff --git a/mlir-tensorrt/compiler/lib/Conversion/StablehloToTensorRT/StablehloToTensorRT.cpp b/mlir-tensorrt/compiler/lib/Conversion/StablehloToTensorRT/StablehloToTensorRT.cpp index 1476e0100..63e9ee322 100644 --- a/mlir-tensorrt/compiler/lib/Conversion/StablehloToTensorRT/StablehloToTensorRT.cpp +++ b/mlir-tensorrt/compiler/lib/Conversion/StablehloToTensorRT/StablehloToTensorRT.cpp @@ -2248,7 +2248,7 @@ struct PadConverter : public ConvertHloOpToTensorRTPattern { rewriter.replaceOpWithNewOp( op, /*input=*/adaptor.getOperand(), - /*offset=*/*edgePaddingLow, + /*offset=*/sliceOffset, /*size=*/size, /*stride=*/stride, /*slice_mode=*/tensorrt::SliceMode::kFILL, From 31617a8ad1c968534c77d977bd2f2fa3abe6ed06 Mon Sep 17 00:00:00 2001 From: Yizhuo Zhang Date: Fri, 20 Sep 2024 11:44:59 -0700 Subject: [PATCH 2/3] Add unit test --- .../stablehlo-to-tensorrt.mlir | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mlir-tensorrt/test/Conversion/StablehloToTensorRT/stablehlo-to-tensorrt.mlir b/mlir-tensorrt/test/Conversion/StablehloToTensorRT/stablehlo-to-tensorrt.mlir index 35d262b79..6dd22dbaf 100644 --- a/mlir-tensorrt/test/Conversion/StablehloToTensorRT/stablehlo-to-tensorrt.mlir +++ b/mlir-tensorrt/test/Conversion/StablehloToTensorRT/stablehlo-to-tensorrt.mlir @@ -1124,6 +1124,23 @@ func.func @hlo_pad_static(%arg0: tensor<10x48x48x32xf32>) -> tensor<10x48x48x48x // ----- +func.func @hlo_pad_static_low_high(%arg0: tensor<10x48x48x32xf32>) -> tensor<10x48x48x64xf32> { + %0 = "stablehlo.constant"() {value = dense<0.0> : tensor} : () -> tensor + %1 = "stablehlo.pad"(%arg0, %0) { + edge_padding_high = array, + edge_padding_low = array, + interior_padding = array + } : (tensor<10x48x48x32xf32>, tensor) -> tensor<10x48x48x64xf32> + func.return %1 : tensor<10x48x48x64xf32> +} + +// CHECK-LABEL: @hlo_pad_static +// CHECK-SAME: (%[[arg0:.+]]: tensor<10x48x48x32xf32> +// CHECK: %[[fill:.+]] = tensorrt.constant dense<0.0{{.*}}> : tensor +// CHECK: tensorrt.slice %[[arg0]][0, 0, 0, -16][10, 48, 48, 64][1, 1, 1, 1] fill(%[[fill]] : tensor) {mode = #tensorrt.slice_mode} : tensor<10x48x48x32xf32> to tensor<10x48x48x64xf32> + +// ----- + func.func @hlo_pad_dynamic_non_sliced_dim(%arg0: tensor) -> tensor { %0 = "stablehlo.constant"() {value = dense<0.0> : tensor} : () -> tensor %1 = "stablehlo.pad"(%arg0, %0) { From 0022716890805f72426d33177b1eba40786b9a5b Mon Sep 17 00:00:00 2001 From: Yizhuo Zhang Date: Tue, 24 Sep 2024 13:34:14 -0700 Subject: [PATCH 3/3] Revert version update --- mlir-tensorrt/Version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir-tensorrt/Version.cmake b/mlir-tensorrt/Version.cmake index 896845e1a..397a35aa9 100644 --- a/mlir-tensorrt/Version.cmake +++ b/mlir-tensorrt/Version.cmake @@ -1,6 +1,6 @@ set(MLIR_TENSORRT_VERSION_MAJOR "0") set(MLIR_TENSORRT_VERSION_MINOR "1") -set(MLIR_TENSORRT_VERSION_PATCH "33") +set(MLIR_TENSORRT_VERSION_PATCH "32") set(MLIR_TENSORRT_VERSION "${MLIR_TENSORRT_VERSION_MAJOR}.${MLIR_TENSORRT_VERSION_MINOR}.${MLIR_TENSORRT_VERSION_PATCH}")