@@ -126,6 +126,15 @@ def pass_num(block) -> int:
126126 return block .get ('PassFinished' , DEFAULT_PASS )[0 ]['num' ]
127127
128128
129+ def try_first (block : Block , * event_ids ):
130+ for index , event_id in enumerate (event_ids ):
131+ try :
132+ return block [event_id ]
133+ except KeyError :
134+ if index == len (event_ids ) - 1 :
135+ raise
136+
137+
129138def extract_dag_info (logs : Logs ) -> Dict [str , List [List [DagInfo ]]]:
130139 dags = {}
131140
@@ -145,13 +154,10 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
145154
146155 for block in blocks :
147156 try :
148- try :
149- best_result = block .single ('BestResult' )
150- is_optimal = best_result ['optimal' ]
151- except KeyError :
152- best_result = block ['HeuristicResult' ][- 1 ]
153- is_optimal = best_result ['cost' ] == 0 or \
154- 'INFO: Marking SLIL list schedule as optimal due to zero PERP.' in block .raw_log
157+ best_result = try_first (block , 'BestResult' , 'HeuristicResult' )[- 1 ]
158+ best_result_info = try_first (block , 'DagSolvedOptimally' , 'DagTimedOut' , 'HeuristicResult' )[- 1 ]
159+ is_optimal = best_result .get ('optimal' , False ) or best_result ['cost' ] == 0 or \
160+ 'INFO: Marking SLIL list schedule as optimal due to zero PERP.' in block .raw_log
155161
156162 target_occ = block .single ('TargetOccupancy' )['target' ] if 'TargetOccupancy' in block else None
157163
@@ -164,7 +170,7 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
164170 relative_cost = best_result ['cost' ],
165171 length = best_result ['length' ],
166172 is_optimal = is_optimal ,
167- spill_cost = best_result ['spill_cost' ],
173+ spill_cost = best_result_info ['spill_cost' ],
168174 target_occupancy = target_occ ,
169175 ))
170176 except Exception as ex :
0 commit comments