[Mlir-commits] [mlir] [MLIR] Add shape propagation through tensor.pad (PR #136681)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jul 16 06:41:14 PDT 2025
================
@@ -1100,6 +1102,267 @@ class FoldPadWithProducerReshapeOpByExpansion
ControlFusionFn controlFoldingReshapes;
};
+bool isZero(OpFoldResult value) {
+ if (auto attr = dyn_cast<Attribute>(value)) {
+ if (auto intAttr = dyn_cast<IntegerAttr>(attr))
+ return intAttr.getInt() == 0;
+ }
+ if (auto val = dyn_cast<Value>(value)) {
+ if (auto constOp = val.getDefiningOp<arith::ConstantOp>()) {
+ if (auto attr = dyn_cast<IntegerAttr>(constOp.getValue()))
+ return attr.getInt() == 0;
+ }
+ }
+ return false;
+}
----------------
Max191 wrote:
You can use `isConstantIntValue(value, 0)` for this:
https://github.com/llvm/llvm-project/blob/88a498c3b110b73c10362df8c18ca13fe1873744/mlir/lib/Dialect/Utils/StaticValueUtils.cpp#L144-L146
https://github.com/llvm/llvm-project/pull/136681
More information about the Mlir-commits
mailing list