Skip to content

Commit

Permalink
[MetaSchedule] Improve Error Message in JSON Database (apache#11940)
Browse files Browse the repository at this point in the history
  • Loading branch information
junrushao authored Jun 29, 2022
1 parent 54f8176 commit 9ea681f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/meta_schedule/database/json_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,19 @@ Database Database::JSONDatabase(String path_workload, String path_tuning_record,
support::parallel_for_dynamic(
0, json_objs.size(), num_threads, [&](int thread_id, int task_id) {
const ObjectRef& json_obj = json_objs[task_id];
Workload workload{nullptr};
try {
const ArrayNode* arr = json_obj.as<ArrayNode>();
ICHECK_EQ(arr->size(), 2);
records[task_id] = TuningRecord::FromJSON(arr->at(1), //
workloads[Downcast<Integer>(arr->at(0))]);
workload = workloads[Downcast<Integer>(arr->at(0))];
records[task_id] = TuningRecord::FromJSON(arr->at(1), workload);
} catch (std::runtime_error& e) {
LOG(FATAL) << "ValueError: Unable to parse the JSON object: " << json_obj
<< "\nThe error is: " << e.what();
LOG(FATAL) << "ValueError: Unable to parse TuningRecord, on line " << (task_id + 1)
<< " of file " << path_tuning_record << ". The workload is:\n"
<< (workload.defined() ? tir::AsTVMScript(workload) : "(null)")
<< "\nThe JSONObject of TuningRecrod is:\n"
<< json_obj << "\nThe error message is:\n"
<< e.what();
}
});
for (const TuningRecord& record : records) {
Expand Down

0 comments on commit 9ea681f

Please sign in to comment.