(self)
| 480 | |
| 481 | @test_util.run_v2_only |
| 482 | def testConcreteFunc(self): |
| 483 | input_data = constant_op.constant(1., shape=[1]) |
| 484 | root = tracking.AutoTrackable() |
| 485 | root.v1 = variables.Variable(3.) |
| 486 | root.v2 = variables.Variable(2.) |
| 487 | root.f = def_function.function(lambda x: root.v1 * root.v2 * x) |
| 488 | concrete_func = root.f.get_concrete_function(input_data) |
| 489 | |
| 490 | # Convert model. |
| 491 | converter = lite.TFLiteConverterV2.from_concrete_functions([concrete_func]) |
| 492 | converter.experimental_enable_mlir_converter = True |
| 493 | converter.target_spec.supported_ops = set([lite.OpsSet.SELECT_TF_OPS]) |
| 494 | tflite_model = converter.convert() |
| 495 | |
| 496 | # Ensures the model contains TensorFlow ops. |
| 497 | # TODO(nupurgarg): Check values once there is a Python delegate interface. |
| 498 | interpreter = Interpreter(model_content=tflite_model) |
| 499 | with self.assertRaises(RuntimeError) as error: |
| 500 | interpreter.allocate_tensors() |
| 501 | self.assertIn( |
| 502 | 'Regular TensorFlow ops are not supported by this interpreter. Make ' |
| 503 | 'sure you invoke the Flex delegate before inference.', |
| 504 | str(error.exception)) |
| 505 | |
| 506 | |
| 507 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected