[Mlir-commits] [clang-tools-extra] [mlir] [MLIR][XeGPU] Refactor Layout access interface (PR #172125)

Jianhui Li llvmlistbot at llvm.org
Tue Dec 16 11:50:53 PST 2025


================
@@ -218,55 +229,156 @@ maybePickPermanentLayout(xegpu::DistributeLayoutAttr layout,
   return candidate;
 }
 
-template <typename T, typename>
-void xegpu::setDistributeLayoutAttr(const T &operandOrResult,
-                                    const DistributeLayoutAttr layout,
-                                    bool respectPermLayout) {
-  Operation *owner = operandOrResult.getOwner();
-  std::string name = xegpu::getLayoutName(operandOrResult);
+// TODO-LayoutRefactor: Remove this function after replacing use
+//  with setTempLayout or setAnchorLayout
+void xegpu::setDistributeLayoutAttr(
+    const mlir::OpResult &result,
+    const mlir::xegpu::DistributeLayoutAttr layout) {
+  Operation *owner = result.getOwner();
 
-  if (owner->hasAttrOfType<DistributeLayoutAttr>(name))
+  if (auto anchorOp = dyn_cast<xegpu::AnchorLayoutInterface>(owner)) {
+    if (anchorOp.getAnchorLayout() == layout)
+      return;
+    anchorOp.setAnchorLayout(layout);
+    return;
+  }
+
+  std::string name = xegpu::getTempLayoutName(result);
+  if (owner->hasAttrOfType<DistributeLayoutAttr>(name)) {
+    return;
+  }
+  if (layout) {
----------------
Jianhui-Li wrote:

Not sure. Maybe just for convenience. The original code does so. Removing this causing exception. 

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


More information about the Mlir-commits mailing list