[Mlir-commits] [mlir] [mlir][xegpu] Add definitons of MatrixDescType and related ops. (PR #153273)
Jianhui Li
llvmlistbot at llvm.org
Thu Aug 14 17:46:03 PDT 2025
================
@@ -1101,4 +1101,150 @@ def XeGPU_ConvertLayoutOp: XeGPU_Op<"convert_layout", [Pure, AllTypesMatch<["sou
let hasCanonicalizer = 1;
}
+def isSharedPred : CPred<"isSharedMemory(llvm::cast<mlir::MemRefType>($_self))">;
+class StaticShared1DMemRefOf<list<Type> allowedTypes> :
+ ConfinedType<MemRefRankOf<allowedTypes, [1]>, [HasStaticShapePred, isSharedPred],
+ "statically shaped " # MemRefOf<allowedTypes>.summary # " for shared memory",
+ "mlir::MemRefType">;
+
+class SizeInBits<string name> :
+ StrFunc<"llvm::cast<mlir::ShapedType>($" # name # ".getType()).getNumElements()"
+ "*llvm::cast<mlir::ShapedType>($" # name # ".getType()).getElementTypeBitWidth()">;
+class AllMemSizesMatch<list<string> names> :
+ AllMatchSameOperatorTrait<names, SizeInBits<"_self">.result,
+ "size in bits">;
+
+def XeGPU_CreateMemDescOp: XeGPU_Op<"create_mem_desc", [Pure,
+ AllMemSizesMatch<["source", "mem_desc"]>]> {
+ let summary = "Create a matrix descriptor.";
+ let description = [{
+ Creates a matrix descriptor from a shared local memory (SLM) buffer.
+ The resulting matrix descriptor has to have the same size as the underlying
+ shared local memory.
+
+ Arguments:
+ - `source` : a 1D statically shaped memref with element type i8, representing the raw SLM buffer.
+ Results:
+ - `mem_desc` : the matrix descriptor.
+ }];
+ let arguments = (ins StaticShared1DMemRefOf<[I8]>:$source);
+ let results = (outs XeGPU_MemDesc:$mem_desc);
+ let assemblyFormat = "$source prop-dict attr-dict `` `:` type($source) `->` qualified(type($mem_desc))";
+}
+
+def XeGPU_LoadMatrixOp: XeGPU_Op<"load_matrix", [MemoryEffects<[MemRead]>,
+ AllElementTypesMatch<["mem_desc", "res"]>,
+ AllRanksMatch<["mem_desc", "res"]>]> {
+ let arguments = (ins XeGPU_MemDesc:$mem_desc,
+ Variadic<Index>: $offsets,
+ DenseI64ArrayAttr: $const_offsets,
+ OptionalAttr<LayoutTrait>:$layout
+ );
+ let results = (outs XeGPU_ValueType:$res);
+ let assemblyFormat = [{
+ $mem_desc `` custom<DynamicIndexList>($offsets, $const_offsets)
+ prop-dict attr-dict `` `:` type(operands) `->` type(results)
+ }];
+
+ let description = [{
+ This operation reads a block of data from shared local memory (SLM)
+ using the provided matrix descriptor.
+
+ Arguments:
+ - `mem_desc`: the matrix descriptor identifying the SLM region.
----------------
Jianhui-Li wrote:
nit: matrix -> memory
https://github.com/llvm/llvm-project/pull/153273
More information about the Mlir-commits
mailing list