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

Function node_to_graph

tensorflow/python/autograph/impl/conversion.py:688–723  ·  view source on GitHub ↗

Convert Python code to equivalent TF graph mode code. Args: node: AST, the code to convert. context: converter.EntityContext Returns: A tuple (node, deps): * node: A Python ast node, representing the converted code. * deps: A set of strings, the fully qualified name

(node, context)

Source from the content-addressed store, hash-verified

686
687
688def node_to_graph(node, context):
689 """Convert Python code to equivalent TF graph mode code.
690
691 Args:
692 node: AST, the code to convert.
693 context: converter.EntityContext
694
695 Returns:
696 A tuple (node, deps):
697 * node: A Python ast node, representing the converted code.
698 * deps: A set of strings, the fully qualified names of entity
699 dependencies that this node has.
700 """
701 # TODO(mdan): Insert list_comprehensions somewhere.
702 unsupported_features_checker.verify(node)
703
704 node = converter.standard_analysis(node, context, is_initial=True)
705 node = converter.apply_(node, context, function_scopes)
706 node = converter.apply_(node, context, arg_defaults)
707 node = converter.apply_(node, context, directives)
708 node = converter.apply_(node, context, break_statements)
709 if context.program.options.uses(converter.Feature.ASSERT_STATEMENTS):
710 node = converter.apply_(node, context, asserts)
711 # Note: sequencing continue canonicalization before for loop one avoids
712 # dealing with the extra loop increment operation that the for
713 # canonicalization creates.
714 node = converter.apply_(node, context, continue_statements)
715 node = converter.apply_(node, context, return_statements)
716 if context.program.options.uses(converter.Feature.LISTS):
717 node = converter.apply_(node, context, lists)
718 node = converter.apply_(node, context, slices)
719 node = converter.apply_(node, context, call_trees)
720 node = converter.apply_(node, context, control_flow)
721 node = converter.apply_(node, context, conditional_expressions)
722 node = converter.apply_(node, context, logical_expressions)
723 return node

Callers 1

convert_func_to_astFunction · 0.85

Calls 2

usesMethod · 0.80
verifyMethod · 0.45

Tested by

no test coverage detected