@@ -194,26 +194,29 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> {
194194 InterfaceMethod<"Get the num of effective subgroups",
195195 "int64_t",
196196 "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 ();
198198 if (sgLayout.has_value())
199199 return computeProduct(*sgLayout);
200200 return 0;
201201 }], [{}]>,
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",
203206 "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",
206209 "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",
209212 "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",
212215 "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",
215218 "SmallVector<int64_t>",
216- "getLaneDataAsInt ">,
219+ "getEffectiveLaneDataAsInt ">,
217220 InterfaceMethod<"Derive a new layout by dropping sgLayout and sgData",
218221 "xegpu::DistributeLayoutAttr",
219222 "dropSgLayoutAndData">,
@@ -231,7 +234,11 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> {
231234 multiple blocks according to round-robin distribution rules.}],
232235 "FailureOr<SmallVector<SmallVector<Value>>>",
233236 "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)>
235242 ];
236243}
237244
@@ -391,31 +398,31 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttr]> {
391398 getLaneLayout(), getLaneData(), getOrder());
392399 }
393400
394- SmallVector<int64_t> getSgLayoutAsInt () const {
401+ SmallVector<int64_t> getEffectiveSgLayoutAsInt () const {
395402 if (DenseI32ArrayAttr layout = getSgLayout())
396403 return llvm::to_vector_of<int64_t>(layout.asArrayRef());
397404 return {};
398405 }
399406
400- SmallVector<int64_t> getSgDataAsInt () const {
407+ SmallVector<int64_t> getEffectiveSgDataAsInt () const {
401408 if (DenseI32ArrayAttr data = getSgData())
402409 return llvm::to_vector_of<int64_t>(data.asArrayRef());
403410 return {};
404411 }
405412
406- SmallVector<int64_t> getInstDataAsInt () const {
413+ SmallVector<int64_t> getEffectiveInstDataAsInt () const {
407414 if (DenseI32ArrayAttr inst = getInstData())
408415 return llvm::to_vector_of<int64_t>(inst.asArrayRef());
409416 return {};
410417 }
411418
412- SmallVector<int64_t> getLaneLayoutAsInt () const {
419+ SmallVector<int64_t> getEffectiveLaneLayoutAsInt () const {
413420 if (DenseI32ArrayAttr layout = getLaneLayout())
414421 return llvm::to_vector_of<int64_t>(layout.asArrayRef());
415422 return {};
416423 }
417424
418- SmallVector<int64_t> getLaneDataAsInt () const {
425+ SmallVector<int64_t> getEffectiveLaneDataAsInt () const {
419426 if (DenseI32ArrayAttr data = getLaneData())
420427 return llvm::to_vector_of<int64_t>(data.asArrayRef());
421428 return {};
@@ -433,6 +440,9 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttr]> {
433440 FailureOr<SmallVector<SmallVector<Value>>>
434441 getOffsets(OpBuilder &builder, Location loc, Value linearId, ArrayRef<int64_t> shape);
435442
443+ /// Check if this is slice of some other layout.
444+ bool isSliceOf(const xegpu::DistributeLayoutAttr &other) { return false; }
445+
436446 }];
437447
438448 let assemblyFormat = "`<` struct(params) `>`";
@@ -499,10 +509,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
499509
500510 /// Returns the SgLayout of the attribute, computed by applying
501511 /// the slice dimensions to the underlying LayoutAttr.
502- SmallVector<int64_t> getSgLayoutAsInt () const {
512+ SmallVector<int64_t> getEffectiveSgLayoutAsInt () const {
503513 SliceAttr attr = flatten();
504514 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
505- auto layout = parent.getSgLayoutAsInt ();
515+ auto layout = parent.getEffectiveSgLayoutAsInt ();
506516 if (layout.size()) {
507517 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
508518 return XeGPUDialect::slice(ArrayRef<int64_t>(layout), dims);
@@ -512,10 +522,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
512522
513523 /// Returns the SgData of the attribute, computed by applying
514524 /// the slice dimensions to the underlying LayoutAttr.
515- SmallVector<int64_t> getSgDataAsInt () const {
525+ SmallVector<int64_t> getEffectiveSgDataAsInt () const {
516526 SliceAttr attr = flatten();
517527 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
518- auto data = parent.getSgDataAsInt ();
528+ auto data = parent.getEffectiveSgDataAsInt ();
519529 if (data.size()) {
520530 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
521531 return XeGPUDialect::slice(ArrayRef<int64_t>(data), dims);
@@ -525,10 +535,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
525535
526536 /// Returns the InstData of the attribute, computed by applying
527537 /// the slice dimensions to the underlying LayoutAttr.
528- SmallVector<int64_t> getInstDataAsInt () const {
538+ SmallVector<int64_t> getEffectiveInstDataAsInt () const {
529539 SliceAttr attr = flatten();
530540 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
531- auto inst = parent.getInstDataAsInt ();
541+ auto inst = parent.getEffectiveInstDataAsInt ();
532542 if (inst.size()) {
533543 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
534544 return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(inst), dims);
@@ -538,10 +548,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
538548
539549 /// Returns the LaneLayout of the attribute, computed by applying
540550 /// the slice dimensions to the underlying LayoutAttr.
541- SmallVector<int64_t> getLaneLayoutAsInt () const {
551+ SmallVector<int64_t> getEffectiveLaneLayoutAsInt () const {
542552 SliceAttr attr = flatten();
543553 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
544- auto layout = parent.getLaneLayoutAsInt ();
554+ auto layout = parent.getEffectiveLaneLayoutAsInt ();
545555 if (layout.size()) {
546556 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
547557 return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(layout), dims);
@@ -551,10 +561,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
551561
552562 /// Returns the LaneData of the attribute, computed by applying
553563 /// the slice dimensions to the underlying LayoutAttr.
554- SmallVector<int64_t> getLaneDataAsInt () const {
564+ SmallVector<int64_t> getEffectiveLaneDataAsInt () const {
555565 SliceAttr attr = flatten();
556566 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
557- auto data = parent.getLaneDataAsInt ();
567+ auto data = parent.getEffectiveLaneDataAsInt ();
558568 if (data.size()) {
559569 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
560570 return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(data), dims);
@@ -594,6 +604,9 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
594604 FailureOr<SmallVector<SmallVector<Value>>>
595605 getOffsets(OpBuilder &builder, Location loc, Value linearId, ArrayRef<int64_t> shape);
596606
607+ /// Check if this is slice of some other layout.
608+ bool isSliceOf(const xegpu::DistributeLayoutAttr &other);
609+
597610 }];
598611
599612 let assemblyFormat = "`<` qualified($parent) `,` `dims` `=` $dims `>`";
0 commit comments