@@ -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">,
@@ -232,50 +235,6 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> {
232235 "FailureOr<SmallVector<SmallVector<Value>>>",
233236 "getOffsets",
234237 (ins "OpBuilder &": $builder, "Location":$loc, "Value":$linearId, "ArrayRef<int64_t>":$shape)>,
235- InterfaceMethod</*desc=*/[{Check if this layout can be achieved by applying a transpose
236- to some other layout according to given permutation of (0...n-1).}],
237- /*retTy=*/"bool",
238- /*methodName=*/"isTransposeOf",
239- /*args=*/(ins "const xegpu::DistributeLayoutAttr&": $other, "ArrayRef<int64_t>": $perm),
240- /*methodBody=*/[{
241- if (!other)
242- return false;
243- if ($_self.getRank() != other.getRank() || perm.size() != static_cast<size_t>($_self.getRank()))
244- return false;
245- // check if the permutation is valid
246- int64_t rank = $_self.getRank();
247- SmallVector<bool, 8> seen(rank, false);
248- for (const auto &ta : llvm::enumerate(perm)) {
249- if (ta.value() < 0 || ta.value() >= rank)
250- return false;
251- if (seen[ta.value()])
252- return false;
253- seen[ta.value()] = true;
254- }
255- auto checkTranspose = [](ArrayRef<int64_t> dst, ArrayRef<int64_t> src, ArrayRef<int64_t> perm) {
256- for (const auto &ta : llvm::enumerate(perm)) {
257- if (src[ta.index()] != dst[ta.value()])
258- return false;
259- }
260- return true;
261- };
262- // check sgLayout
263- if (!checkTranspose($_self.getSgLayoutAsInt(), other.getSgLayoutAsInt(), perm))
264- return false;
265- // check sgData
266- if (!checkTranspose($_self.getSgDataAsInt(), other.getSgDataAsInt(), perm))
267- return false;
268- // check instData
269- if (!checkTranspose($_self.getInstDataAsInt(), other.getInstDataAsInt(), perm))
270- return false;
271- // check laneLayout
272- if (!checkTranspose($_self.getLaneLayoutAsInt(), other.getLaneLayoutAsInt(), perm))
273- return false;
274- // check laneData
275- if (!checkTranspose($_self.getLaneDataAsInt(), other.getLaneDataAsInt(), perm))
276- return false;
277- return true;
278- }]>,
279238 InterfaceMethod</*desc=*/[{Check if this layout is a slice of some other layout.}],
280239 /*retTy=*/"bool",
281240 /*methodName=*/"isSliceOf",
@@ -439,31 +398,31 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttr]> {
439398 getLaneLayout(), getLaneData(), getOrder());
440399 }
441400
442- SmallVector<int64_t> getSgLayoutAsInt () const {
401+ SmallVector<int64_t> getEffectiveSgLayoutAsInt () const {
443402 if (DenseI32ArrayAttr layout = getSgLayout())
444403 return llvm::to_vector_of<int64_t>(layout.asArrayRef());
445404 return {};
446405 }
447406
448- SmallVector<int64_t> getSgDataAsInt () const {
407+ SmallVector<int64_t> getEffectiveSgDataAsInt () const {
449408 if (DenseI32ArrayAttr data = getSgData())
450409 return llvm::to_vector_of<int64_t>(data.asArrayRef());
451410 return {};
452411 }
453412
454- SmallVector<int64_t> getInstDataAsInt () const {
413+ SmallVector<int64_t> getEffectiveInstDataAsInt () const {
455414 if (DenseI32ArrayAttr inst = getInstData())
456415 return llvm::to_vector_of<int64_t>(inst.asArrayRef());
457416 return {};
458417 }
459418
460- SmallVector<int64_t> getLaneLayoutAsInt () const {
419+ SmallVector<int64_t> getEffectiveLaneLayoutAsInt () const {
461420 if (DenseI32ArrayAttr layout = getLaneLayout())
462421 return llvm::to_vector_of<int64_t>(layout.asArrayRef());
463422 return {};
464423 }
465424
466- SmallVector<int64_t> getLaneDataAsInt () const {
425+ SmallVector<int64_t> getEffectiveLaneDataAsInt () const {
467426 if (DenseI32ArrayAttr data = getLaneData())
468427 return llvm::to_vector_of<int64_t>(data.asArrayRef());
469428 return {};
@@ -550,10 +509,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
550509
551510 /// Returns the SgLayout of the attribute, computed by applying
552511 /// the slice dimensions to the underlying LayoutAttr.
553- SmallVector<int64_t> getSgLayoutAsInt () const {
512+ SmallVector<int64_t> getEffectiveSgLayoutAsInt () const {
554513 SliceAttr attr = flatten();
555514 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
556- auto layout = parent.getSgLayoutAsInt ();
515+ auto layout = parent.getEffectiveSgLayoutAsInt ();
557516 if (layout.size()) {
558517 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
559518 return XeGPUDialect::slice(ArrayRef<int64_t>(layout), dims);
@@ -563,10 +522,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
563522
564523 /// Returns the SgData of the attribute, computed by applying
565524 /// the slice dimensions to the underlying LayoutAttr.
566- SmallVector<int64_t> getSgDataAsInt () const {
525+ SmallVector<int64_t> getEffectiveSgDataAsInt () const {
567526 SliceAttr attr = flatten();
568527 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
569- auto data = parent.getSgDataAsInt ();
528+ auto data = parent.getEffectiveSgDataAsInt ();
570529 if (data.size()) {
571530 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
572531 return XeGPUDialect::slice(ArrayRef<int64_t>(data), dims);
@@ -576,10 +535,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
576535
577536 /// Returns the InstData of the attribute, computed by applying
578537 /// the slice dimensions to the underlying LayoutAttr.
579- SmallVector<int64_t> getInstDataAsInt () const {
538+ SmallVector<int64_t> getEffectiveInstDataAsInt () const {
580539 SliceAttr attr = flatten();
581540 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
582- auto inst = parent.getInstDataAsInt ();
541+ auto inst = parent.getEffectiveInstDataAsInt ();
583542 if (inst.size()) {
584543 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
585544 return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(inst), dims);
@@ -589,10 +548,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
589548
590549 /// Returns the LaneLayout of the attribute, computed by applying
591550 /// the slice dimensions to the underlying LayoutAttr.
592- SmallVector<int64_t> getLaneLayoutAsInt () const {
551+ SmallVector<int64_t> getEffectiveLaneLayoutAsInt () const {
593552 SliceAttr attr = flatten();
594553 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
595- auto layout = parent.getLaneLayoutAsInt ();
554+ auto layout = parent.getEffectiveLaneLayoutAsInt ();
596555 if (layout.size()) {
597556 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
598557 return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(layout), dims);
@@ -602,10 +561,10 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
602561
603562 /// Returns the LaneData of the attribute, computed by applying
604563 /// the slice dimensions to the underlying LayoutAttr.
605- SmallVector<int64_t> getLaneDataAsInt () const {
564+ SmallVector<int64_t> getEffectiveLaneDataAsInt () const {
606565 SliceAttr attr = flatten();
607566 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
608- auto data = parent.getLaneDataAsInt ();
567+ auto data = parent.getEffectiveLaneDataAsInt ();
609568 if (data.size()) {
610569 ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
611570 return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(data), dims);
0 commit comments