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/09/15 18:58:24 UTC
[GitHub] [tvm] zxybazh opened a new pull request, #12796: [MetaSchedule] Enable Clone Function for Task-Level Classes
zxybazh opened a new pull request, #12796:
URL: https://github.com/apache/tvm/pull/12796
This PR introduces a clone function for each of the task-level MetaSchedule classes for convenient class deep copying.
- [x] ScheduleRule
- [ ] Postproc
- [ ] Mutator
- [ ] SpaceGenerator
- [ ] SearchStrategy
- [ ] TuneContext
--
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 #12796: [MetaSchedule] Enable Clone Function for Task-Level Classes
Posted by GitBox <gi...@apache.org>.
junrushao commented on PR #12796:
URL: https://github.com/apache/tvm/pull/12796#issuecomment-1248886455
This is used for enhancing UX of the tuning. Considering the current `tune` API:
https://github.com/apache/tvm/blob/370abe69d24519a5453cead846d328a1c378957f/tests/python/integration/test_meta_schedule_auto_tensorize.py#L174-L175
where users have to provide a lambda function, has become a bit confusing and inconvenient, we want to make it possible for users to directly provide a single object, and our system takes care of cloning
--
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 #12796: [MetaSchedule] Enable Clone Function for Task-Level Classes
Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12796:
URL: https://github.com/apache/tvm/pull/12796#discussion_r972614488
##########
src/meta_schedule/tune_context.cc:
##########
@@ -52,6 +52,32 @@ TuneContext::TuneContext(Optional<IRModule> mod,
data_ = std::move(n);
}
+TuneContext TuneContextNode::Clone() const {
+ ObjectPtr<TuneContextNode> n = make_object<TuneContextNode>(*this);
+ if (this->sch_rules.defined()) {
+ n->sch_rules = Array<ScheduleRule>();
+ for (const ScheduleRule& sch_rule : this->sch_rules) {
+ n->sch_rules.push_back(sch_rule->Clone());
+ }
+ }
+ if (this->postprocs.defined()) {
+ n->postprocs = Array<Postproc>();
+ for (const Postproc& postproc : this->postprocs) {
+ n->postprocs.push_back(postproc->Clone());
+ }
+ }
+ if (this->mutator_probs.defined()) {
+ n->mutator_probs = Map<Mutator, FloatImm>();
+ for (const auto& kv : this->mutator_probs) {
+ n->mutator_probs.Set(kv.first->Clone(), kv.second);
+ }
+ }
+ if (this->space_generator.defined()) n->space_generator = this->space_generator.value()->Clone();
+ if (this->search_strategy.defined()) n->search_strategy = this->search_strategy.value()->Clone();
+ n->Initialize();
Review Comment:
Let's fork the random state instead of copying 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] zxybazh commented on a diff in pull request #12796: [MetaSchedule] Enable Clone Function for Task-Level Classes
Posted by GitBox <gi...@apache.org>.
zxybazh commented on code in PR #12796:
URL: https://github.com/apache/tvm/pull/12796#discussion_r972617865
##########
src/meta_schedule/tune_context.cc:
##########
@@ -52,6 +52,32 @@ TuneContext::TuneContext(Optional<IRModule> mod,
data_ = std::move(n);
}
+TuneContext TuneContextNode::Clone() const {
+ ObjectPtr<TuneContextNode> n = make_object<TuneContextNode>(*this);
+ if (this->sch_rules.defined()) {
+ n->sch_rules = Array<ScheduleRule>();
+ for (const ScheduleRule& sch_rule : this->sch_rules) {
+ n->sch_rules.push_back(sch_rule->Clone());
+ }
+ }
+ if (this->postprocs.defined()) {
+ n->postprocs = Array<Postproc>();
+ for (const Postproc& postproc : this->postprocs) {
+ n->postprocs.push_back(postproc->Clone());
+ }
+ }
+ if (this->mutator_probs.defined()) {
+ n->mutator_probs = Map<Mutator, FloatImm>();
+ for (const auto& kv : this->mutator_probs) {
+ n->mutator_probs.Set(kv.first->Clone(), kv.second);
+ }
+ }
+ if (this->space_generator.defined()) n->space_generator = this->space_generator.value()->Clone();
+ if (this->search_strategy.defined()) n->search_strategy = this->search_strategy.value()->Clone();
+ n->Initialize();
Review Comment:
Sounds good to me!
--
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 merged pull request #12796: [MetaSchedule] Enable Clone Function for Task-Level Classes
Posted by GitBox <gi...@apache.org>.
junrushao merged PR #12796:
URL: https://github.com/apache/tvm/pull/12796
--
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 #12796: [MetaSchedule] Enable Clone Function for Task-Level Classes
Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12796:
URL: https://github.com/apache/tvm/pull/12796#discussion_r972410804
##########
src/meta_schedule/schedule_rule/add_rfactor.cc:
##########
@@ -36,6 +36,16 @@ class AddRFactorNode : public ScheduleRuleNode {
// Inherited from ScheduleRuleNode
Array<tir::Schedule> Apply(const tir::Schedule& sch, const tir::BlockRV& block_rv);
+ // Inherited from ScheduleRuleNode
+ ScheduleRule Clone() final {
+ ObjectPtr<AddRFactorNode> n = make_object<AddRFactorNode>(*this);
+ n->max_jobs_per_core = this->max_jobs_per_core;
+ n->max_innermost_factor = this->max_innermost_factor;
+ n->max_parallel_extent_ = this->max_parallel_extent_;
+ n->max_parallel_basic_ = this->max_parallel_basic_;
Review Comment:
Those fields are already copied in `make_object<AddRFactorNode>(*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] Hzfengsy commented on pull request #12796: [MetaSchedule] Enable Clone Function for Task-Level Classes
Posted by GitBox <gi...@apache.org>.
Hzfengsy commented on PR #12796:
URL: https://github.com/apache/tvm/pull/12796#issuecomment-1248826403
Could you please explain a bit about why we need `clone` these structures?
Cloning a function or a module makes sense to me. But I'm not sure why we need to clone a rule or a mutator.
Could you please also add more information to the PR description? Thanks
--
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