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

Function main

tensorflow/python/tools/optimize_for_inference.py:74–101  ·  view source on GitHub ↗
(unused_args)

Source from the content-addressed store, hash-verified

72
73
74def 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
104def _parse_placeholder_types(values):

Callers

nothing calls this directly

Calls 10

_parse_placeholder_typesFunction · 0.85
ExistsMethod · 0.45
OpenMethod · 0.45
readMethod · 0.45
ParseFromStringMethod · 0.45
MergeMethod · 0.45
decodeMethod · 0.45
splitMethod · 0.45
writeMethod · 0.45
SerializeToStringMethod · 0.45

Tested by

no test coverage detected