Skip to content

Commit e2f6eae

Browse files
nbpatelaokblast
authored andcommitted
[MLIR][XeGPU] Fix isEvenlyDistributable API in xegpu (llvm#164907)
1 parent e9e8833 commit e2f6eae

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

mlir/lib/Dialect/XeGPU/IR/XeGPUDialect.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,12 @@ bool XeGPUDialect::isEvenlyDistributable(llvm::ArrayRef<int64_t> shape,
113113
if (layout.size() != shape.size())
114114
return std::nullopt;
115115
auto ratio = computeShapeRatio(shape, layout);
116-
if (!ratio.has_value())
116+
if (ratio.has_value()) {
117+
newShape = ratio.value();
118+
} else if (!rr || !computeShapeRatio(layout, shape).has_value()) {
117119
return std::nullopt;
118-
newShape = ratio.value();
120+
}
121+
// Round-robin case: continue with original newShape
119122
}
120123

121124
if (data.size()) {

mlir/test/Dialect/XeGPU/xegpu-wg-to-sg-unify-ops.mlir

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,4 +527,11 @@ gpu.module @test_distribution {
527527
%cst_1 = arith.constant {layout_result_0 = #xegpu.layout<sg_layout = [32, 1], sg_data = [1, 16]>} dense<[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]> : vector<1x16xindex>
528528
gpu.return
529529
}
530+
531+
// CHECK-LABEL: scalar_broadcast
532+
gpu.func @scalar_broadcast(%arg0: index) {
533+
// CHECK: vector.broadcast {{.*}} : index to vector<1x1x1xindex>
534+
%broadcast = vector.broadcast %arg0 {layout_result_0 = #xegpu.layout<sg_layout = [4, 8, 1], sg_data = [1, 1, 1]>} : index to vector<4x1x1xindex>
535+
gpu.return
536+
}
530537
}

0 commit comments

Comments
 (0)