[Mlir-commits] [mlir] [mlir][tosa] Harden folds/canonicalizations for unranked and dynamic shapes (PR #188188)
Luke Hutton
llvmlistbot at llvm.org
Thu Mar 26 03:32:22 PDT 2026
================
@@ -946,6 +955,11 @@ binaryFolder(DenseElementsAttr lhs, DenseElementsAttr rhs, ShapedType returnTy,
if (!lhs || !rhs)
return {};
+ // DenseElementsAttr::get needs a static shape. Result types may be unranked
+ // (no RankedTensorType) or ranked-dynamic while operands are dense splats.
+ if (!returnTy || !returnTy.hasStaticShape())
----------------
lhutton1 wrote:
Casting an unranked tensor to a `ShapedType` will not result in `null`, better to check `!returnTy.hasRank() || !returnTy.hasStaticShape()` here
https://github.com/llvm/llvm-project/pull/188188
More information about the Mlir-commits
mailing list