@@ -185,6 +185,9 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> {
185185 InterfaceMethod<"Check the availability of workgroup level layouts",
186186 "bool",
187187 "isForWorkgroup">,
188+ InterfaceMethod<"Check the availability of subgroup level layouts",
189+ "bool",
190+ "isForSubgroup">,
188191 InterfaceMethod<"Get the rank of attribute",
189192 "int64_t",
190193 "getRank">,
@@ -202,6 +205,15 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> {
202205 InterfaceMethod<"Get the SgData field of the attribute as integer array",
203206 "std::optional<SmallVector<int64_t>>",
204207 "getSgDataAsInt">,
208+ InterfaceMethod<"Get the InstData field of the attribute as integer array",
209+ "std::optional<SmallVector<int64_t>>",
210+ "getInstDataAsInt">,
211+ InterfaceMethod<"Get the LaneLayout field of the attribute as integer array",
212+ "std::optional<SmallVector<int64_t>>",
213+ "getLaneLayoutAsInt">,
214+ InterfaceMethod<"Get the LaneData field of the attribute as integer array",
215+ "std::optional<SmallVector<int64_t>>",
216+ "getLaneDataAsInt">,
205217 InterfaceMethod<"Derive a new layout by dropping sgLayout and sgData",
206218 "xegpu::DistributeLayoutAttr",
207219 "dropSgLayoutAndData">,
@@ -388,6 +400,24 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttr]> {
388400 return std::nullopt;
389401 }
390402
403+ std::optional<SmallVector<int64_t>> getInstDataAsInt() const {
404+ if (DenseI32ArrayAttr inst = getInstData())
405+ return llvm::to_vector_of<int64_t>(inst.asArrayRef());
406+ return std::nullopt;
407+ }
408+
409+ std::optional<SmallVector<int64_t>> getLaneLayoutAsInt() const {
410+ if (DenseI32ArrayAttr layout = getLaneLayout())
411+ return llvm::to_vector_of<int64_t>(layout.asArrayRef());
412+ return std::nullopt;
413+ }
414+
415+ std::optional<SmallVector<int64_t>> getLaneDataAsInt() const {
416+ if (DenseI32ArrayAttr data = getLaneData())
417+ return llvm::to_vector_of<int64_t>(data.asArrayRef());
418+ return std::nullopt;
419+ }
420+
391421 /// Delinearizes a linear subgroup ID into its multidimensional indices
392422 /// based on the effective subgroup layout.
393423 FailureOr<SmallVector<Value>>
@@ -488,6 +518,42 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> {
488518 return std::nullopt;
489519 }
490520
521+ /// Returns the InstData of the attribute, computed by applying
522+ /// the slice dimensions to the underlying LayoutAttr.
523+ std::optional<SmallVector<int64_t>> getInstDataAsInt() const {
524+ SliceAttr attr = flatten();
525+ auto parent = dyn_cast<LayoutAttr>(attr.getParent());
526+ if (auto inst = parent.getInstDataAsInt()) {
527+ ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
528+ return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(*inst), dims);
529+ }
530+ return std::nullopt;
531+ }
532+
533+ /// Returns the LaneLayout of the attribute, computed by applying
534+ /// the slice dimensions to the underlying LayoutAttr.
535+ std::optional<SmallVector<int64_t>> getLaneLayoutAsInt() const {
536+ SliceAttr attr = flatten();
537+ auto parent = dyn_cast<LayoutAttr>(attr.getParent());
538+ if (auto layout = parent.getLaneLayoutAsInt()) {
539+ ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
540+ return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(*layout), dims);
541+ }
542+ return std::nullopt;
543+ }
544+
545+ /// Returns the LaneData of the attribute, computed by applying
546+ /// the slice dimensions to the underlying LayoutAttr.
547+ std::optional<SmallVector<int64_t>> getLaneDataAsInt() const {
548+ SliceAttr attr = flatten();
549+ auto parent = dyn_cast<LayoutAttr>(attr.getParent());
550+ if (auto data = parent.getLaneDataAsInt()) {
551+ ArrayRef<int64_t> dims = attr.getDims().asArrayRef();
552+ return XeGPUDialect::slice(llvm::ArrayRef<int64_t>(*data), dims);
553+ }
554+ return std::nullopt;
555+ }
556+
491557 SliceAttr dropSgLayoutAndData() {
492558 SliceAttr attr = flatten();
493559 auto parent = dyn_cast<LayoutAttr>(attr.getParent());
0 commit comments