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

Function find_all_hinted_output_nodes

tensorflow/lite/python/op_hint.py:1226–1258  ·  view source on GitHub ↗

Find all Ophints output nodes in the graph. This is used to get all the output nodes those are ophinted, it is important for operation like convert_variables_to_constants keep all ophints structure. Note: only one of session or graph_def should be used, not both. Why this can be useful? Som

(session=None, graph_def=None)

Source from the content-addressed store, hash-verified

1224
1225
1226def find_all_hinted_output_nodes(session=None, graph_def=None):
1227 """Find all Ophints output nodes in the graph.
1228
1229 This is used to get all the output nodes those are ophinted, it is important
1230 for operation like convert_variables_to_constants keep all ophints structure.
1231 Note: only one of session or graph_def should be used, not both.
1232 Why this can be useful? Some TensorFlow ops (e.g. bidirectional rnn), can
1233 generate multiple outputs for unfused subgraph. If not all output nodes are
1234 consumed, graph optimization can potentially drop the unused nodes and cause
1235 ophints in an invalid states (due to missing ophinted output nodes). So it's
1236 important for us to find all those hinted output nodes and make sure they're
1237 not discarded away.
1238
1239 Args:
1240 session: A TensorFlow session that contains the graph to convert.
1241 graph_def: A graph def that we should convert.
1242
1243 Returns:
1244 A list of OpHints output nodes.
1245 Raises:
1246 ValueError: If both session and graph_def are provided.
1247 """
1248 if session is not None and graph_def is not None:
1249 raise ValueError("Provide only one of session and graph_def.")
1250 hinted_outputs_nodes = []
1251 if session is not None:
1252 hints = _find_all_hints_in_nodes(session.graph_def.node)
1253 elif graph_def is not None:
1254 hints = _find_all_hints_in_nodes(graph_def.node)
1255 for hint in _six.itervalues(hints):
1256 _, output_nodes = hint.flattened_inputs_and_outputs()
1257 hinted_outputs_nodes.extend(output_nodes)
1258 return hinted_outputs_nodes
1259
1260
1261@_tf_export(v1=["lite.experimental.convert_op_hints_to_stubs"])

Callers 1

freeze_graphFunction · 0.90

Calls 3

_find_all_hints_in_nodesFunction · 0.85
extendMethod · 0.45

Tested by

no test coverage detected