Skip to content

Commit 21d5850

Browse files
lixinqiroll-away
andauthored
Calculate num ops (#434)
* 1119 * 1120 * 1120.2 * model_path * remove unnecessary files and pre-committed * remove unnecessary files and pre-committed * 1121 remove unnecessary files * modify rev version * modify rev version * modify rev version * accuracy issues targeted * test script and modify feature * return set[str] * add logfile for test * filter can get the number of kernels in naive_graph_decomposer * post extract process feature * remove unnecessary code blocks and variables * modify the way of counting kernels used * modify the way of counting kernels used * modify script, rename files and variables * add failure protection and log output when removing directories * add a script to check fusability of a given model * add a script to check if a given model is fully fusable * add a script to check if a given model is fully fusable * a script to check if a given model is fully fusable * add a script to check if a given model is fully fusionable * add a script to find fully fusionable subgraph * find the biggest fully fusionable subgraph * get fusible subgraph test * modify get fully fusible subgraph * improve fully_fusible_subgraph_extractor.py efficiency * backup code * Improve efficiency of test/fully_fusible_subgraph_extractor_test.sh * check_graph_module_parsable * Calculate num ops --------- Co-authored-by: roll-away <[email protected]>
1 parent 07eaab2 commit 21d5850

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

graph_net/tools/check_graph_module_parsable.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ config_json_str=$(cat <<EOF
1111
"handler_path": "$GRAPH_NET_ROOT/torch/check_graph_module_parsable.py",
1212
"handler_class_name": "CheckGraphModuleParsable",
1313
"handler_config": {
14+
"resume": false,
1415
"model_path_prefix": "$GRAPH_NET_ROOT/../",
15-
"resume": true,
1616
"limits_handled_models": 999999,
1717
"output_dir": "/tmp/check_graph_module_parsable"
1818
}

graph_net/torch/check_graph_module_parsable.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ def __call__(self, rel_model_path):
3131
model_path = os.path.join(self.config["model_path_prefix"], rel_model_path)
3232
if self.config["resume"] and self._is_model_path_handled(rel_model_path):
3333
return
34-
parse_immutable_model_path_into_sole_graph_module(model_path)
34+
gm = parse_immutable_model_path_into_sole_graph_module(model_path)
3535
output_dir = Path(self.config["output_dir"]) / rel_model_path
3636
output_dir.mkdir(parents=True, exist_ok=True)
37+
(output_dir / "num_ops.txt").write_text(str(self._get_num_ops(gm)))
3738
self._inc_num_handled_models()
3839

40+
def _get_num_ops(self, gm):
41+
ignored = {"placeholder", "output"}
42+
return len([node for node in gm.graph.nodes if node.op not in ignored])
43+
3944
def _is_model_path_handled(self, rel_model_path):
4045
return (Path(self.config["output_dir"]) / rel_model_path).exists()
4146

0 commit comments

Comments
 (0)