[Mlir-commits] [mlir] 30c4714 - [mlir][utils] Update generate-test-checks.py (#136757)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Apr 22 23:32:27 PDT 2025
Author: Andrzej WarzyĆski
Date: 2025-04-23T07:32:24+01:00
New Revision: 30c47147262523663892836fee42e02f8f9366f5
URL: https://github.com/llvm/llvm-project/commit/30c47147262523663892836fee42e02f8f9366f5
DIFF: https://github.com/llvm/llvm-project/commit/30c47147262523663892836fee42e02f8f9366f5.diff
LOG: [mlir][utils] Update generate-test-checks.py (#136757)
At the moment, the `CHECK-SAME` lines generated by
"generate-test-checks.py" (i.e. check-lines that correspond to the
preceeding `CHECK-LABEL` line) are indented to match the label length.
For example,
```mlir
func.func @batch_reduce_matmul_bcast_k_to_fill_missing_dims_A(%arg0: memref<5xf32>, %arg1: memref<2x5x7xf32>, %arg2: memref<3x7xf32>) {
linalg.batch_reduce_matmul indexing_maps = (...)
}
```
will lead to the following:
```mlir
// CHECK-LABEL: func.func @batch_reduce_matmul_bcast_k_to_fill_missing_dims_A(
// CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: memref<5xf32>,
// CHECK-SAME: %[[VAL_1:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: memref<2x5x7xf32>,
// CHECK-SAME: %[[VAL_2:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: memref<3x7xf32>) {
// CHECK: linalg.batch_reduce_matmul indexing_maps = (...)
```
This indentation is unnecasarilly deep. With this change, for labales
that are longer than 20 chars, the indentation is trimmed to 4 spaces:
```mlir
// CHECK-LABEL: func.func @batch_reduce_matmul_bcast_k_to_fill_missing_dims_A(
// CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: memref<5xf32>,
// CHECK-SAME: %[[VAL_1:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: memref<2x5x7xf32>,
// CHECK-SAME: %[[VAL_2:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: memref<3x7xf32>) {
// CHECK: linalg.batch_reduce_matmul indexing_maps = (...)
```
Added:
Modified:
mlir/utils/generate-test-checks.py
Removed:
################################################################################
diff --git a/mlir/utils/generate-test-checks.py b/mlir/utils/generate-test-checks.py
index f1dd7a2843893..d157af9c3cab7 100755
--- a/mlir/utils/generate-test-checks.py
+++ b/mlir/utils/generate-test-checks.py
@@ -408,8 +408,12 @@ def main():
for argument in ssa_split[1:]:
output_line += "// " + args.check_prefix + "-SAME: "
- # Pad to align with the original position in the line.
- output_line += " " * len(ssa_split[0])
+ # Pad to align with the original position in the line (i.e. where the label ends),
+ # unless the label is more than 20 chars long, in which case pad with 4 spaces
+ # (this is to avoid deep indentation).
+ label_length = len(ssa_split[0])
+ pad_depth = label_length if label_length < 21 else 4
+ output_line += " " * pad_depth
# Process the rest of the line.
output_line += process_line(
More information about the Mlir-commits
mailing list