[Mlir-commits] [mlir] fe0befb - [mlir][linalg] Add padding helper functions to PadTensorOp

Matthias Springer llvmlistbot at llvm.org
Mon Jun 7 04:18:23 PDT 2021


Author: Matthias Springer
Date: 2021-06-07T20:18:06+09:00
New Revision: fe0befb123e4a727c3c883845c9d3bfe75d831c7

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

LOG: [mlir][linalg] Add padding helper functions to PadTensorOp

Add helper functions to quickly check for zero low/high padding.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
index d74e407640b0b..8b0766b2f7031 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
@@ -263,6 +263,18 @@ def Linalg_PadTensorOp : Linalg_Op<"pad_tensor",
     SmallVector<OpFoldResult> getMixedHighPad() {
       return getMixedPadImpl(static_high(), high());
     }
+    // Return true if low padding is guaranteed to be 0.
+    bool hasZeroLowPad() {
+      return llvm::all_of(getMixedLowPad(), [](OpFoldResult ofr) {
+        return mlir::isEqualConstantInt(ofr, 0);
+      });
+    }
+    // Return true if high padding is guaranteed to be 0.
+    bool hasZeroHighPad() {
+      return llvm::all_of(getMixedHighPad(), [](OpFoldResult ofr) {
+        return mlir::isEqualConstantInt(ofr, 0);
+      });
+    }
   }];
 
   let builders = [


        


More information about the Mlir-commits mailing list