Skip to content

Commit d7460da

Browse files
authored
[mlir][utils] Update generate-test-checks.py (#136721)
Following #128083, all `CHECK-SAME` lines generated by generate-test-checks.py use a strict regex: ```mlir // CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: memref<128x256x512xf32>, ``` However, in most cases this strict form is unnecessary and can obscure readability. In such cases, the following would be sufficient: ```mlir // CHECK-SAME: %[[VAL_0:.*]]: memref<128x256x512xf32>, ``` This patch adds a command-line flag to make the strict mode optional. To enable strict regex matching, use: ```bash generate-test-checks.py --strict_name_re=true file.mlir ```
1 parent dee96a3 commit d7460da

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mlir/utils/generate-test-checks.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,13 @@ def main():
295295
help="Names to be used in FileCheck regular expression to represent "
296296
"attributes in the order they are defined. Separate names with commas,"
297297
"commas, and leave empty entries for default names (e.g.: 'MAP0,,,MAP1')")
298+
parser.add_argument(
299+
"--strict_name_re",
300+
type=bool,
301+
default=False,
302+
help="Set to true to use stricter regex for CHECK-SAME directives. "
303+
"Use when Greedy matching causes issues with the generic '.*'",
304+
)
298305

299306
args = parser.parse_args()
300307

@@ -406,7 +413,7 @@ def main():
406413

407414
# Process the rest of the line.
408415
output_line += process_line(
409-
[argument], variable_namer, strict_name_re=True
416+
[argument], variable_namer, args.strict_name_re
410417
)
411418

412419
# Append the output line.

0 commit comments

Comments
 (0)