This is an archive of the discontinued LLVM Phabricator instance.

New features and bug fix in MLIR test generation tool
ClosedPublic

Authored by rafaelubalmw on Jul 4 2023, 12:02 PM.

Details

Summary
  • Option --variable_names <names> allows the user to pass names for FileCheck regexps representing variables. Variable names are separated by commas, and empty names can be used to generate specific variable names automatically. For example, --variable-names arg_0,arg_1,,,result will produce regexp names ARG_0, ARG_1, VAR_0, VAR_1, RESULT, VAR_2, VAR_3, ...
  • Option '--attribute_names <names>' can be used to generate global regexp names to represent attributes. Useful for affine maps. Same behavior as '--variable_names'.
  • Bug fixed for scope detection of SSA variables in ops with nested regions that return SSA values (e.g., 'linalg.generic'). Originally, returned SSA values were inserted in the nested scope.

This version of the tool has been used to generate unit tests for the following
patch: https://reviews.llvm.org/D153291

For example, the main body of the test named 'test_select_2d_one_dynamic' was
generated using the following command:

$ mlir-opt -pass-pipeline='builtin.module(func.func(tosa-to-linalg))' test_select_2d_one_dynamic.tosa.mlir | generate-test-checks.py --attribute_names map0,map1,map2 --variable_names arg0,arg1,arg2,const1,arg0_dim1,arg1_dim1,,arg2_dim1,max_dim1,,,arg0_broadcast,,,,,,,arg1_broadcast,,,,,,,arg2_broadcast,,,,,,result

Diff Detail

Event Timeline

rafaelubalmw created this revision.Jul 4 2023, 12:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2023, 12:02 PM
rafaelubalmw requested review of this revision.Jul 4 2023, 12:02 PM
rafaelubalmw retitled this revision from Improved MLIR test generation tools with new features. to New features and bug fix in MLIR test generation tool.Jul 4 2023, 12:05 PM
rafaelubalmw edited the summary of this revision. (Show Details)
eric-k256 accepted this revision.Jul 6 2023, 11:47 AM

Looks okay to me.
It does feel like it might be awkward to use with the long sequences of commas if the default values are used, but I can't think of an obviously better option.

This revision is now accepted and ready to land.Jul 6 2023, 11:47 AM

I'm just gonna take this opportunity to remind that this tool is not a substitution for manually pruning the output and make it minimal : the test shouldn't be over specified in general and intend to test specific properties of the output.

Thank you all for the comments. Would someone with commit access be able to merge the patch?

I can land this.

This revision was automatically updated to reflect the committed changes.