Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 20 additions & 1 deletion graph_net/torch/backend/unstable_to_stable_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,26 @@ def _impl_unstable_to_stable_linalg_vector_norm(self, gm):

return gm

# replace this line with modification code for task 117 (torch._C._linalg.linalg_norm)
def _impl_unstable_to_stable_linalg_norm(self, gm):
"""
Convert torch._C._linalg.linalg_norm to torch.linalg.norm
"""
# Update graph nodes: replace torch._C._linalg.linalg_norm with torch.linalg.norm
issue_nodes = (
node
for node in gm.graph.nodes
if node.op == "call_function"
if hasattr(node.target, "__module__")
if node.target.__module__ == "torch._C._linalg"
if hasattr(node.target, "__name__")
if node.target.__name__ == "linalg_norm"
)
for node in issue_nodes:
node.target = torch.linalg.norm

# Recompile the graph
gm.recompile()
return gm

def _impl_unstable_to_stable_softplus(self, gm):
"""
Expand Down
2 changes: 1 addition & 1 deletion graph_net/torch/fx_graph_serialize_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def serialize_graph_module_to_str(gm: torch.fx.GraphModule) -> str:
(r"torch\._C\._fft\.fft_fftn\(", "torch.fft.fftn("),
(r"torch\._C\._special\.special_logit\(", "torch.special.logit("),
(r"torch\._C\._linalg\.linalg_vector_norm\(", "torch.linalg.vector_norm("),
# replace this line with modification code for task 117 (torch._C._linalg.linalg_norm)
(r"torch\._C\._linalg\.linalg_norm\(", "torch.linalg.norm("),
(r"torch\._C\._nn\.softplus\(", "torch.nn.functional.softplus("),
(r"torch\._C\._nn\.one_hot\(", "torch.nn.functional.one_hot("),
(r"torch\._C\._set_grad_enabled\(", "torch.set_grad_enabled("),
Expand Down