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/08/21 08:25:46 UTC

[GitHub] [tvm] junrushao opened a new pull request, #12520: [MetaSchedule][UX] Make `Database` with-able

junrushao opened a new pull request, #12520:
URL: https://github.com/apache/tvm/pull/12520

   `ApplyHistoryBest` right now plays a role as the database adaptor to query inside the database. In fact, the logic could be simplified and users only have to deal with `Database` instead of this extra object.
   
   - [x] Add `EnterWithScope`/`ExitWithScope`/`Current` to Database
   - [ ] Migrate `te_filter_func`
   - [ ] Migrate `f_take_tuning_record`
   - [ ] Migrate `f_direct_dispatch`
   - [ ] Migrate `TECompiler` to use `Database`


-- 
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] junrushao commented on pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on PR #12520:
URL: https://github.com/apache/tvm/pull/12520#issuecomment-1228768928

   Also CC @sunggg @YuchenJin for updates on Relax side


-- 
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 diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
sunggg commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956439486


##########
python/tvm/meta_schedule/relay_integration.py:
##########
@@ -38,7 +36,7 @@ def extract_task_from_relay(
     opt_level: int = 3,
     pass_config: Optional[Dict[str, Any]] = None,
     disabled_pass: Optional[List[str]] = None,
-    te_filter_func: Union[str, None, Callable[[List[Tensor]], PrimFunc]] = None,
+    tir_converter: str = "default",

Review Comment:
   Do we pass `ffi_key` here? If so, it might be good to clarify in the comment. 



##########
python/tvm/meta_schedule/database/database.py:
##########
@@ -234,6 +234,71 @@ def __len__(self) -> int:
         """
         return _ffi_api.DatabaseSize(self)  # type: ignore # pylint: disable=no-member
 
+    def query_tuning_record(self, mod: IRModule, target: Target) -> Optional[TuningRecord]:

Review Comment:
   Nit: do we also have the APIs to fetch data other than the best one? Since database stores every record (we keep the records even though it is not the best one), maybe good to offer API to access them. Might be useful for certain cases like cost model research



##########
src/relay/backend/utils.cc:
##########
@@ -368,6 +371,71 @@ void BindParamsInModule(IRModule mod, Map<String, runtime::NDArray> params) {
   BindParamsInModule(mod, params_tmp);
 }
 
+Optional<tir::PrimFunc> DefaultTIRConverterImpl(const Array<te::Tensor>& args,

Review Comment:
   Add some comments what this function does. 



##########
src/relay/backend/te_compiler_cache.cc:
##########
@@ -359,32 +350,43 @@ class ScheduleBuilder : public ExprVisitor {
           schedule = Downcast<te::Schedule>(obj);
         }
       }
-      if (meta_schedule_ctx_) {
+      if (database_) {
+        using tvm::meta_schedule::TuningRecord;
+        using tvm::tir::IndexMap;
+        using tvm::tir::Instruction;
+        using tvm::tir::InstructionKind;
+        using tvm::tir::PrimFunc;
+        using tvm::tir::Schedule;
+        backend::FTECompilerTIRConverter tir_converter = backend::GetTIRConverter();
         Array<te::Tensor> te_args = Concat(fn_inputs, tensor_outs);
         Array<runtime::NDArray> constants;
         for (auto [const_node, te_tensor] : lower_te_compute.constant_tensors_) {
           te_args.push_back(te_tensor);
           constants.push_back(const_node->data);
         }
-
-        if (Optional<tir::PrimFunc> tir_func =
-                meta_schedule_ctx_.value()->te_filter_func(te_args, constants)) {
-          IRModule relay_mod({{prim_fn_var, relay_func}});
-          IRModule tir_mod({{prim_fn_var, tir_func.value()}});
-          if (Optional<IRModule> opt_scheduled_mod = meta_schedule_ctx_.value()->Query(
-                  /*task_name=*/prim_fn_var->name_hint,     //
-                  /*mod=*/relay_mod,                        //
-                  /*target=*/target_,                       //
-                  /*dispatched=*/Array<IRModule>{tir_mod},  //
-                  /*f_take_tuning_record=*/ExtractTransformLayout)) {
-            IRModule scheduled_mod =
-                tir::transform::RemoveWeightLayoutRewriteBlock()(opt_scheduled_mod.value());
-            ICHECK_EQ(scheduled_mod->functions.count(prim_fn_var), 1);
-            prim_func = Downcast<tir::PrimFunc>(scheduled_mod->functions[prim_fn_var]);
+        if (Optional<PrimFunc> f = tir_converter(te_args, constants)) {
+          if (Optional<TuningRecord> opt_record = database_.value()->QueryTuningRecord(

Review Comment:
   What is the fallback strategy for meta_schedule if schedule is not found in the DB? 



##########
src/relay/backend/te_compiler_cache.cc:
##########
@@ -359,32 +350,43 @@ class ScheduleBuilder : public ExprVisitor {
           schedule = Downcast<te::Schedule>(obj);
         }
       }
-      if (meta_schedule_ctx_) {
+      if (database_) {
+        using tvm::meta_schedule::TuningRecord;
+        using tvm::tir::IndexMap;
+        using tvm::tir::Instruction;
+        using tvm::tir::InstructionKind;
+        using tvm::tir::PrimFunc;
+        using tvm::tir::Schedule;
+        backend::FTECompilerTIRConverter tir_converter = backend::GetTIRConverter();
         Array<te::Tensor> te_args = Concat(fn_inputs, tensor_outs);
         Array<runtime::NDArray> constants;
         for (auto [const_node, te_tensor] : lower_te_compute.constant_tensors_) {
           te_args.push_back(te_tensor);
           constants.push_back(const_node->data);
         }
-
-        if (Optional<tir::PrimFunc> tir_func =
-                meta_schedule_ctx_.value()->te_filter_func(te_args, constants)) {
-          IRModule relay_mod({{prim_fn_var, relay_func}});
-          IRModule tir_mod({{prim_fn_var, tir_func.value()}});
-          if (Optional<IRModule> opt_scheduled_mod = meta_schedule_ctx_.value()->Query(
-                  /*task_name=*/prim_fn_var->name_hint,     //
-                  /*mod=*/relay_mod,                        //
-                  /*target=*/target_,                       //
-                  /*dispatched=*/Array<IRModule>{tir_mod},  //
-                  /*f_take_tuning_record=*/ExtractTransformLayout)) {
-            IRModule scheduled_mod =
-                tir::transform::RemoveWeightLayoutRewriteBlock()(opt_scheduled_mod.value());
-            ICHECK_EQ(scheduled_mod->functions.count(prim_fn_var), 1);
-            prim_func = Downcast<tir::PrimFunc>(scheduled_mod->functions[prim_fn_var]);
+        if (Optional<PrimFunc> f = tir_converter(te_args, constants)) {
+          if (Optional<TuningRecord> opt_record = database_.value()->QueryTuningRecord(
+                  /*mod=*/backend::PrimFuncToIRModule(f.value()),
+                  /*target=*/target_)) {
+            static InstructionKind kind_transform_layout = InstructionKind::Get("TransformLayout");
+            TuningRecord record = opt_record.value();
+            for (const Instruction& inst : record->trace->insts) {
+              if (inst->kind.same_as(kind_transform_layout)) {
+                ICHECK_EQ(inst->attrs.size(), 3);
+                MetaScheduleLayoutRewriter::LayoutQueuePush(Downcast<IndexMap>(inst->attrs[2]));

Review Comment:
   Could you explain what this does?



-- 
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 diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
zxybazh commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956445903


##########
python/tvm/meta_schedule/database/database.py:
##########
@@ -234,6 +234,71 @@ def __len__(self) -> int:
         """
         return _ffi_api.DatabaseSize(self)  # type: ignore # pylint: disable=no-member
 
+    def query_tuning_record(self, mod: IRModule, target: Target) -> Optional[TuningRecord]:

Review Comment:
   I think we can access them with `get_top_k` function instead.



-- 
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] junrushao commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956484627


