[Mlir-commits] [mlir] [mlir][linalg] Consolidate tests for scalable vectorization (PR #141469)

Han-Chung Wang llvmlistbot at llvm.org
Tue May 27 06:32:06 PDT 2025


================
@@ -36,6 +40,42 @@ module attributes {transform.with_named_sequence} {
 
 // -----
 
+func.func @vectorize_dynamic_identity_scalable(%arg0: tensor<?xf32>,
+                                               %arg1: tensor<?xf32>,
+                                               %arg2: tensor<?xf32>) -> tensor<?xf32> {
+  %0 = linalg.generic { indexing_maps = [affine_map<(d0) -> (d0)>,
+                                         affine_map<(d0) -> (d0)>,
+                                         affine_map<(d0) -> (d0)>],
+                   iterator_types = ["parallel"] }
+    ins(%arg0, %arg1 : tensor<?xf32>, tensor<?xf32>)
+    outs(%arg2 : tensor<?xf32>) {
+    ^bb(%in0: f32, %in1: f32, %out: f32) :
+      %0 = arith.addf %in0, %in1 : f32
+      linalg.yield %0 : f32
+    } -> tensor<?xf32>
+  return %0 : tensor<?xf32>
+}
+
+// CHECK-LABEL:   @vectorize_dynamic_identity_scalable
----------------
hanhanW wrote:

> The CHECK lines are super wide - manageable on big screens but noisy on laptops, especially with auto-wrap. Perhaps wide-lines should be discouraged?

I was not going to bring up this topic, but I can share what I learned recently: 
https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices

> FileCheck tests should be as self-contained as possible and focus on testing the minimal set of functionalities needed.

IMO, people (including me) have added some unnecessary checks to the lit tests. There are several cases. E.g., sometimes I think maybe we should not check some types. E.g., I think we don't really care what the type is for `C1_IDX` and `DIM_A0_1`. It is hard to make a clear rule, though.

```
// CHECK:    %[[C1_IDX:.*]] = arith.constant 1 : index
// CHECK:    %[[DIM_A0_1:.*]] = tensor.dim %[[ARG_0]], %[[C1_IDX]] : tensor<?x?xf32>
```

We should also request changes for future checks from dumb tools. (Maybe there are good tools that can generate good checks.) Some existing `VAL_XXX` checks are very dumb to me, and I appreciate that you spent plenty of time to fix them. :)

For some wide-lines checks, e.g., masking, we may break them into a couple of lines using `CHECK-SAME` trick, IMO.

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


More information about the Mlir-commits mailing list