Skip to content

Commit be43823

Browse files
authored
Generate graph_hash.txt for renamed graph (#429)
1 parent 8e928e2 commit be43823

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

graph_net/torch/graph_variable_renamer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import os
22
import torch
3+
import shutil
4+
import inspect
35
from graph_net.torch.fx_graph_module_util import get_torch_module_and_inputs
46
from graph_net.torch.fx_graph_parse_util import parse_sole_graph_module
57
from graph_net.tensor_meta import TensorMeta
68
from pathlib import Path
7-
import shutil
89
from graph_net.torch.utils import apply_templates
910
from graph_net.imp_util import load_module
10-
import inspect
11+
from graph_net.hash_util import get_sha256_hash
1112

1213

1314
class GraphVariableRenamer:
@@ -96,6 +97,8 @@ def _try_run(self, model_path):
9697
def _update_model_py_file(self, graph_module, model_path):
9798
py_code = apply_templates(graph_module.code)
9899
(Path(model_path) / "model.py").write_text(py_code)
100+
file_hash = get_sha256_hash(py_code)
101+
(Path(model_path) / "graph_hash.txt").write_text(file_hash)
99102

100103
def _update_weight_meta_py_file(self, src_model_path, dst_model_path):
101104
old_name_to_new_name = self._get_original_name_to_new_name(

0 commit comments

Comments
 (0)