[Mlir-commits] [mlir] [mlir][linalg] Reject unsigned pooling on non-integer element types (PR #166070)

Andrzej WarzyƄski llvmlistbot at llvm.org
Sat Dec 13 09:46:21 PST 2025


================
@@ -1939,3 +1939,31 @@ func.func @matmul_invalid_mixed_types(%t: tensor<?xf16>, %f: vector<4xf16>)
                                 outs(%f : vector<4xf16>) -> tensor<?xf16>
   func.return %0, %f : tensor<?xf16>, vector<4xf16>
 }
+
+// -----
+
+func.func @pooling_nhwc_max_unsigned_non_integer_elem_type(
+    %input: tensor<1x4x4x1xf32>,
+    %filter: tensor<2x2xf32>,
+    %init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
+  // expected-error @+1 {{unsupported operation: unsigned max not on uint}}
+  %0 = linalg.pooling_nhwc_max_unsigned {dilations = dense<1> : tensor<2xi64>,
+                                        strides = dense<1> : tensor<2xi64>}
+      ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
+      outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
+  return %0 : tensor<1x2x2x1xf32>
+}
+
+// -----
+
+func.func @pooling_nhwc_min_unsigned_non_integer_elem_type(
+    %input: tensor<1x4x4x1xf32>,
+    %filter: tensor<2x2xf32>,
+    %init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
+  // expected-error @+1 {{unsupported operation: unsigned min not on uint}}
+  %0 = linalg.pooling_nhwc_min_unsigned {dilations = dense<1> : tensor<2xi64>,
+                                        strides = dense<1> : tensor<2xi64>}
+      ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
+      outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
+  return %0 : tensor<1x2x2x1xf32>
+}
----------------
banach-space wrote:

Please add a block comment, like this one: https://github.com/llvm/llvm-project/blob/fa511cde48ea218dadfa8b35658ac06368f34607/mlir/test/Dialect/Linalg/invalid.mlir?plain=1#L1920-L1922

Also, please test all variants that can be signed/unsigned (I am missing `nwc` variants here).

[nit] Lastly, I would keep the tests above ("Tests for generic infrastructure for named Ops.") as the "bottom" tests. IMO it makes sense to keep general tests at the very end.

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


More information about the Mlir-commits mailing list