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)
| 196 | |
| 197 | |
| 198 | def 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 | |
| 227 | TF_TYPE_INFO = { |
no test coverage detected