Skip to content
This repository was archived by the owner on Jan 15, 2021. It is now read-only.

Commit f1b909c

Browse files
committed
[Feat] Update ResultCheck
1 parent d749cc0 commit f1b909c

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/SubgraphDetection/Util/check_result.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from mindinsight.datavisual.data_transform.graph import MSGraph
44

5-
from SubgraphDetection.DataStructure import SMSGraph
65
from SubgraphDetection.DataStructure import Subgraph
76

87

@@ -15,13 +14,7 @@ def __init__(self, graph: MSGraph, subgraph_deque: Deque[Subgraph]):
1514
subgraph_deque: The result
1615
"""
1716

18-
self.graph_size = len(
19-
tuple(
20-
node
21-
for node in graph._normal_node_map.values()
22-
if node.type not in set(SMSGraph.non_normal_node_type[:1])
23-
)
24-
)
17+
self.graph_size = len(graph._normal_node_map)
2518
self.num_subgraph = len(subgraph_deque)
2619
self.subgraph_size = tuple(len(g.nodes[0]) for g in subgraph_deque)
2720
self.subgraph_count = tuple(len(g.nodes) for g in subgraph_deque)

src/SubgraphDetection/__main__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import time
2-
from typing import Deque
2+
from typing import Deque, Union
33

44
from SubgraphDetection import __version__
55
from SubgraphDetection.DataStructure import Subgraph
@@ -9,7 +9,7 @@
99
from SubgraphDetection.config import CONFIG
1010

1111

12-
def detect_subgraph(graph_path, result_path, **kwargs) -> Deque[Subgraph]:
12+
def detect_subgraph(graph_path, result_path, **kwargs) -> Union[Deque[Subgraph], ResultCheck]:
1313
"""
1414
Detect the subgraph in a mindspore computational graph
1515
@@ -22,7 +22,8 @@ def detect_subgraph(graph_path, result_path, **kwargs) -> Deque[Subgraph]:
2222
**kwargs: Any other args will pass to config
2323
2424
Returns:
25-
Deque of subgraph, all the detected subgraphs
25+
Deque of subgraph, all the detected subgraphs.
26+
If CHECK_RESULT, it will return a ResultCheck object.
2627
"""
2728
time_st = time.time()
2829
CONFIG.set(kwargs)
@@ -31,13 +32,16 @@ def detect_subgraph(graph_path, result_path, **kwargs) -> Deque[Subgraph]:
3132
result = executor.run()
3233
dump_result(result, result_path)
3334

34-
if CONFIG.CHECK_RESULT:
35-
print(ResultCheck(graph, result))
3635
print(
3736
f"Detecting finished and result have been write to {result_path}, "
3837
f"total usage of time:{time.time() - time_st} s"
3938
)
40-
return result
39+
40+
if CONFIG.CHECK_RESULT:
41+
result_check = ResultCheck(graph, result)
42+
return result_check
43+
else:
44+
return result
4145

4246

4347
def detect_subgraph_in_console():

0 commit comments

Comments
 (0)