Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternative prettyprinting method to Graph #50878

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions torch/fx/examples/inspect_utils.py

This file was deleted.

11 changes: 11 additions & 0 deletions torch/fx/graph.py
@@ -1,6 +1,7 @@
from .node import Node, Argument, Target, map_arg

from typing import Callable, Any, List, Dict, Optional, Tuple, Set
from tabulate import tabulate
import builtins
import torch
import types
Expand Down Expand Up @@ -785,6 +786,16 @@ def format_node(n : Node) -> Optional[str]:
s += '\n ' + node_str
return s

def print_tabular(self):
"""
Prints the intermediate representation of the graph in tabular
format.
"""
node_specs = [[n.op, n.name, n.target, n.args, n.kwargs]
for n in self.nodes]
print(tabulate(node_specs,
headers=['opcode', 'name', 'target', 'args', 'kwargs']))

def lint(self, root : Optional[torch.nn.Module] = None):
"""
Runs various checks on this Graph to make sure it is well-formed. In
Expand Down