66//
77// ===----------------------------------------------------------------------===//
88
9+ #include " mlir/Dialect/Affine/Utils.h"
910#include " mlir/Dialect/Utils/IndexingUtils.h"
1011#include " mlir/Dialect/XeGPU/IR/XeGPU.h"
1112#include " mlir/Dialect/XeGPU/IR/XeGPUTargetInfo.h"
@@ -211,6 +212,18 @@ LayoutAttr::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
211212 return success ();
212213}
213214
215+ FailureOr<SmallVector<Value>>
216+ LayoutAttr::delinearizeSubgroupId (Value linearId, Location loc,
217+ OpBuilder &builder) {
218+ assert (isWgLayout () && " delinearizeSubgroupId is only available for "
219+ " workgroup-level layout attribute." );
220+ auto dims =
221+ llvm::map_to_vector (getSgLayout ().asArrayRef (), [&](int32_t d) -> Value {
222+ return arith::ConstantIndexOp::create (builder, loc, d);
223+ });
224+ return affine::delinearizeIndex (builder, loc, linearId, dims);
225+ }
226+
214227// ===----------------------------------------------------------------------===//
215228// XeGPU_SliceAttr
216229// ===----------------------------------------------------------------------===//
@@ -232,6 +245,12 @@ SliceAttr::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
232245 return success ();
233246}
234247
248+ FailureOr<SmallVector<Value>>
249+ SliceAttr::delinearizeSubgroupId (Value linearId, Location loc,
250+ OpBuilder &builder) {
251+ return getParent ().delinearizeSubgroupId (linearId, loc, builder);
252+ }
253+
235254// ===----------------------------------------------------------------------===//
236255// XeGPU_TensorDescType
237256// ===----------------------------------------------------------------------===//
0 commit comments