From 4620410f18923a0993ef009870256c26896370cb Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 2 Jun 2021 09:31:57 -0700 Subject: [PATCH] Integrate LLVM at llvm/llvm-project@b25546a4b406 Updates LLVM usage to match [b25546a4b406](https://github.com/llvm/llvm-project/commit/b25546a4b406) PiperOrigin-RevId: 377077163 --- WORKSPACE | 4 ++-- build_tools/llvm_version.txt | 2 +- .../mhlo/transforms/legalize_to_linalg.cc | 18 ++++++++++++------ tests/hlo-legalize-to-linalg.mlir | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 820890c..4f191c6 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,9 +15,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -LLVM_COMMIT = "97d234935f1514af128277943f30efc469525371" +LLVM_COMMIT = "b25546a4b40675b596dcfdbfd491b10fa12d88e6" -LLVM_SHA256 = "168d75d00d50c3e4a09f18b096495bc924074b133c9916716daaf0cbe4c10abd" +LLVM_SHA256 = "e82cc57ee8b6232124459fad521bf7a0b5dbb1d479f528137364b6b1f3b58bc0" LLVM_BAZEL_TAG = "llvm-project-{commit}".format(commit = LLVM_COMMIT) diff --git a/build_tools/llvm_version.txt b/build_tools/llvm_version.txt index d736acf..99a82f4 100644 --- a/build_tools/llvm_version.txt +++ b/build_tools/llvm_version.txt @@ -1,2 +1,2 @@ -97d234935f1514af128277943f30efc469525371 +b25546a4b40675b596dcfdbfd491b10fa12d88e6 diff --git a/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc b/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc index c49b5a9..c93a093 100644 --- a/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc +++ b/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc @@ -1820,10 +1820,9 @@ struct DepthwiseConvOpOnTensorsConversion "non-zero padding unsupported yet"); } - if ((op.lhs_dilation() && !isSplatValue(*op.lhs_dilation(), 1)) || - (op.rhs_dilation() && !isSplatValue(*op.rhs_dilation(), 1))) { - return rewriter.notifyMatchFailure(op, - "non-one dialation unsupported yet"); + if ((op.lhs_dilation() && !isSplatValue(*op.lhs_dilation(), 1))) { + return rewriter.notifyMatchFailure( + op, "non-one lhs- dialation unsupported yet"); } if (const mhlo::ConvDimensionNumbers& dimension_numbers = @@ -1858,6 +1857,13 @@ struct DepthwiseConvOpOnTensorsConversion window_strides = rewriter.getI64VectorAttr({1, 1}); } + DenseIntElementsAttr rhs_dilation; + if (op.rhs_dilation()) { + rhs_dilation = op.rhs_dilation().getValue(); + } else { + rhs_dilation = rewriter.getI64VectorAttr({1, 1}); + } + mhlo::ConvOp::Adaptor adaptor(args); Location loc = op.getLoc(); Value input = adaptor.lhs(); @@ -1895,7 +1901,7 @@ struct DepthwiseConvOpOnTensorsConversion reshaped_output_dims, result_type.getElementType()); auto conv = rewriter.create( op.getLoc(), reshaped_output_type, ValueRange{input, filter}, - ValueRange{zero_tensor}, window_strides); + ValueRange{zero_tensor}, rhs_dilation, window_strides); // Create a Linalg reshape op that converts the output from 5 dimensions // into 4 dimensions (by collapsing the last two dimensions). This is @@ -1935,7 +1941,7 @@ struct DepthwiseConvOpOnTensorsConversion rewriter.replaceOpWithNewOp( op, result_type, ValueRange{input, reshaped_filter}, - ValueRange{zero_tensor}, window_strides); + ValueRange{zero_tensor}, rhs_dilation, window_strides); } return success(); diff --git a/tests/hlo-legalize-to-linalg.mlir b/tests/hlo-legalize-to-linalg.mlir index b8bc527..910c4f6 100644 --- a/tests/hlo-legalize-to-linalg.mlir +++ b/tests/hlo-legalize-to-linalg.mlir @@ -2059,7 +2059,7 @@ func @depthwise_conv(%arg0: tensor<2x4x5x2xf32>, // CHECK: %[[CST:.+]] = constant 0.000000e+00 : f32 // CHECK: %[[FILL:.+]] = linalg.fill(%[[INIT]], %[[CST]]) : tensor<2x3x4x2x3xf32>, f32 -> tensor<2x3x4x2x3xf32> // CHECK: %[[OUT:.+]] = linalg.depthwise_conv_2d_input_nhwc_filter_hwcf -// CHECK-SAME: {strides = dense<1> : tensor<2xi64>} +// CHECK-SAME: {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} // CHECK-SAME: ins(%[[IN]], %[[FILTER]] : tensor<2x4x5x2xf32>, tensor<2x2x2x3xf32>) // CHECK-SAME: outs(%[[FILL]] : tensor<2x3x4x2x3xf32>) -> tensor<2x3x4x2x3xf32> // CHECK: %{{.+}} = linalg.tensor_reshape %[[OUT]] @@ -2099,7 +2099,7 @@ func @depthwise_conv_multiplier_1(%arg0: tensor<1x113x113x96xf32>, // CHECK-SAME: [0], [1], [2, 3] // CHECK-SAME: : tensor<3x3x1x96xf32> into tensor<3x3x96xf32> // CHECK: %{{.+}} = linalg.depthwise_conv_2d_input_nhwc_filter_hwc -// CHECK-SAME: {strides = dense<2> : tensor<2xi64>} +// CHECK-SAME: {dilations = dense<1> : tensor<2xi64>, strides = dense<2> : tensor<2xi64>} // CHECK-SAME: ins(%[[IN]], %[[RESHAPED_FILTER]] : tensor<1x113x113x96xf32>, tensor<3x3x96xf32>) // CHECK-SAME: outs(%[[FILL]] : tensor<1x56x56x96xf32>) -> tensor<1x56x56x96xf32>