[Mlir-commits] [mlir] [mlir][GPU] Verify known_{block, grid, cluster}_size is non-negative (PR #179886)

Durgadoss R llvmlistbot at llvm.org
Thu Feb 5 01:46:30 PST 2026


================
@@ -347,9 +347,22 @@ def GPU_SubgroupSizeOp : GPU_Op<"subgroup_size", [
   let assemblyFormat = "(`upper_bound` $upper_bound^)? attr-dict `:` type($result)";
 }
 
-def GPU_OptionalDimSizeHintAttr : ConfinedAttr<OptionalAttr<DenseI32ArrayAttr>,
-  [AttrConstraint<Or<[IsNullAttr.predicate, DenseArrayCount<3>.predicate]>,
-    "with 3 elements (if present)">]>;
+def GPU_OptionalDimSizeHintAttr : ConfinedAttr<
+  OptionalAttr<DenseI32ArrayAttr>,
+  [AttrConstraint<
+    Or<[
+      IsNullAttr.predicate,
+      And<[
+        DenseArrayCount<3>.predicate,
+        CPred<"([](mlir::Attribute a) { "
+              "  auto arr = ::llvm::cast<::mlir::DenseI32ArrayAttr>(a).asArrayRef();"
+              "  return ::llvm::all_of(arr, [](int32_t v) { return v >= 0; });"
+              "})($_self)">
+      ]>
+    ]>,
+    "with 3 elements (if present) and all elements >= 0"
----------------
durga4github wrote:

I believe 1 is the default size of the dim when it is not explicitly provided.
So, wondering why did you choose `>=0` here instead of `>=1` ?

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


More information about the Mlir-commits mailing list