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

Function run_graph_optimizations

tensorflow/lite/python/util.py:173–199  ·  view source on GitHub ↗

Apply standard TensorFlow optimizations to the graph_def. Args: graph_def: Frozen GraphDef to be optimized. input_arrays: List of arrays that are considered inputs of the graph. output_arrays: List of arrays that are considered outputs of the graph. config: tf.ConfigProto. gra

(graph_def,
                            input_arrays,
                            output_arrays,
                            config,
                            graph=None)

Source from the content-addressed store, hash-verified

171
172
173def run_graph_optimizations(graph_def,
174 input_arrays,
175 output_arrays,
176 config,
177 graph=None):
178 """Apply standard TensorFlow optimizations to the graph_def.
179
180 Args:
181 graph_def: Frozen GraphDef to be optimized.
182 input_arrays: List of arrays that are considered inputs of the graph.
183 output_arrays: List of arrays that are considered outputs of the graph.
184 config: tf.ConfigProto.
185 graph: TensorFlow Graph. Required when Eager mode is enabled. (default None)
186
187 Returns:
188 A new, optimized GraphDef.
189 """
190 meta_graph = _export_meta_graph(graph_def=graph_def, graph=graph)
191
192 # We need to add a collection called 'train_op' so that grappler
193 # knows what the outputs are.
194 fetch_collection = _meta_graph_pb2.CollectionDef()
195 for array in input_arrays + output_arrays:
196 fetch_collection.node_list.value.append(array.name)
197 meta_graph.collection_def["train_op"].CopyFrom(fetch_collection)
198
199 return tf_optimizer.OptimizeGraph(config, meta_graph)
200
201
202def _convert_op_hints_if_present(sess, graph_def, output_tensors,

Callers 1

freeze_graphFunction · 0.85

Calls 3

appendMethod · 0.45
CopyFromMethod · 0.45
OptimizeGraphMethod · 0.45

Tested by

no test coverage detected