[Mlir-commits] [mlir] [MLIR][XeGPU] Refactor layout propagation utilities (PR #179016)

Jianhui Li llvmlistbot at llvm.org
Tue Feb 3 21:54:00 PST 2026


================
@@ -471,6 +468,152 @@ LayoutAttr::setUnitDimLayout(SetVector<int64_t> unitDims) const {
       getLaneData(), getOrder());
 }
 
+// Derive a new layout with sg_data, inst_data and lane_data set to the
+// specified values for the given dimension
+DistributeLayoutAttr LayoutAttr::setDimData(int64_t dim, int64_t sgData,
+                                            int64_t instData,
+                                            int64_t laneData) {
+
+  SmallVector<int64_t> sgDataVec = getEffectiveSgDataAsInt();
+  SmallVector<int64_t> instDataVec = getEffectiveInstDataAsInt();
+  SmallVector<int64_t> laneDataVec = getEffectiveLaneDataAsInt();
+
+  if (dim < static_cast<int64_t>(sgDataVec.size()) && sgData != -1)
+    sgDataVec[dim] = sgData;
+  if (dim < static_cast<int64_t>(instDataVec.size()) && instData != -1)
+    instDataVec[dim] = instData;
+  if (dim < static_cast<int64_t>(laneDataVec.size()) && laneData != -1)
+    laneDataVec[dim] = laneData;
+
+  SmallVector<int32_t> sgDataVec32(sgDataVec.begin(), sgDataVec.end());
----------------
Jianhui-Li wrote:

Do you know why getEffectiveSgDataAsInt() returns vector of int64_t. It has been annoying. 

SmallVector<int64_t> sgDataVec = getEffectiveSgDataAsInt();

https://github.com/llvm/llvm-project/pull/179016


More information about the Mlir-commits mailing list