def test_op_reg_gen(self):
     cxx_code = gen_register_op(sys.modules[__name__])
     cxx_code_exp = r"""
   CHECK: #include "tensorflow/core/framework/op.h"
   CHECK-EMPTY
   CHECK: namespace tensorflow {
   CHECK-EMPTY
   CHECK-LABEL: REGISTER_OP("TestNoOp")
   CHECK-NEXT:      .Attr("T: numbertype")
   CHECK-NEXT:      .Output("o1: T");
   CHECK-EMPTY
   CHECK-LABEL: REGISTER_OP("TestCompositeOp")
   CHECK-NEXT:      .Input("x: T")
   CHECK-NEXT:      .Input("y: T")
   CHECK-NEXT:      .Attr("act: {'', 'relu'}")
   CHECK-NEXT:      .Attr("trans: bool = true")
   CHECK-NEXT:      .Attr("T: numbertype")
   CHECK-NEXT:      .Output("o1: T")
   CHECK-NEXT:      .Output("o2: T");
   CHECK-EMPTY
   CHECK:  }  // namespace tensorflow
 """
     self.assertTrue(fw.check(str(cxx_code), cxx_code_exp), str(cxx_code))
Example #2
0
 def _check_code(self, tfr_code, exp_tfr_code):
     return self.assertTrue(fw.check(str(tfr_code), exp_tfr_code),
                            str(tfr_code))
 def assertFilecheck(self, actual, expected):
   """Assert that FileCheck runs successfully."""
   self.assertTrue(fw.check(actual, expected))
Example #4
0
 def _check_code(self, mlir_code, exp_mlir_code):
     return self.assertTrue(fw.check(str(mlir_code), exp_mlir_code))
Example #5
0
 def assertFilecheck(self, actual, expected):
   """Assert that FileCheck runs successfully."""
   if not fw.check(actual, expected):
     self.fail(f'Got output:\n{actual}\nExpected:\n{expected}')