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

Method testSession

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

Source from the content-addressed store, hash-verified

455class TestFlexMode(test_util.TensorFlowTestCase):
456
457 def testSession(self):
458 with ops.Graph().as_default():
459 in_tensor = array_ops.placeholder(
460 shape=[1, 16, 16, 3], dtype=dtypes.float32)
461 out_tensor = in_tensor + in_tensor
462 sess = session.Session()
463
464 # Convert model and ensure model is not None.
465 converter = lite.TFLiteConverter.from_session(sess, [in_tensor],
466 [out_tensor])
467 converter.experimental_enable_mlir_converter = True
468 converter.target_spec.supported_ops = set([lite.OpsSet.SELECT_TF_OPS])
469 tflite_model = converter.convert()
470
471 # Ensures the model contains TensorFlow ops.
472 # TODO(nupurgarg): Check values once there is a Python delegate interface.
473 interpreter = Interpreter(model_content=tflite_model)
474 with self.assertRaises(RuntimeError) as error:
475 interpreter.allocate_tensors()
476 self.assertIn(
477 'Regular TensorFlow ops are not supported by this interpreter. Make '
478 'sure you invoke the Flex delegate before inference.',
479 str(error.exception))
480
481 @test_util.run_v2_only
482 def testConcreteFunc(self):

Callers

nothing calls this directly

Calls 8

allocate_tensorsMethod · 0.95
InterpreterClass · 0.90
as_defaultMethod · 0.45
GraphMethod · 0.45
placeholderMethod · 0.45
SessionMethod · 0.45
from_sessionMethod · 0.45
convertMethod · 0.45

Tested by

no test coverage detected