Skip to content

Commit df1ea34

Browse files
committed
find the biggest fully fusable subgraph in a given graph
1 parent 0a0d713 commit df1ea34

File tree

6 files changed

+11
-93
lines changed

6 files changed

+11
-93
lines changed

graph_net/torch/fully_fusable_subgraph_extractor.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ def _get_sub_ranges(self):
6666
), f"Invalid range generated: start={start_pos}, end={end_pos}, max={self.config['max_nodes']}"
6767
yield start_pos, end_pos
6868

69+
def _handle_success(self, temp_dir: str, start_pos: int, end_pos: int) -> str:
70+
target_name = f"{self.name}_start{start_pos}_end{end_pos}"
71+
target_path = os.path.join(
72+
self.config["output_dir"],
73+
target_name,
74+
)
75+
os.makedirs(target_path, exist_ok=True)
76+
shutil.move(temp_dir, target_path)
77+
return target_path
78+
6979
def _build_decompose_config(
7080
self, temp_dir: str, start_pos: int, end_pos: int
7181
) -> dict:
@@ -103,12 +113,7 @@ def __call__(self, gm: torch.fx.GraphModule, sample_inputs):
103113
self.config["model_path"]
104114
)
105115
if success:
106-
target_path = os.path.join(
107-
self.config["output_dir"],
108-
f"{self.name}_start{start_pos}_end{end_pos}",
109-
)
110-
os.makedirs(target_path, exist_ok=True)
111-
shutil.move(temp_dir, target_path)
116+
target_path = self._handle_success(temp_dir, start_pos, end_pos)
112117
print(
113118
f"SUCCESS in finding the biggest fully fusable subgraph. Result saved to: {target_path}"
114119
)

successful_subgraphs_output/_find_fusable_subgraphmabgk0wg/resnet18_0/graph_net.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

successful_subgraphs_output/_find_fusable_subgraphmabgk0wg/resnet18_0/input_meta.py

Whitespace-only changes.

successful_subgraphs_output/_find_fusable_subgraphmabgk0wg/resnet18_0/input_tensor_constraints.py

Whitespace-only changes.

successful_subgraphs_output/_find_fusable_subgraphmabgk0wg/resnet18_0/model.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

successful_subgraphs_output/_find_fusable_subgraphmabgk0wg/resnet18_0/weight_meta.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)