[Mlir-commits] [mlir] bfa508e - [mlir][linalg] Fix one more missing NoSideEffect in linalg tensor op

Thomas Raoux llvmlistbot at llvm.org
Tue Feb 9 07:05:47 PST 2021


Author: Thomas Raoux
Date: 2021-02-09T07:04:50-08:00
New Revision: bfa508efd589d9bdcae4a2ec8f668af36af39e1f

URL: https://github.com/llvm/llvm-project/commit/bfa508efd589d9bdcae4a2ec8f668af36af39e1f
DIFF: https://github.com/llvm/llvm-project/commit/bfa508efd589d9bdcae4a2ec8f668af36af39e1f.diff

LOG: [mlir][linalg] Fix one more missing NoSideEffect in linalg tensor op

Differential Revision: https://reviews.llvm.org/D96314

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
    mlir/test/Dialect/Linalg/canonicalize.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
index f558f656e558..bc98a04a19f2 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
@@ -123,7 +123,7 @@ def Linalg_InitTensorOp : Linalg_Op<"init_tensor", [NoSideEffect]> {
 }
 
 def Linalg_PadTensorOp : Linalg_Op<"pad_tensor",
-    [AttrSizedOperandSegments]> {
+    [AttrSizedOperandSegments, NoSideEffect]> {
   let summary = "tensor pad operation";
   let description = [{
     `linalg.pad_tensor` is an operation that pads the `source` tensor

diff  --git a/mlir/test/Dialect/Linalg/canonicalize.mlir b/mlir/test/Dialect/Linalg/canonicalize.mlir
index 1e68fd5ee862..75abef70cd4e 100644
--- a/mlir/test/Dialect/Linalg/canonicalize.mlir
+++ b/mlir/test/Dialect/Linalg/canonicalize.mlir
@@ -696,9 +696,13 @@ func @fold_init_tensor_with_subtensor
 //   CHECK-NOT:   linalg.fill
 //   CHECK-NOT:   linalg.matmul
 //   CHECK-NOT:   linalg.generic
+//   CHECK-NOT:   linalg.pad_tensor
 //       CHECK:   return
-func @dead_linalg_tensor(%arg0 : tensor<7x7xi32>, %arg1 : tensor<7x7xf32>) {
+func @dead_linalg_tensor(%arg0 : tensor<7x7xi32>, %arg1 : tensor<7x7xf32>,
+                         %arg2: tensor<?x?xf32>, %high : index) {
   %c0_i32 = constant 0 : i32
+  %c0 = constant 0 : index
+  %cst = constant 0.000000e+00 : f32
   %0 = linalg.fill(%arg0, %c0_i32) : tensor<7x7xi32>, i32 -> tensor<7x7xi32>
   %1 = linalg.matmul ins(%arg1, %arg1: tensor<7x7xf32>, tensor<7x7xf32>)
                      outs(%arg1: tensor<7x7xf32>) -> tensor<7x7xf32>
@@ -706,5 +710,9 @@ func @dead_linalg_tensor(%arg0 : tensor<7x7xi32>, %arg1 : tensor<7x7xf32>) {
   ^bb(%3: i32) :
     linalg.yield %3 : i32
   } -> tensor<7x7xi32>
+  %3 = linalg.pad_tensor %arg2 low[%c0, %c0] high[%high, %high] {
+        ^bb0(%arg9: index, %arg10: index):  // no predecessors
+          linalg.yield %cst : f32
+  } : tensor<?x?xf32> to tensor<2x4xf32>
   return
 }


        


More information about the Mlir-commits mailing list