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

Method testString

tensorflow/lite/python/lite_test.py:137–165  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

135 self.assertEqual((0., 0.), output_details[0]['quantization'])
136
137 def testString(self):
138 with ops.Graph().as_default():
139 in_tensor = array_ops.placeholder(shape=[4], dtype=dtypes.string)
140 out_tensor = array_ops.reshape(in_tensor, shape=[2, 2])
141 sess = session.Session()
142
143 # Convert model and ensure model is not None.
144 converter = lite.TFLiteConverter.from_session(sess, [in_tensor],
145 [out_tensor])
146 tflite_model = converter.convert()
147 self.assertTrue(tflite_model)
148
149 # Check values from converted model.
150 interpreter = Interpreter(model_content=tflite_model)
151 interpreter.allocate_tensors()
152
153 input_details = interpreter.get_input_details()
154 self.assertEqual(1, len(input_details))
155 self.assertEqual('Placeholder', input_details[0]['name'])
156 self.assertEqual(np.string_, input_details[0]['dtype'])
157 self.assertTrue(([4] == input_details[0]['shape']).all())
158
159 output_details = interpreter.get_output_details()
160 self.assertEqual(1, len(output_details))
161 self.assertEqual('Reshape', output_details[0]['name'])
162 self.assertEqual(np.string_, output_details[0]['dtype'])
163 self.assertTrue(([2, 2] == output_details[0]['shape']).all())
164 # TODO(b/122659643): Test setting/getting string data via the python
165 # interpreter API after support has been added.
166
167 def testQuantization(self):
168 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