-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[MetaSchedule][M4b] Add ApplyHisotryBest Meta Schedule Context
#10049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |
| #include <tvm/relay/function.h> | ||
| #include <tvm/tir/function.h> | ||
|
|
||
| #include "./utils.h" | ||
|
|
||
| namespace tvm { | ||
| namespace meta_schedule { | ||
|
|
||
|
|
@@ -112,7 +114,21 @@ ApplyHistoryBest::ApplyHistoryBest(Database database) { | |
|
|
||
| Optional<ObjectRef> ApplyHistoryBestNode::Query(runtime::String task_name, IRModule mod, | ||
| Optional<Array<IRModule>> dispatched) { | ||
| throw; | ||
| ICHECK(dispatched.defined()); | ||
| ICHECK_EQ(dispatched.value().size(), 1); | ||
| ICHECK(HasOnlyOneFunction<relay::Function>(mod)) << mod; | ||
| IRModule prim_mod = dispatched.value()[0]; | ||
| ICHECK(HasOnlyOneFunction<tir::PrimFunc>(prim_mod)) << prim_mod; | ||
| // Unify func name to make sure it can be found in database | ||
| prim_mod = UnifyFuncName(prim_mod); | ||
| if (database->HasWorkload(prim_mod)) { | ||
| Array<TuningRecord> records = database->GetTopK(database->CommitWorkload(prim_mod), 1); | ||
| if (records.size() == 1) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Here I don't think we need to do the check because
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that makes sense! Thanks for the answer! |
||
| LOG(INFO) << "Applied history best for " << task_name << "."; | ||
| return records[0]->workload->mod; | ||
| } | ||
| } | ||
| return NullOpt; | ||
| } | ||
|
|
||
| /**************** FFI ****************/ | ||
|
|
@@ -146,6 +162,10 @@ TVM_REGISTER_GLOBAL("meta_schedule.MetaScheduleContextQuery") | |
| TVM_REGISTER_GLOBAL("meta_schedule.TaskExtraction").set_body_typed([]() -> TaskExtraction { | ||
| return TaskExtraction(); | ||
| }); | ||
| TVM_REGISTER_GLOBAL("meta_schedule.ApplyHistoryBest") | ||
| .set_body_typed([](Database database) -> ApplyHistoryBest { | ||
| return ApplyHistoryBest(database); | ||
| }); | ||
|
|
||
| } // namespace meta_schedule | ||
| } // namespace tvm | ||
Uh oh!
There was an error while loading. Please reload this page.