@@ -194,26 +194,29 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> {
194
194
InterfaceMethod<"Get the num of effective subgroups",
195
195
"int64_t",
196
196
"getNumSubgroups", (ins), [{
197
- std::optional<SmallVector<int64_t>> sgLayout = llvm::cast<ConcreteAttr>(tablegen_opaque_val).getSgLayoutAsInt ();
197
+ std::optional<SmallVector<int64_t>> sgLayout = llvm::cast<ConcreteAttr>(tablegen_opaque_val).getEffectiveSgLayoutAsInt ();
198
198
if (sgLayout.has_value())
199
199
return computeProduct(*sgLayout);
200
200
return 0;
201
201
}], [{}]>,
202
- InterfaceMethod<"Get the SgLayout field of the attribute as integer array",
202
+ InterfaceMethod<"Get the order of the layout attribute",
203
+ "DenseI32ArrayAttr",
204
+ "getOrder">,
205
+ InterfaceMethod<"Get the effective SgLayout of the layout attribute as integer array",
203
206
"SmallVector<int64_t>",
204
- "getSgLayoutAsInt ">,
205
- InterfaceMethod<"Get the SgData field of the attribute as integer array",
207
+ "getEffectiveSgLayoutAsInt ">,
208
+ InterfaceMethod<"Get the effective SgData of the layout attribute as integer array",
206
209
"SmallVector<int64_t>",
207
- "getSgDataAsInt ">,
208
- InterfaceMethod<"Get the InstData field of the attribute as integer array",
210
+ "getEffectiveSgDataAsInt ">,
211
+ InterfaceMethod<"Get the effective InstData of the layout attribute as integer array",
209
212
"SmallVector<int64_t>",
210
- "getInstDataAsInt ">,
211
- InterfaceMethod<"Get the LaneLayout field of the attribute as integer array",
213
+ "getEffectiveInstDataAsInt ">,
214
+ InterfaceMethod<"Get the effective LaneLayout of the layout attribute as integer array",
212
215
"SmallVector<int64_t>",
213
- "getLaneLayoutAsInt ">,
214
- InterfaceMethod<"Get the LaneData field of the attribute as integer array",
216
+ "getEffectiveLaneLayoutAsInt ">,
217
+ InterfaceMethod<"Get the effective LaneData of the layout attribute as integer array",
215
218
"SmallVector<int64_t>",
216
- "getLaneDataAsInt ">,
219
+ "getEffectiveLaneDataAsInt ">,
217
220
InterfaceMethod<"Derive a new layout by dropping sgLayout and sgData",
218
221
"xegpu::DistributeLayoutAttr",
219
222
"dropSgLayoutAndData">,
@@ -231,7 +234,11 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> {
231
234
multiple blocks according to round-robin distribution rules.}],
232
235
"FailureOr<SmallVector<SmallVector<Value>>>",
233
236
"getOffsets",
234
- (ins "OpBuilder &": $builder, "Location":$loc, "Value":$linearId, "ArrayRef<int64_t>":$shape)>
237
+ (ins "OpBuilder &": $builder, "Location":$loc, "Value":$linearId, "ArrayRef<int64_t>":$shape)>,
238
+ InterfaceMethod</*desc=*/[{Check if this layout is a slice of some other layout.}],
239
+ /*retTy=*/"bool",
240
+ /*methodName=*/"isSliceOf",
241
+ /*args=*/(ins "const xegpu::DistributeLayoutAttr&": $other)>
235
242
];
236
243
}
237
244
@@ -391,31 +398,31 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttr]> {
391
398
getLaneLayout(), getLaneData(), getOrder());
392
399
}
393
400
394
- SmallVector<int64_t> getSgLayoutAsInt () const {
401
+ SmallVector<int64_t> getEffectiveSgLayoutAsInt () const {
395
402
if (DenseI32ArrayAttr layout = getSgLayout())
396
403
return llvm::to_vector_of<int64_t>(layout.asArrayRef());
397
404
return {};
398
405
}
399
406
400
- SmallVector<int64_t> getSgDataAsInt () const {
407
+ SmallVector<int64_t> getEffectiveSgDataAsInt () const {
401
408
if (DenseI32ArrayAttr data = getSgData())
402
409
return llvm::to_vector_of<int64_t>(data.asArrayRef());
403
410
return {};
404
411
}
405
412
406
- SmallVector<int64_t> getInstDataAsInt () const {
413
+ SmallVector<int64_t> getEffectiveInstDataAsInt () const {
407
414
if (DenseI32ArrayAttr inst = getInstData())
408
415
return llvm::to_vector_of<int64_t>(inst.asArrayRef());
409
416
return {};
410
417
}
411
418
412
- SmallVector<int64_t> getLaneLayoutAsInt () const {
419
+ SmallVector<int64_t> getEffectiveLaneLayoutAsInt () const {
413
420
if (DenseI32ArrayAttr layout = getLaneLayout())
414
421
return llvm::to_vector_of<int64_t>(layout.asArrayRef());
415
422
return {};
416
423
}
417
424
418
- SmallVector<int64_t> getLaneDataAsInt () const {
425
+ SmallVector<int64_t> getEffectiveLaneDataAsInt () const {
419
426
if (DenseI32ArrayAttr data = getLaneData())
420
427
return llvm::to_vector_of<int64_t>(data.asArrayRef());
421
428
return {};
@@ -433,6 +440,9 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttr]> {
433
440
FailureOr<SmallVector<SmallVector<Value>>>
434
441
getOffsets(OpBuilder &builder, Location loc, Value linearId, ArrayRef<int64_t> shape);
435
442
443
+ /// Check if this is slice of some other layout.
444
+ bool isSliceOf(const xegpu::DistributeLayoutAttr &other) { return false; }
445
+
436
446
}];
437
447
438
448
let assemblyFormat = "`<` struct(params) `>`";
@@ -499,10 +509,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
499
509
500
510
/// Returns the SgLayout of the attribute, computed by applying
501
511
/// the slice dimensions to the underlying LayoutAttr.
502
- SmallVector<int64_t> getSgLayoutAsInt () const {
512
+ SmallVector<int64_t> getEffectiveSgLayoutAsInt () const {
503
513
SliceAttr attr = flatten();
504
514
auto parent = dyn_cast<LayoutAttr>(attr.getParent());
505
- auto layout = parent.getSgLayoutAsInt ();
515
+ auto layout = parent.getEffectiveSgLayoutAsInt ();
506
516
if (layout.size()) {
507
517
ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
508
518
return XeGPUDialect::slice(ArrayRef<int64_t>(layout), dims);
@@ -512,10 +522,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
512
522
513
523
/// Returns the SgData of the attribute, computed by applying
514
524
/// the slice dimensions to the underlying LayoutAttr.
515
- SmallVector<int64_t> getSgDataAsInt () const {
525
+ SmallVector<int64_t> getEffectiveSgDataAsInt () const {
516
526
SliceAttr attr = flatten();
517
527
auto parent = dyn_cast<LayoutAttr>(attr.getParent());
518
- auto data = parent.getSgDataAsInt ();
528
+ auto data = parent.getEffectiveSgDataAsInt ();
519
529
if (data.size()) {
520
530
ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
521
531
return XeGPUDialect::slice(ArrayRef<int64_t>(data), dims);
@@ -525,10 +535,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
525
535
526
536
/// Returns the InstData of the attribute, computed by applying
527
537
/// the slice dimensions to the underlying LayoutAttr.
528
- SmallVector<int64_t> getInstDataAsInt () const {
538
+ SmallVector<int64_t> getEffectiveInstDataAsInt () const {
529
539
SliceAttr attr = flatten();
530
540
auto parent = dyn_cast<LayoutAttr>(attr.getParent());
531
- auto inst = parent.getInstDataAsInt ();
541
+ auto inst = parent.getEffectiveInstDataAsInt ();
532
542
if (inst.size()) {
533
543
ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
534
544
return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(inst), dims);
@@ -538,10 +548,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
538
548
539
549
/// Returns the LaneLayout of the attribute, computed by applying
540
550
/// the slice dimensions to the underlying LayoutAttr.
541
- SmallVector<int64_t> getLaneLayoutAsInt () const {
551
+ SmallVector<int64_t> getEffectiveLaneLayoutAsInt () const {
542
552
SliceAttr attr = flatten();
543
553
auto parent = dyn_cast<LayoutAttr>(attr.getParent());
544
- auto layout = parent.getLaneLayoutAsInt ();
554
+ auto layout = parent.getEffectiveLaneLayoutAsInt ();
545
555
if (layout.size()) {
546
556
ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
547
557
return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(layout), dims);
@@ -551,10 +561,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
551
561
552
562
/// Returns the LaneData of the attribute, computed by applying
553
563
/// the slice dimensions to the underlying LayoutAttr.
554
- SmallVector<int64_t> getLaneDataAsInt () const {
564
+ SmallVector<int64_t> getEffectiveLaneDataAsInt () const {
555
565
SliceAttr attr = flatten();
556
566
auto parent = dyn_cast<LayoutAttr>(attr.getParent());
557
- auto data = parent.getLaneDataAsInt ();
567
+ auto data = parent.getEffectiveLaneDataAsInt ();
558
568
if (data.size()) {
559
569
ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
560
570
return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(data), dims);
@@ -594,6 +604,9 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
594
604
FailureOr<SmallVector<SmallVector<Value>>>
595
605
getOffsets(OpBuilder &builder, Location loc, Value linearId, ArrayRef<int64_t> shape);
596
606
607
+ /// Check if this is slice of some other layout.
608
+ bool isSliceOf(const xegpu::DistributeLayoutAttr &other);
609
+
597
610
}];
598
611
599
612
let assemblyFormat = "`<` qualified($parent) `,` `dims` `=` $dims `>`";
0 commit comments