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

Method testFloat

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

Source from the content-addressed store, hash-verified

1083class FromFrozenGraphFile(test_util.TensorFlowTestCase):
1084
1085 def testFloat(self):
1086 with ops.Graph().as_default():
1087 in_tensor = array_ops.placeholder(
1088 shape=[1, 16, 16, 3], dtype=dtypes.float32)
1089 _ = in_tensor + in_tensor
1090 sess = session.Session()
1091
1092 # Write graph to file.
1093 graph_def_file = os.path.join(self.get_temp_dir(), 'model.pb')
1094 write_graph(sess.graph_def, '', graph_def_file, False)
1095 sess.close()
1096
1097 # Convert model and ensure model is not None.
1098 converter = lite.TFLiteConverter.from_frozen_graph(graph_def_file,
1099 ['Placeholder'], ['add'])
1100 tflite_model = converter.convert()
1101 self.assertTrue(tflite_model)
1102
1103 # Check values from converted model.
1104 interpreter = Interpreter(model_content=tflite_model)
1105 interpreter.allocate_tensors()
1106
1107 input_details = interpreter.get_input_details()
1108 self.assertEqual(1, len(input_details))
1109 self.assertEqual('Placeholder', input_details[0]['name'])
1110 self.assertEqual(np.float32, input_details[0]['dtype'])
1111 self.assertTrue(([1, 16, 16, 3] == input_details[0]['shape']).all())
1112 self.assertEqual((0., 0.), input_details[0]['quantization'])
1113
1114 output_details = interpreter.get_output_details()
1115 self.assertEqual(1, len(output_details))
1116 self.assertEqual('add', output_details[0]['name'])
1117 self.assertEqual(np.float32, output_details[0]['dtype'])
1118 self.assertTrue(([1, 16, 16, 3] == output_details[0]['shape']).all())
1119 self.assertEqual((0., 0.), output_details[0]['quantization'])
1120
1121 def testFloatWithShapesArray(self):
1122 with ops.Graph().as_default():

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