You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "chunit-quic (via GitHub)" <gi...@apache.org> on 2023/03/02 04:37:12 UTC
[GitHub] [tvm] chunit-quic opened a new pull request, #14168: [TE] Record primitives of Schedule for visualization
chunit-quic opened a new pull request, #14168:
URL: https://github.com/apache/tvm/pull/14168
- Make Stage link to its Schedule via attach_sch.
- Add two array attributes, primitive_record and schedule_record to Schedule.
- Create a new class, ScheduleContext, to record primitives.
- Register a pass config variable, keep_schedule_record to enable/disable the recording.
- Add test cases for TEDD, build_module and schedule ops.
--
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] tvm-bot commented on pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #14168:
URL: https://github.com/apache/tvm/pull/14168#issuecomment-1451288166
<!---bot-comment-->
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
<!--bot-comment-ccs-start-->
* cc @junrushao <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
<sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>
--
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 a diff in pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "masahi (via GitHub)" <gi...@apache.org>.
masahi commented on code in PR #14168:
URL: https://github.com/apache/tvm/pull/14168#discussion_r1133606097
##########
include/tvm/te/schedule.h:
##########
@@ -445,6 +446,26 @@ class Schedule : public ObjectRef {
using ContainerType = ScheduleNode;
};
+/*!
+ * \brief Context helper to collect debug information of Schedule.
+ *
+ * Attach With<ScheduleContext>(schedule_instance, primitive_name)
+ * inside function body of schedule primitives to collect the
+ * snapshot of schedule status and corresponding primitive name
+ */
+class ScheduleContext {
+ private:
+ friend class With<ScheduleContext>;
+ ScheduleContext(const ScheduleNode* sch_node, String current_primitive_name);
+ void EnterWithScope();
+ void ExitWithScope();
+
+ /*! \brief the Schedule instance to store debug information */
Review Comment:
information for
##########
include/tvm/te/schedule.h:
##########
@@ -546,6 +567,8 @@ class StageNode : public Object {
IterVar attach_ivar;
/*! \brief The stage this node attaches to */
Stage attach_stage;
+ /*! \brief The schedule of current stage attaches to */
+ const ScheduleNode* attach_sch;
Review Comment:
The schedule the current stage is attached to
##########
python/tvm/contrib/tedd.py:
##########
@@ -78,6 +78,30 @@ def insert_dot_id(sch):
return sch
+def itervar_equal(iv_a, iv_b):
+ """A helper method that compares the equality of two iterative variables"""
+ # after schedule.normalize was called, domains of iterative variables inside
+ # stage.leaf_iter_vars would be discarded and expected to be inferred in later
+ # InferBound call
+ # this rebase behavior would make plain comparison fail (i.e. ivar == itervar)
Review Comment:
What is "rebase behavior"
##########
include/tvm/te/schedule.h:
##########
@@ -445,6 +446,26 @@ class Schedule : public ObjectRef {
using ContainerType = ScheduleNode;
};
+/*!
+ * \brief Context helper to collect debug information of Schedule.
+ *
+ * Attach With<ScheduleContext>(schedule_instance, primitive_name)
+ * inside function body of schedule primitives to collect the
+ * snapshot of schedule status and corresponding primitive name
+ */
+class ScheduleContext {
+ private:
+ friend class With<ScheduleContext>;
+ ScheduleContext(const ScheduleNode* sch_node, String current_primitive_name);
+ void EnterWithScope();
+ void ExitWithScope();
+
+ /*! \brief the Schedule instance to store debug information */
+ Schedule sch_;
+ /*! \brief string represents which primitive applied to Schedule */
Review Comment:
String representing which primitive has been applied to sch_
##########
include/tvm/te/schedule.h:
##########
@@ -615,12 +638,32 @@ class ScheduleNode : public Object {
* This is created on demand and can be invalidated.
*/
std::unordered_map<const Object*, Stage> op2stage_cache_;
+ /*!
+ * \brief list of all schedules during primitives applied to stages.
Review Comment:
Broken sentence.
--
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 merged pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "masahi (via GitHub)" <gi...@apache.org>.
masahi merged PR #14168:
URL: https://github.com/apache/tvm/pull/14168
--
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] chunit-quic commented on a diff in pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "chunit-quic (via GitHub)" <gi...@apache.org>.
chunit-quic commented on code in PR #14168:
URL: https://github.com/apache/tvm/pull/14168#discussion_r1134882787
##########
python/tvm/contrib/tedd.py:
##########
@@ -78,6 +78,30 @@ def insert_dot_id(sch):
return sch
+def itervar_equal(iv_a, iv_b):
+ """A helper method that compares the equality of two iterative variables"""
+ # after schedule.normalize was called, domains of iterative variables inside
+ # stage.leaf_iter_vars would be discarded and expected to be inferred in later
+ # InferBound call
+ # this rebase behavior would make plain comparison fail (i.e. ivar == itervar)
Review Comment:
Hi masahi,
Sorry for the unclear statement.
The rebase behavior here means the new bounds of iterative variables, which is rebased from InferBound. Because original way (iter_var1 == inter_var2) would fail after invoking InferBound. We apply a new way to compare iterative variables.
--
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] chunit-quic commented on pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "chunit-quic (via GitHub)" <gi...@apache.org>.
chunit-quic commented on PR #14168:
URL: https://github.com/apache/tvm/pull/14168#issuecomment-1451289044
Hi community,
This is second part of TVM Explorer infrastructures. After this patch, user can backtrack what
(schedule) primitives have been applied to a schedule. Pair with the tool, TEDD, these changes can
be visualized beautifully.
To give you more context, we briefly describe what have been done below in this PR. Here is the
list of main modifications:
1. Make a Stage know which Schedule it belongs to.
2. Add two attributes, primitive_record and schedule_record to Schedule.
3. Create a new class, ScheduleContext, to record primitive in the RAII way.
4. Register a pass config variable, keep_schedule_record to enable/disable the recording.
Everytime a Stage being modified by a primitive, we will use ScheduleContext to record the optimized schedule and corresponding primitive. So that we can obtain the modification sequence later. You can reference to [preRFC](https://discuss.tvm.apache.org/t/pre-rfc-tvm-explorer-infrastructure/13457#schedulestage-visualization-enhancement-7) for more details. Thanks!
#
For your reference, here is the related links.
[PreRFC in forum](https://discuss.tvm.apache.org/t/pre-rfc-tvm-explorer-infrastructure/13457/24)
https://github.com/apache/tvm-rfcs/pull/92
https://github.com/apache/tvm/issues/13116
[@haowhsu-quic](https://github.com/haowhsu-quic), [@zack-ch](https://github.com/zack-ch)
--
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] chunit-quic commented on pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "chunit-quic (via GitHub)" <gi...@apache.org>.
chunit-quic commented on PR #14168:
URL: https://github.com/apache/tvm/pull/14168#issuecomment-1465400935
Hi @Hzfengsy,
> LGTM. But I'm not confident to explicitly approve it since I'm not an expert on TE
Thank you for reviewing! May I know is there any recommended person who could help to review this topic? :)
Hi @masahi,
Sorry to bother you, because I saw you dealt with some TE related PRs, and had checked the RFC of Explorer before. Would you mind to take a look at this PR and give us some feedbacks? Thank you. :D
--
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] chunit-quic commented on a diff in pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "chunit-quic (via GitHub)" <gi...@apache.org>.
chunit-quic commented on code in PR #14168:
URL: https://github.com/apache/tvm/pull/14168#discussion_r1134943348
##########
python/tvm/contrib/tedd.py:
##########
@@ -78,6 +78,30 @@ def insert_dot_id(sch):
return sch
+def itervar_equal(iv_a, iv_b):
+ """A helper method that compares the equality of two iterative variables"""
+ # after schedule.normalize was called, domains of iterative variables inside
+ # stage.leaf_iter_vars would be discarded and expected to be inferred in later
+ # InferBound call
+ # this rebase behavior would make plain comparison fail (i.e. ivar == itervar)
Review Comment:
I see, thank you a lot for kindly point out the problem for us. :D
Really sorry for using a wrong term here. We remove the term of "rebase", and rephrase the comments a bit in the new patch.
--
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] chunit-quic commented on pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "chunit-quic (via GitHub)" <gi...@apache.org>.
chunit-quic commented on PR #14168:
URL: https://github.com/apache/tvm/pull/14168#issuecomment-1467294211
> Please fix basic grammar issues.
Hi @masahi,
Thank you very much for reviewing!
We're pretty sorry for basic issues of documentation.
We have rewritten those parts in comments. If there is still anything unclear we would try to reword them at once.
Thank you!
--
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] chunit-quic commented on pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "chunit-quic (via GitHub)" <gi...@apache.org>.
chunit-quic commented on PR #14168:
URL: https://github.com/apache/tvm/pull/14168#issuecomment-1465423397
> Thanks, @chunit-quic for the PR. I explicitly approve this PR after another look. Let's merge it in 24h if there are no other objectives.
No problem. Thanks a lot for helping us! :D
--
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 a diff in pull request #14168: [TE] Record primitives of Schedule for visualization
Posted by "masahi (via GitHub)" <gi...@apache.org>.
masahi commented on code in PR #14168:
URL: https://github.com/apache/tvm/pull/14168#discussion_r1134906672
##########
python/tvm/contrib/tedd.py:
##########
@@ -78,6 +78,30 @@ def insert_dot_id(sch):
return sch
+def itervar_equal(iv_a, iv_b):
+ """A helper method that compares the equality of two iterative variables"""
+ # after schedule.normalize was called, domains of iterative variables inside
+ # stage.leaf_iter_vars would be discarded and expected to be inferred in later
+ # InferBound call
+ # this rebase behavior would make plain comparison fail (i.e. ivar == itervar)
Review Comment:
I mean, I'm not asking for an explanation for me. This is not a conventional use of the term "rebase". Please do not use a term that requires long explanation in doc or code.
--
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