This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Rework generate-test-checks.py to attach CHECK lines to the source (test) file.
ClosedPublic

Authored by timshen on Jun 15 2020, 7:49 PM.

Details

Summary

This patch adds --source flag to indicate the source file. Then it tries to find insert
points in the source file and insert corresponding checks at those places.

Example output from Tensorflow XLA:

// -----

// CHECK-LABEL:   func @main.3(
// CHECK-SAME:                 %[[VAL_0:.*]]: memref<2x2xf32> {xla_lhlo.params = 0 : index},
// CHECK-SAME:                 %[[VAL_1:.*]]: memref<16xi8> {xla_lhlo.alloc = 0 : index, xla_lhlo.liveout = true}) {
// CHECK:           %[[VAL_2:.*]] = constant 0 : index
// CHECK:           %[[VAL_3:.*]] = constant 0 : index
// CHECK:           %[[VAL_4:.*]] = std.view %[[VAL_1]]{{\[}}%[[VAL_3]]][] : memref<16xi8> to memref<2x2xf32>
// CHECK:           "xla_lhlo.tanh"(%[[VAL_0]], %[[VAL_4]]) : (memref<2x2xf32>, memref<2x2xf32>) -> ()
// CHECK:           return
// CHECK:         }
func @main(%value0: tensor<2x2xf32>) -> tensor<2x2xf32> {
  %res = "xla_hlo.tanh"(%value0) : (tensor<2x2xf32>) -> tensor<2x2xf32>
  return %res : tensor<2x2xf32>
}

Diff Detail

Event Timeline

timshen created this revision.Jun 15 2020, 7:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2020, 7:49 PM
timshen updated this revision to Diff 270947.Jun 15 2020, 7:52 PM

Fix typo.

timshen updated this revision to Diff 270948.Jun 15 2020, 8:00 PM

Remove extra empty line in the end.

timshen edited the summary of this revision. (Show Details)Jun 15 2020, 8:00 PM
mehdi_amini accepted this revision.Jun 15 2020, 8:30 PM

Nice improvement, thanks!

This revision is now accepted and ready to land.Jun 15 2020, 8:30 PM
Harbormaster completed remote builds in B60413: Diff 270947.
rriddle accepted this revision.Jun 16 2020, 11:31 AM

Looks good, thanks!

mlir/utils/generate-test-checks.py
11–14

Please add documentation for any new behavior here.

59

nit: Add a function comment for these.

96

nit: Add comments.

This revision was automatically updated to reflect the committed changes.
timshen marked 3 inline comments as done.Jun 16 2020, 11:39 AM

Added documentation in succeeding commits.