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

Method testString

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

Source from the content-addressed store, hash-verified

75 self.assertEqual((0., 0.), output_details[0]['quantization'])
76
77 def testString(self):
78 with ops.Graph().as_default():
79 in_tensor = array_ops.placeholder(shape=[4], dtype=dtypes.string)
80 out_tensor = array_ops.reshape(in_tensor, shape=[2, 2])
81 sess = session.Session()
82
83 # Convert model and ensure model is not None.
84 converter = lite.TFLiteConverter.from_session(sess, [in_tensor],
85 [out_tensor])
86 converter.experimental_enable_mlir_converter = True
87 tflite_model = converter.convert()
88
89 # Check values from converted model.
90 interpreter = Interpreter(model_content=tflite_model)
91 interpreter.allocate_tensors()
92
93 input_details = interpreter.get_input_details()
94 self.assertEqual(1, len(input_details))
95 self.assertEqual('Placeholder', input_details[0]['name'])
96 self.assertEqual(np.string_, input_details[0]['dtype'])
97 self.assertTrue(([4] == input_details[0]['shape']).all())
98
99 output_details = interpreter.get_output_details()
100 self.assertEqual(1, len(output_details))
101 self.assertEqual('Reshape', output_details[0]['name'])
102 self.assertEqual(np.string_, output_details[0]['dtype'])
103 self.assertTrue(([2, 2] == output_details[0]['shape']).all())
104
105 def testQuantization(self):
106 with ops.Graph().as_default():

Callers

nothing calls this directly

Calls 12

allocate_tensorsMethod · 0.95
get_input_detailsMethod · 0.95
get_output_detailsMethod · 0.95
InterpreterClass · 0.90
reshapeMethod · 0.80
as_defaultMethod · 0.45
GraphMethod · 0.45
placeholderMethod · 0.45
SessionMethod · 0.45
from_sessionMethod · 0.45
convertMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected