Description
The current Linalg vectorization tests are split somewhat arbitrarily across multiple files:
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:
- Standardise naming: e.g., unify
vectorize
vs.vectorization
. - Introduce a dedicated subdirectory (e.g., "Linalg/Vectorization") to eliminate repeated prefixes (
vectorize
/vectorization
). - Standardise the test split between:
- Tests using
transform.structured.vectorize
(with masking). - Tests using
transform.structured.vectorize_children_and_apply_patterns
(no masking).
- Tests using
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:
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: