Skip to content

Commit 9a30aa7

Browse files
authored
add log (#145)
1 parent 0892d11 commit 9a30aa7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

graph_net/torch/single_device_runner.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import importlib.util
44
import inspect
55
import torch
6+
import logging
67
from pathlib import Path
78
from typing import Type, Any
89
import sys
@@ -65,6 +66,16 @@ def main(args):
6566
params = inputs_params["weight_info"]
6667
state_dict = {k: utils.replay_tensor(v) for k, v in params.items()}
6768

69+
explain = torch._dynamo.explain(model)(**state_dict)
70+
if explain.graph_count != 1 or len(explain.break_reasons) != 0:
71+
logging.error(
72+
f"Failed to generate a complete graph. The extraction process resulted in an incomplete graph, which was broken into {explain.graph_count} subgraphs."
73+
)
74+
logging.error(f"Reason(s): {explain.break_reasons}.")
75+
raise ValueError(
76+
f"Graph extraction failed. The resulting graph is incomplete, broken into {explain.graph_count} subgraphs."
77+
)
78+
6879
y = model(**state_dict)[0]
6980

7081
print(torch.argmin(y), torch.argmax(y))

0 commit comments

Comments
 (0)