You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/01/24 21:36:42 UTC
[GitHub] [tvm] zxybazh opened a new pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
zxybazh opened a new pull request #10049:
URL: https://github.com/apache/tvm/pull/10049
This PR is part of the stage M4b of the meta schedule project (#8473).
The architecture is re-designed by Junru and Xiyou. In this PR we introduced `ApplyHistoryBest` meta schedule context to apply the best trace from given database when tuning given relay workload. Unittest is also added in this PR.
CC: @junrushao1994 @sunggg @YuchenJin
Thanks to all co-authors for contributing!
Co-authored-by: Junru Shao <<j...@gmail.com>>
Co-authored-by: Bohan Hou <<3...@users.noreply.github.com>>
Co-authored-by: Ruihang Lai <<l...@qq.com>>
Co-authored-by: Hongyi Jin <<3...@qq.com>>
Co-authored-by: Wuwei Lin <<w...@apache.org>>
Co-authored-by: Siyuan Feng <<H...@sjtu.edu.cn>>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao1994 commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791202376
##########
File path: src/meta_schedule/integration.cc
##########
@@ -20,6 +20,8 @@
#include <tvm/relay/function.h>
#include <tvm/tir/function.h>
+#include "./utils.h"
Review comment:
Yep we allow include relative path for headers internal under `src/`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao1994 commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791202376
##########
File path: src/meta_schedule/integration.cc
##########
@@ -20,6 +20,8 @@
#include <tvm/relay/function.h>
#include <tvm/tir/function.h>
+#include "./utils.h"
Review comment:
Yep we allow include relative path for headers internal under `src/`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] YuchenJin commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
YuchenJin commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791252645
##########
File path: src/meta_schedule/integration.cc
##########
@@ -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) {
Review comment:
Ah, that makes sense! Thanks for the answer!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] YuchenJin commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
YuchenJin commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791194100
##########
File path: src/meta_schedule/integration.cc
##########
@@ -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) {
Review comment:
Should we do `ICHECK_EQ(records.size(), 1)` here?
##########
File path: src/meta_schedule/integration.cc
##########
@@ -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) {
Review comment:
Ah, that makes sense! Thanks for the answer!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] zxybazh commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
zxybazh commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791241498
##########
File path: src/meta_schedule/integration.cc
##########
@@ -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) {
Review comment:
Good question. Here I don't think we need to do the check because `HasWorkload` implies the workload is in the workload registery but does not imply we have a valid tuning record with workload inside of the database. Therefore, I removed such check here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao1994 merged pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
junrushao1994 merged pull request #10049:
URL: https://github.com/apache/tvm/pull/10049
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] sunggg commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
sunggg commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791197306
##########
File path: src/meta_schedule/integration.cc
##########
@@ -20,6 +20,8 @@
#include <tvm/relay/function.h>
#include <tvm/tir/function.h>
+#include "./utils.h"
Review comment:
Do we allow relative path?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] YuchenJin commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
YuchenJin commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791194100
##########
File path: src/meta_schedule/integration.cc
##########
@@ -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) {
Review comment:
Should we do `ICHECK_EQ(records.size(), 1)` here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] sunggg commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
sunggg commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791197306
##########
File path: src/meta_schedule/integration.cc
##########
@@ -20,6 +20,8 @@
#include <tvm/relay/function.h>
#include <tvm/tir/function.h>
+#include "./utils.h"
Review comment:
Do we allow relative path?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] zxybazh commented on a change in pull request #10049: [Meta Schedule] Add `ApplyHisotryBest` Meta Schedule Context
Posted by GitBox <gi...@apache.org>.
zxybazh commented on a change in pull request #10049:
URL: https://github.com/apache/tvm/pull/10049#discussion_r791241498
##########
File path: src/meta_schedule/integration.cc
##########
@@ -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) {
Review comment:
Good question. Here I don't think we need to do the check because `HasWorkload` implies the workload is in the workload registery but does not imply we have a valid tuning record with workload inside of the database. Therefore, I removed such check here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org