[MLIR] Rework generate-test-checks.py to attach CHECK lines to the source (test)...
authorTim Shen <timshen@google.com>
Tue, 16 Jun 2020 02:41:03 +0000 (19:41 -0700)
committerTim Shen <timshen@google.com>
Tue, 16 Jun 2020 18:15:46 +0000 (11:15 -0700)
commit25b3806788aed8633fa32afbe842b0dd48552938
tree786ab3a225b0273ba855ea5d921f3284d78c7456
parent3f0c9c1634237834af6b74e9319cb15f6ab89d11
[MLIR] Rework generate-test-checks.py to attach CHECK lines to the source (test) file.

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>
}

Differential Revision: https://reviews.llvm.org/D81903
mlir/utils/generate-test-checks.py