diff --git a/mlir/lib/Dialect/XeGPU/Transforms/XeGPULayoutImpl.cpp b/mlir/lib/Dialect/XeGPU/Transforms/XeGPULayoutImpl.cpp index a4e47fca96d34..a6db4563faaa2 100644 --- a/mlir/lib/Dialect/XeGPU/Transforms/XeGPULayoutImpl.cpp +++ b/mlir/lib/Dialect/XeGPU/Transforms/XeGPULayoutImpl.cpp @@ -90,7 +90,7 @@ bool xegpu::recoverTemporaryLayouts(Operation *rootOp) { if (!isa(operand.get().getType())) continue; // Skip block arguments since they don't have defining ops to attach - // layout attributes to + // layout attributes to. if (isa(operand.get())) continue; auto layout = xegpu::getDistributeLayoutAttr(operand.get()); diff --git a/mlir/lib/Dialect/XeGPU/Transforms/XeGPUWgToSgDistribute.cpp b/mlir/lib/Dialect/XeGPU/Transforms/XeGPUWgToSgDistribute.cpp index cd6bc9ac4b8e0..566fb45f5bcb4 100644 --- a/mlir/lib/Dialect/XeGPU/Transforms/XeGPUWgToSgDistribute.cpp +++ b/mlir/lib/Dialect/XeGPU/Transforms/XeGPUWgToSgDistribute.cpp @@ -1847,4 +1847,18 @@ void XeGPUWgToSgDistributePass::runOnOperation() { if (failed( applyPartialConversion(getOperation(), target, std::move(patterns)))) return signalPassFailure(); + + // Remove layout attributes from SCF ops + getOperation()->walk([](Operation *op) { + if (!isa(op)) + return; + + SmallVector attrsToRemove; + for (auto namedAttr : op->getDiscardableAttrs()) { + if (isa(namedAttr.getValue())) + attrsToRemove.push_back(namedAttr.getName()); + } + for (auto attrName : attrsToRemove) + op->removeDiscardableAttr(attrName); + }); }