Skip to content

Commit 30c4714

Browse files
authored
[mlir][utils] Update generate-test-checks.py (llvm#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 = (...) ```
1 parent 832ca74 commit 30c4714

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mlir/utils/generate-test-checks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,12 @@ def main():
408408
for argument in ssa_split[1:]:
409409
output_line += "// " + args.check_prefix + "-SAME: "
410410

411-
# Pad to align with the original position in the line.
412-
output_line += " " * len(ssa_split[0])
411+
# Pad to align with the original position in the line (i.e. where the label ends),
412+
# unless the label is more than 20 chars long, in which case pad with 4 spaces
413+
# (this is to avoid deep indentation).
414+
label_length = len(ssa_split[0])
415+
pad_depth = label_length if label_length < 21 else 4
416+
output_line += " " * pad_depth
413417

414418
# Process the rest of the line.
415419
output_line += process_line(

0 commit comments

Comments
 (0)