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

Method testPbtxt

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

Source from the content-addressed store, hash-verified

1167 str(error.exception))
1168
1169 def testPbtxt(self):
1170 with ops.Graph().as_default():
1171 in_tensor = array_ops.placeholder(
1172 shape=[1, 16, 16, 3], dtype=dtypes.float32)
1173 _ = in_tensor + in_tensor
1174 sess = session.Session()
1175
1176 # Write graph to file.
1177 graph_def_file = os.path.join(self.get_temp_dir(), 'model.pbtxt')
1178 write_graph(sess.graph_def, '', graph_def_file, True)
1179 sess.close()
1180
1181 # Convert model and ensure model is not None.
1182 converter = lite.TFLiteConverter.from_frozen_graph(graph_def_file,
1183 ['Placeholder'], ['add'])
1184 tflite_model = converter.convert()
1185 self.assertTrue(tflite_model)
1186
1187 # Check values from converted model.
1188 interpreter = Interpreter(model_content=tflite_model)
1189 interpreter.allocate_tensors()
1190
1191 input_details = interpreter.get_input_details()
1192 self.assertEqual(1, len(input_details))
1193 self.assertEqual('Placeholder', input_details[0]['name'])
1194 self.assertEqual(np.float32, input_details[0]['dtype'])
1195 self.assertTrue(([1, 16, 16, 3] == input_details[0]['shape']).all())
1196 self.assertEqual((0., 0.), input_details[0]['quantization'])
1197
1198 output_details = interpreter.get_output_details()
1199 self.assertEqual(1, len(output_details))
1200 self.assertEqual('add', output_details[0]['name'])
1201 self.assertEqual(np.float32, output_details[0]['dtype'])
1202 self.assertTrue(([1, 16, 16, 3] == output_details[0]['shape']).all())
1203 self.assertEqual((0., 0.), output_details[0]['quantization'])
1204
1205 def testInvalidFileNotFound(self):
1206 with self.assertRaises(IOError) as error:

Callers

nothing calls this directly

Calls 15

closeMethod · 0.95
allocate_tensorsMethod · 0.95
get_input_detailsMethod · 0.95
get_output_detailsMethod · 0.95
InterpreterClass · 0.90
get_temp_dirMethod · 0.80
write_graphFunction · 0.50
as_defaultMethod · 0.45
GraphMethod · 0.45
placeholderMethod · 0.45
SessionMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected