Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hiddenlayer/pytorch_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
ht.Rename(op=r"BatchNormalization", to="BatchNorm"),
]

# https://github.com/pytorch/pytorch/blob/2efe4d809fdc94501fc38bf429e9a8d4205b51b6/torch/utils/tensorboard/_pytorch_graph.py#L384
def _node_get(node: torch._C.Node, key: str):
"""Gets attributes of a node which is polymorphic over return type."""
sel = node.kindOf(key)
return getattr(node, sel)(key)

torch._C.Node.__getitem__ = _node_get

def dump_pytorch_graph(graph):
"""List all the nodes in a PyTorch graph."""
Expand Down