11import time
2- from typing import Deque
2+ from typing import Deque , Union
33
44from SubgraphDetection import __version__
55from SubgraphDetection .DataStructure import Subgraph
99from 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
4347def detect_subgraph_in_console ():
0 commit comments