[Mlir-commits] [mlir] [MLIR][XeGPU] Extend propagation and sg_to_lane distribution pass support broadcast with low rank and scalar source input (PR #170409)
Charitha Saumya
llvmlistbot at llvm.org
Wed Dec 3 15:27:25 PST 2025
================
@@ -581,16 +581,37 @@ void LayoutInfoPropagation::visitVectorBroadCastOp(
// Only consider vector to vector broadcasts for now.
VectorType resultTy = broadcast.getResultVectorType();
VectorType sourceTy = dyn_cast<VectorType>(broadcast.getSourceType());
- if (!sourceTy) {
- broadcast.emitWarning("Expecting source type to be a vector type.");
+ // skip layout propagation for non-vector source operand.
+ if (!sourceTy)
return;
- }
- // Only consider nD -> nD broadcast.
+ // Hanlding broadcast from low-rank to high-rank (e.g., 1D to 2D) case.
if (sourceTy.getRank() != resultTy.getRank()) {
- broadcast.emitWarning("Expecting source and result to have same rank.");
+ auto sourceDims = sourceTy.getShape();
+ auto resultDims = resultTy.getShape();
+ // adding the missing leading missing dims
+ SmallVector<int64_t> bcastDims;
+ int64_t dimDiff = resultTy.getRank() - sourceTy.getRank();
+ for (int i = 0; i < dimDiff; i++) {
+ bcastDims.push_back(i);
+ }
+
+ // for the rest dims in the resultTy, if sourceTy dim is 1, then it's
+ // broadcasted dim
+ for (size_t i = 0; i < sourceDims.size(); i++) {
+ if ((sourceDims[i] == 1) && (resultDims[i + dimDiff] != 1))
+ bcastDims.push_back(i + dimDiff);
+ }
+
+ // create a slice layout for the source
+ xegpu::SliceAttr sliceLayout = xegpu::SliceAttr::get(
+ broadcast->getContext(), cast<xegpu::LayoutAttr>(resultLayout.get()),
----------------
charithaintc wrote:
I think we should check if the result layout is a `LayoutAttr`. If not we should emit some error.
https://github.com/llvm/llvm-project/pull/170409
More information about the Mlir-commits
mailing list