[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
This commit is contained in:
Matthias Springer 2021-06-07 20:13:08 +09:00
parent 8344e215ec
commit fe0befb123
1 changed files with 12 additions and 0 deletions

View File

@ -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 = [