[Mlir-commits] [mlir] [MLIR][NVVM] Update TMA tensor prefetch Op (PR #153464)

Guray Ozen llvmlistbot at llvm.org
Thu Aug 14 03:37:28 PDT 2025


================
@@ -99,10 +99,41 @@ LogicalResult CpAsyncOp::verify() {
 }
 
 LogicalResult CpAsyncBulkTensorPrefetchOp::verify() {
-  size_t numIm2ColOffsets = getIm2colOffsets().size();
-  bool isIm2Col = numIm2ColOffsets > 0;
-  return cpAsyncBulkTensorCommonVerifier(getCoordinates().size(), isIm2Col,
-                                         numIm2ColOffsets, getLoc());
+  size_t tensorDims = getCoordinates().size();
+  if (tensorDims < 1 || tensorDims > 5)
+    return emitError("expects coordinates between 1 to 5 dimension");
+
+  auto checkTMALoadParams = [&](TMALoadMode mode, bool isIm2col,
+                                size_t expectedNumOffsets) -> LogicalResult {
+    if (isIm2col && (tensorDims < 3))
+      return emitError()
+             << "to use " << stringifyEnum(mode)
+             << " mode, the tensor has to be at least 3-dimensional";
+
+    if (getIm2colOffsets().size() != expectedNumOffsets)
+      return emitError() << " im2col offsets expected " << expectedNumOffsets
+                         << " (provided " << getIm2colOffsets().size() << ")";
+
+    return success();
+  };
+
+  auto mode = getMode();
+  switch (mode) {
+  case TMALoadMode::TILE:
+    return checkTMALoadParams(mode, false, 0);
+  case TMALoadMode::IM2COL:
+    return checkTMALoadParams(mode, true, tensorDims - 2);
+  case TMALoadMode::IM2COL_W:
+  case TMALoadMode::IM2COL_W_128:
+    return checkTMALoadParams(mode, true, 2);
+  case TMALoadMode::TILE_GATHER4:
+    return (tensorDims == 5) ? checkTMALoadParams(mode, false, 0)
+                             : emitError("Gather4 mode expects 5 coordinates");
+  default:
+    return emitError("Invalid LoadMode in CpAsyncBulkTensorPrefetchOp.");
+  }
----------------
grypp wrote:

Is the verifier specific to this op? can it be used in general?

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


More information about the Mlir-commits mailing list