[Mlir-commits] [mlir] [MLIR][XeGPU] Enhance XeGPU lane layout to support "wrap-around" distribution (PR #186958)
Charitha Saumya
llvmlistbot at llvm.org
Thu Mar 19 10:48:22 PDT 2026
================
@@ -743,6 +795,45 @@ bool LayoutAttr::isTransposeOf(const xegpu::DistributeLayoutAttr &other,
return false;
}
+bool LayoutAttr::isCompatibleWith(const xegpu::DistributeLayoutAttr &other,
+ SmallVector<int64_t> shape,
+ xegpu::LayoutKind level) {
+ if (!other)
+ return false;
+ if (getEffectiveOrderAsInt() == other.getEffectiveOrderAsInt()) {
+ if (level == xegpu::LayoutKind::Subgroup)
+ return (getEffectiveSgLayoutAsInt() ==
+ other.getEffectiveSgLayoutAsInt() &&
+ getEffectiveSgDataAsInt() == other.getEffectiveSgDataAsInt());
+ if (level == xegpu::LayoutKind::Lane)
+ return (getEffectiveLaneLayoutAsInt() ==
+ other.getEffectiveLaneLayoutAsInt() &&
+ getEffectiveLaneDataAsInt() == other.getEffectiveLaneDataAsInt());
+ }
+ if (level == xegpu::LayoutKind::Subgroup) {
+ int64_t wgSize = computeProduct(getEffectiveSgLayoutAsInt());
+ for (int64_t id : llvm::seq<int64_t>(0, wgSize)) {
+ auto coords = computeStaticDistributedCoords(id, shape);
+ auto otherCoords = other.computeStaticDistributedCoords(id, shape);
+ if (coords != otherCoords)
+ return false;
+ }
+ }
+ if (level == xegpu::LayoutKind::InstData) {
+ return (getEffectiveInstDataAsInt() == other.getEffectiveInstDataAsInt());
+ }
+ if (level == xegpu::LayoutKind::Lane) {
+ int64_t subgroupSize = computeProduct(getEffectiveLaneLayoutAsInt());
----------------
charithaintc wrote:
for wrap-around layouts would this `computeProduct` still give the subgroup size correctly?
https://github.com/llvm/llvm-project/pull/186958
More information about the Mlir-commits
mailing list