<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141025>141025</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir][linalg] Re-organise tests for vectorization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
banach-space
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
banach-space
</td>
</tr>
</table>
<pre>
The current Linalg vectorization tests are split somewhat arbitrarily across multiple files:
```bash
ls -1 mlir/test/Dialect/Linalg/vectoriz*
mlir/test/Dialect/Linalg/vectorization-pad-patterns.mlir
mlir/test/Dialect/Linalg/vectorization-scalable.mlir
mlir/test/Dialect/Linalg/vectorization-unsupported.mlir
mlir/test/Dialect/Linalg/vectorization-with-patterns.mlir
mlir/test/Dialect/Linalg/vectorization.mlir
mlir/test/Dialect/Linalg/vectorize-conv-masked-and-scalable.mlir
mlir/test/Dialect/Linalg/vectorize-convolution-flatten.mlir
mlir/test/Dialect/Linalg/vectorize-convolution.mlir
mlir/test/Dialect/Linalg/vectorize-tensor-extract-masked.mlir
mlir/test/Dialect/Linalg/vectorize-tensor-extract.mlir
```
**Proposed improvements:**
1. Standardise naming: e.g., unify `vectorize` vs. `vectorization`.
2. Introduce a dedicated subdirectory (e.g., "Linalg/Vectorization") to eliminate repeated prefixes (`vectorize`/`vectorization`).
3. Standardise the test split between:
* Tests using `transform.structured.vectorize` (with masking).
* Tests using `transform.structured.vectorize_children_and_apply_patterns` (no masking).
Re 3., this split is already followed in "vectorization.mlir" and "vectorization-with-patterns.mlir", respectively.
**Specific steps:**
* **Rename:** "vectorize-tensor-extract-masked.mlir" --> _**"vectorization-tensor-extract.mlir"**_ (it follows the format from _**"vectorization.mlir"**_).
* **Rename:** "vectorize-tensor-extract.mlir" --> **_"vectorization-tensor-extract-with-patterns.mlir"_** (it follows the format from **_"vectorization-with-patterns.mlir"_**).
* **Merge** "vectorization-scalable.mlir" with other tests.
* **Update** convolution tests to follow the same naming and structural convention.
**Additional clean-up**
* Split "vectorization.mlir" and "vectorization-with-patterns.mlir" into smaller tests. At a minimum, extract non-Linalg operations into separate test files.
* Rename "vectorization-pad-patterns.mlir" to more clearly reflect that it tests `transform.apply_patterns.linalg.pad_vectorization`.
**Structure after the changes**
Without committing to all the fine details just yet, here is a possible end structure for the tests:
```bash
mlir/test/Dialect/Linalg/vectorization/
├── conv.mlir
├── conv-flatten.mlir
├── conv-with-patterns.mlir
├── extract.mlir
├── extract-with-patterns.mlir
├── insert-slice.mlir
├── insert-slice-with-patterns.mlir
├── linalg-ops.mlir
├── linalg-ops-with-patterns.mlir
├── pad.mlir
├── pad-with-patterns.mlir
├── unsupported.mlir
```
In addition to consistent naming, this structure provides a clear separation between tests using:
* `transform.structured.vectorize` - finer-grained tests, typically involving masking.
* `transform.structured.vectorize_children_and_apply_patterns` - broader pattern-based transformations, typically without masking.
**Next steps**
I’ll be uploading patches implementing these changes incrementally, and I’ll use this ticket as a reference for the overall direction. If you have any high-level comments, suggestions, or objections, please raise them here. For smaller details, let’s handle them through the individual PRs.
Thanks!
PRs:
* https://github.com/llvm/llvm-project/pull/140877
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysWF1v2zoS_TX0y0CCTH8_-ME3uQYC7C6KtLv7aIzEscSWIgWScur99QtSsmo7vkmcXsBAHYk8833m1OicLDXRms3-YJznqLGoEtdgQYxzNnscYesrY9fnb0a5Ecf1t4qgaK0l7eEfUqMq4UCFN1b-D700Gjw57wAtgWuU9OBMTS8VekCbS2_RSnUELKxxDupWedkogr1U5Nhkw7L4mWfdJ0dXsWyjHCRjqJW0jG8DPuPbR4mKivCt84Lx7ckPxgPIh49Ht5MGRdKg92S1S-PduyFcgQpzRZ-83mrXNo2xnsQnEV6kr34ziLtvUVIYfUhqdD9IJKjF59PQQRnVxmD2KgTyWYd6lE_c9qSdsQn99BYL3wf22zgngKG1-07n4fPFmsY4EiDrxpoD1aR9nI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