[Mlir-commits] [mlir] [mlir][xegpu] Add support for `vector.multi_reduction` and `vector.shape_cast` SIMT distribution. (PR #157560)
Charitha Saumya
llvmlistbot at llvm.org
Tue Sep 9 11:20:49 PDT 2025
================
@@ -72,27 +99,30 @@ namespace {
/// | 32x16 | [2, 8] | 16x2 |
/// | 2x32x16 | [1, 16] | 2x32x1 |
static FailureOr<VectorType>
-getDistVecTypeBasedOnLaneLayout(xegpu::LayoutAttr layout,
+getDistVecTypeBasedOnLaneLayout(xegpu::DistributeLayoutAttr layout,
VectorType originalType) {
if (!layout)
return failure();
+ assert((isa<xegpu::LayoutAttr>(layout) || isa<xegpu::SliceAttr>(layout)) &&
+ "Expecting a valid layout.");
+ SmallVector<int64_t> effectiveLaneLayout = computeEffectiveLaneLayout(layout);
- auto laneLayout = layout.getLaneLayout().asArrayRef();
- assert(originalType.getShape().size() >= laneLayout.size() &&
+ assert(originalType.getShape().size() >= effectiveLaneLayout.size() &&
"Rank of the original vector type should be greater or equal to the "
"size of the lane layout to distribute the vector type.");
SmallVector<int64_t> distributedShape(originalType.getShape());
// Only distribute the last `laneLayout.size()` dimensions. The remaining
// dimensions are not distributed.
- unsigned distributionStart = originalType.getRank() - laneLayout.size();
+ unsigned distributionStart =
+ originalType.getRank() - effectiveLaneLayout.size();
for (auto [i, dim] : llvm::enumerate(originalType.getShape())) {
if (i < distributionStart)
continue;
// Check if the dimension can be distributed evenly.
- if (dim % laneLayout[i - distributionStart] != 0)
+ if (dim % effectiveLaneLayout[i - distributionStart] != 0)
----------------
charithaintc wrote:
calling this function for such cases will result in failure. caller (i.e. pattern) should handle the error and decide how to proceed.
https://github.com/llvm/llvm-project/pull/157560
More information about the Mlir-commits
mailing list