@@ -126,6 +126,15 @@ def pass_num(block) -> int:
126
126
return block .get ('PassFinished' , DEFAULT_PASS )[0 ]['num' ]
127
127
128
128
129
+ def find_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
+
129
138
def extract_dag_info (logs : Logs ) -> Dict [str , List [List [DagInfo ]]]:
130
139
dags = {}
131
140
@@ -145,13 +154,10 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
145
154
146
155
for block in blocks :
147
156
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 = find_first (block , 'BestResult' , 'HeuristicResult' )
158
+ best_result_info = find_first (block , 'DagSolvedOptimally' , 'DagTimedOut' , 'HeuristicResult' )
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
155
161
156
162
target_occ = block .single ('TargetOccupancy' )['target' ] if 'TargetOccupancy' in block else None
157
163
@@ -164,7 +170,7 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
164
170
relative_cost = best_result ['cost' ],
165
171
length = best_result ['length' ],
166
172
is_optimal = is_optimal ,
167
- spill_cost = best_result ['spill_cost' ],
173
+ spill_cost = best_result_info ['spill_cost' ],
168
174
target_occupancy = target_occ ,
169
175
))
170
176
except Exception as ex :
0 commit comments