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

Function write_test_cases

tensorflow/lite/testing/generate_examples_lib.py:198–224  ·  view source on GitHub ↗

Given a dictionary of `examples`, write a text format representation. The file format is protocol-buffer-like, even though we don't use proto due to the needs of the Android team. Args: fp: File-like object to write to. model_name: Filename where the model was written to, relative to

(fp, model_name, examples)

Source from the content-addressed store, hash-verified

196
197
198def write_test_cases(fp, model_name, examples):
199 """Given a dictionary of `examples`, write a text format representation.
200
201 The file format is protocol-buffer-like, even though we don't use proto due
202 to the needs of the Android team.
203
204 Args:
205 fp: File-like object to write to.
206 model_name: Filename where the model was written to, relative to filename.
207 examples: Example dictionary consiting of keys "inputs" and "outputs"
208 """
209
210 fp.write("load_model: %s\n" % os.path.basename(model_name))
211 for example in examples:
212 fp.write("reshape {\n")
213 for t in example["inputs"]:
214 fp.write(" input: \"" + ",".join(map(str, t.shape)) + "\"\n")
215 fp.write("}\n")
216 fp.write("invoke {\n")
217
218 for t in example["inputs"]:
219 fp.write(" input: \"" + format_result(t) + "\"\n")
220 for t in example["outputs"]:
221 fp.write(" output: \"" + format_result(t) + "\"\n")
222 fp.write(" output_shape: \"" + ",".join([str(dim) for dim in t.shape]) +
223 "\"\n")
224 fp.write("}\n")
225
226
227TF_TYPE_INFO = {

Callers 1

build_exampleFunction · 0.85

Calls 3

format_resultFunction · 0.85
writeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected