[Mlir-commits] [mlir] [mlir][vector] Relax the requirements on broadcast dims (PR #99341)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Thu Oct 3 02:21:32 PDT 2024
================
@@ -4138,22 +4134,42 @@ static LogicalResult foldTransferInBoundsAttribute(TransferOp op) {
bool changed = false;
SmallVector<bool, 4> newInBounds;
newInBounds.reserve(op.getTransferRank());
+ SmallVector<unsigned> nonBcastDims;
for (unsigned i = 0; i < op.getTransferRank(); ++i) {
- // Already marked as in-bounds, nothing to see here.
+ // 1. Already marked as in-bounds, nothing to see here.
if (op.isDimInBounds(i)) {
newInBounds.push_back(true);
continue;
}
- // Currently out-of-bounds, check whether we can statically determine it is
- // inBounds.
+ // 2. Currently out-of-bounds, check whether we can statically determine it
+ // is inBounds.
+ bool inBounds = false;
auto dimExpr = dyn_cast<AffineDimExpr>(permutationMap.getResult(i));
- assert(dimExpr && "Broadcast dims must be in-bounds");
- auto inBounds =
- isInBounds(op, /*resultIdx=*/i, /*indicesIdx=*/dimExpr.getPosition());
+ if (dimExpr) {
+ // 2.a Non-broadcast dim
+ inBounds = isInBounds(op, /*resultIdx=*/i,
+ /*indicesIdx=*/dimExpr.getPosition());
+ // 2.b Broadcast dims are handled after processing non-bcast dims
+ // FIXME: constant expr != 0 are not broadcasts - should such
+ // constants be allowed at all?
----------------
banach-space wrote:
Thanks! Looks like the Op verifier would reject such cases before we get here (so all good). I'll add relevant "invalid" cases to test/Dialect/Vector/invalid.mlir
https://github.com/llvm/llvm-project/pull/99341
More information about the Mlir-commits
mailing list