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)
| 686 | |
| 687 | |
| 688 | def 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 |
no test coverage detected