##########
src/relay/backend/te_compiler_cache.cc:
##########
@@ -359,32 +350,43 @@ class ScheduleBuilder : public ExprVisitor {
           schedule = Downcast<te::Schedule>(obj);
         }
       }
-      if (meta_schedule_ctx_) {
+      if (database_) {
+        using tvm::meta_schedule::TuningRecord;
+        using tvm::tir::IndexMap;
+        using tvm::tir::Instruction;
+        using tvm::tir::InstructionKind;
+        using tvm::tir::PrimFunc;
+        using tvm::tir::Schedule;
+        backend::FTECompilerTIRConverter tir_converter = backend::GetTIRConverter();
         Array<te::Tensor> te_args = Concat(fn_inputs, tensor_outs);
         Array<runtime::NDArray> constants;
         for (auto [const_node, te_tensor] : lower_te_compute.constant_tensors_) {
           te_args.push_back(te_tensor);
           constants.push_back(const_node->data);
         }
-
-        if (Optional<tir::PrimFunc> tir_func =
-                meta_schedule_ctx_.value()->te_filter_func(te_args, constants)) {
-          IRModule relay_mod({{prim_fn_var, relay_func}});
-          IRModule tir_mod({{prim_fn_var, tir_func.value()}});
-          if (Optional<IRModule> opt_scheduled_mod = meta_schedule_ctx_.value()->Query(
-                  /*task_name=*/prim_fn_var->name_hint,     //
-                  /*mod=*/relay_mod,                        //
-                  /*target=*/target_,                       //
-                  /*dispatched=*/Array<IRModule>{tir_mod},  //
-                  /*f_take_tuning_record=*/ExtractTransformLayout)) {
-            IRModule scheduled_mod =
-                tir::transform::RemoveWeightLayoutRewriteBlock()(opt_scheduled_mod.value());
-            ICHECK_EQ(scheduled_mod->functions.count(prim_fn_var), 1);
-            prim_func = Downcast<tir::PrimFunc>(scheduled_mod->functions[prim_fn_var]);
+        if (Optional<PrimFunc> f = tir_converter(te_args, constants)) {
+          if (Optional<TuningRecord> opt_record = database_.value()->QueryTuningRecord(
+                  /*mod=*/backend::PrimFuncToIRModule(f.value()),
+                  /*target=*/target_)) {
+            static InstructionKind kind_transform_layout = InstructionKind::Get("TransformLayout");
+            TuningRecord record = opt_record.value();
+            for (const Instruction& inst : record->trace->insts) {
+              if (inst->kind.same_as(kind_transform_layout)) {
+                ICHECK_EQ(inst->attrs.size(), 3);
+                MetaScheduleLayoutRewriter::LayoutQueuePush(Downcast<IndexMap>(inst->attrs[2]));

Review Comment:
   Oh this is an extremely hacky version of weight layout rewriting on CPU



-- 
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] junrushao commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956469782


##########
src/meta_schedule/database/database.cc:
##########
@@ -154,6 +154,59 @@ TuningRecord TuningRecord::FromJSON(const ObjectRef& json_obj, const Workload& w
   return TuningRecord(trace, workload, run_secs, target, args_info);
 }
 
+/******** Database ********/
+
+Optional<TuningRecord> DatabaseNode::QueryTuningRecord(IRModule mod, Target target) {

Review Comment:
   that makes sense!



-- 
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] MasterJH5574 commented on pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
MasterJH5574 commented on PR #12520:
URL: https://github.com/apache/tvm/pull/12520#issuecomment-1229107472

   > > > Another problem I’m thinking about is.. What will happen if we have code
   > > > ```python
   > > > with database_0, database_1:
   > > >     ...
   > > > ```
   > > > 
   > > > 
   > > >     
   > > >       
   > > >     
   > > > 
   > > >       
   > > >     
   > > > 
   > > >     
   > > >   
   > > > If we query the best record in the “with” body, looks like the current impl will only looking for records in `database_2`, rather than looking for record from both databases?
   > > 
   > > 
   > > I think if we have a way to merge several databases, we can agree that we only support `with database:` (one database).
   > 
   > @MasterJH5574 @masahi Great discussion here! We will introduced `JoinedDatabase` in the near future to cater such needs
   
   @junrushao Sounds a great idea. Thanks in advance!


-- 
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 diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
zxybazh commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956421893


##########
include/tvm/meta_schedule/database.h:
##########
@@ -203,6 +203,27 @@ class DatabaseNode : public runtime::Object {
    * \return The size of the database.
    */
   virtual int64_t Size() = 0;
+  /*!
+   * \brief Query the best record of the given workload from the database.
+   * \param mod The IRModule to be searched for.
+   * \param target The target to be searched for.
+   * \return The best record of the given workload; NullOpt if not found.
+   */
+  virtual Optional<TuningRecord> QueryTuningRecord(IRModule mod, Target target);
+  /*!
+   * \brief Query the best record of the given workload from the database.

Review Comment:
   Ditto, `record` -> `Schedule`



##########
src/meta_schedule/database/database.cc:
##########
@@ -154,6 +154,59 @@ TuningRecord TuningRecord::FromJSON(const ObjectRef& json_obj, const Workload& w
   return TuningRecord(trace, workload, run_secs, target, args_info);
 }
 
+/******** Database ********/
+
+Optional<TuningRecord> DatabaseNode::QueryTuningRecord(IRModule mod, Target target) {

Review Comment:
   We may want to add a target comparison function to distinguish between the target given here in the future.



-- 
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] junrushao commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956486647


##########
src/relay/backend/te_compiler_cache.cc:
##########
@@ -359,32 +350,43 @@ class ScheduleBuilder : public ExprVisitor {
           schedule = Downcast<te::Schedule>(obj);
         }
       }
-      if (meta_schedule_ctx_) {
+      if (database_) {
+        using tvm::meta_schedule::TuningRecord;
+        using tvm::tir::IndexMap;
+        using tvm::tir::Instruction;
+        using tvm::tir::InstructionKind;
+        using tvm::tir::PrimFunc;
+        using tvm::tir::Schedule;
+        backend::FTECompilerTIRConverter tir_converter = backend::GetTIRConverter();
         Array<te::Tensor> te_args = Concat(fn_inputs, tensor_outs);
         Array<runtime::NDArray> constants;
         for (auto [const_node, te_tensor] : lower_te_compute.constant_tensors_) {
           te_args.push_back(te_tensor);
           constants.push_back(const_node->data);
         }
-
-        if (Optional<tir::PrimFunc> tir_func =
-                meta_schedule_ctx_.value()->te_filter_func(te_args, constants)) {
-          IRModule relay_mod({{prim_fn_var, relay_func}});
-          IRModule tir_mod({{prim_fn_var, tir_func.value()}});
-          if (Optional<IRModule> opt_scheduled_mod = meta_schedule_ctx_.value()->Query(
-                  /*task_name=*/prim_fn_var->name_hint,     //
-                  /*mod=*/relay_mod,                        //
-                  /*target=*/target_,                       //
-                  /*dispatched=*/Array<IRModule>{tir_mod},  //
-                  /*f_take_tuning_record=*/ExtractTransformLayout)) {
-            IRModule scheduled_mod =
-                tir::transform::RemoveWeightLayoutRewriteBlock()(opt_scheduled_mod.value());
-            ICHECK_EQ(scheduled_mod->functions.count(prim_fn_var), 1);
-            prim_func = Downcast<tir::PrimFunc>(scheduled_mod->functions[prim_fn_var]);
+        if (Optional<PrimFunc> f = tir_converter(te_args, constants)) {
+          if (Optional<TuningRecord> opt_record = database_.value()->QueryTuningRecord(

Review Comment:
   In TECompiler, it falls back to default schedules defined in TOPI directly. We want to support joined database as Masa suggested [here](https://github.com/apache/tvm/pull/12520#issuecomment-1228888860) in the near future for falling back to other databases



-- 
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] MasterJH5574 merged pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
MasterJH5574 merged PR #12520:
URL: https://github.com/apache/tvm/pull/12520


-- 
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] junrushao commented on pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on PR #12520:
URL: https://github.com/apache/tvm/pull/12520#issuecomment-1229313710

   @tqchen Sure `join` doesn't look like a proper name. Perhaps `ms.database.MergedDatabase` sounds better?


-- 
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] masahi commented on pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
masahi commented on PR #12520:
URL: https://github.com/apache/tvm/pull/12520#issuecomment-1228888860

    
   
   
   
   > Another problem I’m thinking about is.. What will happen if we have code
   > 
   > ```python
   > with database_0, database_1:
   >     ...
   > ```
   > 
   > If we query the best record in the “with” body, looks like the current impl will only looking for records in `database_2`, rather than looking for record from both databases?
   
   
   I think if we have a way to merge several databases, we can agree that we only support `with database:`.


-- 
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] tqchen commented on pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
tqchen commented on PR #12520:
URL: https://github.com/apache/tvm/pull/12520#issuecomment-1229201645

   One minor nit on naming :) Join have a separate meaning and in this case perhaps concat(or merge) is more appropriate. Try lookup the terminology in pandas 


-- 
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] junrushao commented on pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on PR #12520:
URL: https://github.com/apache/tvm/pull/12520#issuecomment-1229029253

   > > Another problem I’m thinking about is.. What will happen if we have code
   > > ```python
   > > with database_0, database_1:
   > >     ...
   > > ```
   > >   
   > > If we query the best record in the “with” body, looks like the current impl will only looking for records in `database_2`, rather than looking for record from both databases?
   > 
   > I think if we have a way to merge several databases, we can agree that we only support `with database:` (one database).
   
   @MasterJH5574 @masahi Great discussion here! We will introduced `JoinedDatabase` in the near future to cater such needs


-- 
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] junrushao commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956482325


##########
python/tvm/meta_schedule/database/database.py:
##########
@@ -234,6 +234,71 @@ def __len__(self) -> int:
         """
         return _ffi_api.DatabaseSize(self)  # type: ignore # pylint: disable=no-member
 
+    def query_tuning_record(self, mod: IRModule, target: Target) -> Optional[TuningRecord]:

Review Comment:
   Yes we expose `get_top_k` and `get_all_tuning_records` APIs, but it's supposed to be less used than `query_*`



-- 
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] junrushao commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956481938


##########
python/tvm/meta_schedule/relay_integration.py:
##########
@@ -38,7 +36,7 @@ def extract_task_from_relay(
     opt_level: int = 3,
     pass_config: Optional[Dict[str, Any]] = None,
     disabled_pass: Optional[List[str]] = None,
-    te_filter_func: Union[str, None, Callable[[List[Tensor]], PrimFunc]] = None,
+    tir_converter: str = "default",

Review Comment:
   Oh looks like I missed the doc here! Added a few lines to explain



-- 
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] junrushao commented on pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on PR #12520:
URL: https://github.com/apache/tvm/pull/12520#issuecomment-1228691947

   CC: @masahi @Hzfengsy @spectrometerHBH @vinx13 


-- 
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] junrushao commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956467610


##########
include/tvm/meta_schedule/database.h:
##########
@@ -203,6 +203,27 @@ class DatabaseNode : public runtime::Object {
    * \return The size of the database.
    */
   virtual int64_t Size() = 0;
+  /*!
+   * \brief Query the best record of the given workload from the database.
+   * \param mod The IRModule to be searched for.
+   * \param target The target to be searched for.
+   * \return The best record of the given workload; NullOpt if not found.
+   */
+  virtual Optional<TuningRecord> QueryTuningRecord(IRModule mod, Target target);
+  /*!
+   * \brief Query the best record of the given workload from the database.

Review Comment:
   thanks for spotting this!



-- 
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] junrushao commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956487986


##########
src/relay/backend/utils.cc:
##########
@@ -368,6 +371,71 @@ void BindParamsInModule(IRModule mod, Map<String, runtime::NDArray> params) {
   BindParamsInModule(mod, params_tmp);
 }
 
+Optional<tir::PrimFunc> DefaultTIRConverterImpl(const Array<te::Tensor>& args,

Review Comment:
   added!



-- 
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] MasterJH5574 commented on a diff in pull request #12520: [MetaSchedule][UX] Make `Database` with-able

Posted by GitBox <gi...@apache.org>.
MasterJH5574 commented on code in PR #12520:
URL: https://github.com/apache/tvm/pull/12520#discussion_r956343006


##########
include/tvm/meta_schedule/database.h:
##########
@@ -203,6 +203,27 @@ class DatabaseNode : public runtime::Object {
    * \return The size of the database.
    */
   virtual int64_t Size() = 0;
+  /*!
+   * \brief Query the best record of the given workload from the database.
+   * \param mod The IRModule to be searched for.
+   * \param target The target to be searched for.
+   * \return The best record of the given workload; NullOpt if not found.
+   */
+  virtual Optional<TuningRecord> QueryTuningRecord(IRModule mod, Target target);
+  /*!
+   * \brief Query the best record of the given workload from the database.
+   * \param mod The IRModule to be searched for.
+   * \param target The target to be searched for.
+   * \return The schedule in the best record of the given workload; NullOpt if not found.
+   */
+  virtual Optional<tir::Schedule> QuerySchedule(IRModule mod, Target target);
+  /*!
+   * \brief Query the best record of the given workload from the database.

Review Comment:
   ```suggestion
      * \brief Query the best IRModule of the given workload from the database.
   ```



##########
include/tvm/meta_schedule/database.h:
##########
@@ -203,6 +203,27 @@ class DatabaseNode : public runtime::Object {
    * \return The size of the database.
    */
   virtual int64_t Size() = 0;
+  /*!
+   * \brief Query the best record of the given workload from the database.
+   * \param mod The IRModule to be searched for.
+   * \param target The target to be searched for.
+   * \return The best record of the given workload; NullOpt if not found.
+   */
+  virtual Optional<TuningRecord> QueryTuningRecord(IRModule mod, Target target);
+  /*!
+   * \brief Query the best record of the given workload from the database.

Review Comment:
   ```suggestion
      * \brief Query the best schedule of the given workload from the database.
   ```



-- 
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