(unused_args)
| 72 | |
| 73 | |
| 74 | def main(unused_args): |
| 75 | if not gfile.Exists(FLAGS.input): |
| 76 | print("Input graph file '" + FLAGS.input + "' does not exist!") |
| 77 | return -1 |
| 78 | |
| 79 | input_graph_def = graph_pb2.GraphDef() |
| 80 | with gfile.Open(FLAGS.input, "rb") as f: |
| 81 | data = f.read() |
| 82 | if FLAGS.frozen_graph: |
| 83 | input_graph_def.ParseFromString(data) |
| 84 | else: |
| 85 | text_format.Merge(data.decode("utf-8"), input_graph_def) |
| 86 | |
| 87 | output_graph_def = optimize_for_inference_lib.optimize_for_inference( |
| 88 | input_graph_def, |
| 89 | FLAGS.input_names.split(","), |
| 90 | FLAGS.output_names.split(","), |
| 91 | _parse_placeholder_types(FLAGS.placeholder_type_enum), |
| 92 | FLAGS.toco_compatible) |
| 93 | |
| 94 | if FLAGS.frozen_graph: |
| 95 | f = gfile.GFile(FLAGS.output, "w") |
| 96 | f.write(output_graph_def.SerializeToString()) |
| 97 | else: |
| 98 | graph_io.write_graph(output_graph_def, |
| 99 | os.path.dirname(FLAGS.output), |
| 100 | os.path.basename(FLAGS.output)) |
| 101 | return 0 |
| 102 | |
| 103 | |
| 104 | def _parse_placeholder_types(values): |
nothing calls this directly
no test coverage detected