[Mlir-commits] [mlir] [mlir][vector] Flatten transfer - support multi-dim scalar element (PR #185417)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Mon Mar 9 08:27:25 PDT 2026
================
@@ -835,11 +835,19 @@ class FlattenContiguousRowMajorTransferReadPattern
return failure();
}
+ // Determine vector dimensions to collapse.
+ // Ignore a leading sequence of adjacent unit dimensions in the vector.
+ ArrayRef<int64_t> collapsedVectorShape =
+ vectorType.getShape().drop_while([](auto v) { return v == 1; });
+ size_t collapsedVecRank = collapsedVectorShape.size();
+ // In case of a multi-dimensional scalar vector, restrict the shape collapse
+ // to a 1D vector.
----------------
banach-space wrote:
[ultra nit] To me, scalar != vector, so this comment feels a bit odd (though I totally know what you mean and also find it hard to phrase it better). In any case, I have two suggestions:
* "Collapse multi-dimensional unit vectors (e.g., <1x1x1x1xf32>) to a 1D single-element vector."
* "If a vector has only one element in every dimension, flatten it to a 1D vector of length 1."
https://github.com/llvm/llvm-project/pull/185417
More information about the Mlir-commits
mailing list