Skip to content

Commit ce07282

Browse files
committed
rename isWgLayout to isForWorkgroup
1 parent 93acad2 commit ce07282

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

mlir/include/mlir/Dialect/XeGPU/IR/XeGPUAttrs.td

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def DistributeLayoutAttrInterface: AttrInterface<"DistributeLayoutAttrInterface"
184184
let methods = [
185185
InterfaceMethod<"Check the availability of workgroup level layouts",
186186
"bool",
187-
"isWgLayout">,
187+
"isForWorkgroup">,
188188
InterfaceMethod<"Get the rank of attribute",
189189
"int64_t",
190190
"getRank">,
@@ -337,12 +337,12 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttrInterf
337337
];
338338

339339
let extraClassDeclaration = [{
340-
bool isWgLayout() {
340+
bool isForWorkgroup() {
341341
return getSgLayout() != nullptr;
342342
}
343343

344-
bool isSgLayout() {
345-
return !isWgLayout();
344+
bool isForSubgroup() {
345+
return !isForWorkgroup();
346346
}
347347

348348
int64_t getRank() {
@@ -454,16 +454,16 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttrInterface
454454
return parent.getOrder();
455455
}
456456

457-
bool isWgLayout() const {
457+
bool isForWorkgroup() const {
458458
SliceAttr attr = flatten();
459459
auto parent = dyn_cast<LayoutAttr>(attr.getParent());
460-
return parent.isWgLayout();
460+
return parent.isForWorkgroup();
461461
}
462462

463-
bool isSgLayout() const {
463+
bool isForSubgroup() const {
464464
SliceAttr attr = flatten();
465465
auto parent = dyn_cast<LayoutAttr>(attr.getParent());
466-
return parent.isSgLayout();
466+
return parent.isForSubgroup();
467467
}
468468

469469
int64_t getNumSubgroups() {

mlir/lib/Dialect/XeGPU/IR/XeGPUDialect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ LayoutAttr::delinearizeSubgroupId(OpBuilder &builder, Location loc,
271271
Value linearId) {
272272
// delinearizeSubgroupId is only available for
273273
// workgroup-level layout attribute
274-
if (!isWgLayout())
274+
if (!isForWorkgroup())
275275
return failure();
276276

277277
// TODO: handle order attribute
@@ -296,7 +296,7 @@ LayoutAttr::delinearizeSubgroupId(OpBuilder &builder, Location loc,
296296
FailureOr<SmallVector<SmallVector<Value>>>
297297
LayoutAttr::getOffsets(OpBuilder &builder, Location loc, Value linearId,
298298
ArrayRef<int64_t> shape) {
299-
if (!isWgLayout())
299+
if (!isForWorkgroup())
300300
return failure();
301301

302302
SmallVector<int64_t> sgLayout = getSgLayoutAsInt().value();
@@ -384,7 +384,7 @@ FailureOr<SmallVector<SmallVector<Value>>>
384384
SliceAttr::getOffsets(OpBuilder &builder, Location loc, Value linearId,
385385
ArrayRef<int64_t> shape) {
386386
assert(getRank() == static_cast<int64_t>(shape.size()) && "invalid shape.");
387-
if (!isWgLayout())
387+
if (!isForWorkgroup())
388388
return failure();
389389

390390
SmallVector<int64_t> sgLayout = getSgLayoutAsInt().value();

mlir/lib/Dialect/XeGPU/IR/XeGPUOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,8 @@ LogicalResult ConvertLayoutOp::verify() {
938938

939939
// both input and target layouts should be WgLayout or SgLayout at the same
940940
// time.
941-
if ((!srcLayout.isWgLayout() || !resLayout.isWgLayout()) &&
942-
(!srcLayout.isSgLayout() || !resLayout.isSgLayout()))
941+
if ((!srcLayout.isForWorkgroup() || !resLayout.isForWorkgroup()) &&
942+
(!srcLayout.isForSubgroup() || !resLayout.isForSubgroup()))
943943
return emitOpError("expected input layout and target layout be WgLayout or "
944944
"SgLayout at the same time.");
945945

mlir/lib/Dialect/XeGPU/Transforms/XeGPUBlocking.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ XeGPUBlockingPass::getTileShape(const T &operandOrResult) const {
141141
value = (Value)operandOrResult;
142142

143143
xegpu::LayoutAttr layout = xegpu::getLayoutAttr(operandOrResult);
144-
if (layout && layout.isSgLayout()) {
144+
if (layout && layout.isForSubgroup()) {
145145
if (auto inst_data = layout.getInstData())
146146
return llvm::to_vector_of<int64_t>(inst_data.asArrayRef());
147147

@@ -205,12 +205,12 @@ bool XeGPUBlockingPass::needsUnroll(Operation *op) const {
205205
bool hasWgLayoutOperands =
206206
llvm::any_of(op->getOpOperands(), [](OpOperand &opr) {
207207
xegpu::LayoutAttr layout = xegpu::getLayoutAttr(opr);
208-
return layout && layout.isWgLayout();
208+
return layout && layout.isForWorkgroup();
209209
});
210210
bool hasWgLayoutResults =
211211
llvm::any_of(op->getOpResults(), [](OpResult result) {
212212
xegpu::LayoutAttr layout = xegpu::getLayoutAttr(result);
213-
return layout && layout.isWgLayout();
213+
return layout && layout.isForWorkgroup();
214214
});
215215
if (hasWgLayoutOperands || hasWgLayoutResults) {
216216
LDBG() << "skip unrolling for op with workgroup level layout: " << *op;
@@ -272,7 +272,7 @@ void XeGPUBlockingPass::runOnOperation() {
272272

273273
auto layout =
274274
llvm::dyn_cast_if_present<xegpu::LayoutAttr>(type.getEncoding());
275-
if (layout && layout.isWgLayout())
275+
if (layout && layout.isForWorkgroup())
276276
return failure();
277277

278278
int count;
@@ -289,7 +289,7 @@ void XeGPUBlockingPass::runOnOperation() {
289289
ArrayRef<int64_t> shape = type.getShape();
290290

291291
xegpu::LayoutAttr layout = type.getLayoutAttr();
292-
if (layout && layout.isWgLayout())
292+
if (layout && layout.isForWorkgroup())
293293
return failure();
294294

295295
int count;

mlir/lib/Dialect/XeGPU/Transforms/XeGPUWgToSgDistribute.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ getSgShapeAndCount(ArrayRef<int64_t> shape,
5959
xegpu::DistributeLayoutAttrInterface layout) {
6060
int count = 1;
6161
SmallVector<int64_t> sgShape(shape);
62-
if (layout && layout.isWgLayout()) {
62+
if (layout && layout.isForWorkgroup()) {
6363
SmallVector<int64_t> sgLayout = layout.getSgLayoutAsInt().value();
6464
if (auto maybeSgData = layout.getSgDataAsInt())
6565
sgShape = *maybeSgData;
@@ -115,7 +115,7 @@ genOffsetsList(ConversionPatternRewriter &rewriter, OpType op,
115115

116116
// not applicable to ops without workgroup layout attributes
117117
xegpu::DistributeLayoutAttrInterface layout = op.getLayoutAttr();
118-
if (!layout || !layout.isWgLayout())
118+
if (!layout || !layout.isForWorkgroup())
119119
return failure();
120120

121121
Value sgId = rewriter.create<gpu::SubgroupIdOp>(loc, /*upper_bound=*/nullptr);
@@ -249,7 +249,7 @@ struct WgToSgCreateNdOpNoOffset
249249
MLIRContext *ctx = op.getContext();
250250
xegpu::TensorDescType tdescTy = op.getType();
251251
auto layout = dyn_cast<xegpu::LayoutAttr>(tdescTy.getLayout());
252-
if (!layout || !layout.isWgLayout())
252+
if (!layout || !layout.isForWorkgroup())
253253
return failure();
254254

255255
Type elemTy = tdescTy.getElementType();
@@ -637,7 +637,8 @@ struct WgToSgConvertLayoutOp
637637
xegpu::LayoutAttr input = op.getInputLayout();
638638
xegpu::LayoutAttr target = op.getTargetLayout();
639639

640-
if (!input || !target || !input.isWgLayout() || !target.isWgLayout())
640+
if (!input || !target || !input.isForWorkgroup() ||
641+
!target.isForWorkgroup())
641642
return rewriter.notifyMatchFailure(
642643
op, "Input and target layouts must have subgroup layout");
643644

@@ -938,7 +939,7 @@ void XeGPUWgToSgDistributePass::runOnOperation() {
938939
};
939940

940941
auto isLegal = [&](xegpu::DistributeLayoutAttrInterface layout) -> bool {
941-
return !layout || !layout.isWgLayout();
942+
return !layout || !layout.isForWorkgroup();
942943
};
943944

944945
target.addDynamicallyLegalOp<xegpu::CreateNdDescOp, xegpu::LoadNdOp,

mlir/lib/Dialect/XeGPU/Utils/XeGPUUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mlir::xegpu::getDistributedVectorType(xegpu::TensorDescType tdescTy) {
4040
auto layout = llvm::dyn_cast_if_present<LayoutAttr>(tdescTy.getLayout());
4141
// It only works for subgroup level layout, which only has lane_layout
4242
// and lane_data, and is to distribute a SIMD code into SIMT code.
43-
if (!layout || !layout.isSgLayout())
43+
if (!layout || !layout.isForSubgroup())
4444
return failure();
4545

4646
SmallVector<int64_t> laneData(layout.getLaneData().asArrayRef());

mlir/test/lib/Dialect/XeGPU/TestXeGPUTransforms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct TestXeGPUUnrollingPatterns
8282

8383
if (auto layout = tdescTy.getLayoutAttr()) {
8484
auto inst_data = layout.getInstData();
85-
if (inst_data && layout.isSgLayout())
85+
if (inst_data && layout.isForSubgroup())
8686
return SmallVector<int64_t>(inst_data.asArrayRef().begin(),
8787
inst_data.asArrayRef().end());
8888
}
@@ -239,7 +239,7 @@ struct TestXeGPULayoutInterface
239239

240240
ConversionTarget target(*ctx);
241241
auto isLegal = [&](xegpu::SliceAttr layout) -> bool {
242-
return !layout || !layout.isWgLayout();
242+
return !layout || !layout.isForWorkgroup();
243243
};
244244

245245
target.addDynamicallyLegalOp<vector::StepOp>(

0 commit comments

Comments
 (0)