[Mlir-commits] [mlir] [MLIR][XeGPU] make offsets optional for create_nd_tdesc (PR #148335)

Adam Siemieniuk llvmlistbot at llvm.org
Wed Jul 16 09:45:58 PDT 2025


================
@@ -163,7 +174,26 @@ def XeGPU_CreateNdDescOp: XeGPU_Op<"create_nd_tdesc", [Pure, ViewLikeOpInterface
     }
 
     ArrayRef<int64_t> getStaticOffsets(){
-      return getConstOffsets();
+      auto attr = getConstOffsetsAttr();
+
+      if (attr) 
+        return attr;
+
+      auto memrefType = llvm::dyn_cast<MemRefType>(getSourceType());
+      int rank = 0;
+      if (memrefType) 
+        //use source memref's rank, as source memref rank may be higher
+        rank = memrefType.getRank();
+      else
+        //nd_tdesc created from ui64, use nd_tdesc's rank
+        rank = getMixedSizes().size();
+      
+      // The offsets are allowed to be empty. The Traits verification of OffsetSizeAndStrideOpInterface interface assumes offsets being present.
+      // place-holder value MAX indicating user doesn't provide offsets, instead of kDynamic which means offsets passed as value.
+      setConstOffsets(llvm::SmallVector<int64_t, 4>(rank, std::numeric_limits<int64_t>::max()));
----------------
adam-smnk wrote:

Why is the op property being modified in a getter? This field should be populated correctly at the op construction.

https://github.com/llvm/llvm-project/pull/148335


More information about the Mlir-commits mailing list