MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testConcreteFunc

Method testConcreteFunc

tensorflow/lite/python/lite_mlir_test.py:482–504  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
507if __name__ == '__main__':

Callers

nothing calls this directly

Calls 8

allocate_tensorsMethod · 0.95
InterpreterClass · 0.90
VariableMethod · 0.80
constantMethod · 0.45
functionMethod · 0.45
get_concrete_functionMethod · 0.45
convertMethod · 0.45

Tested by

no test coverage detected