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/11/18 14:39:52 UTC

[GitHub] [tvm] Lunderberg opened a new pull request, #13433: [TVMScript] Output elif where possible

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

   When a TIR `IfThenElseNode::else_case` is itself a `IfThenElse` node, it may be printed as `elif` instead of `else: if ...`.  The `elif` syntax was already handled on the parsing side, so this commit only changes the TVMScript printer.
   
   This change also incidentally altered the printer's output for an else block whose condition is `True`.  Previously, these were dropped from the output altogether.  Now, they are retained in the else block. Removing no-op statements should be done by a transformation pass, not a printer/parser round trip, so this change in behavior makes sense to keep.


-- 
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 #13433: [TVMScript] Output elif where possible

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


-- 
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 #13433: [TVMScript] Output elif where possible

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

   <!---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-->
    * No users to tag found in teams: `tvmscript` <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] shingjan commented on a diff in pull request #13433: [TVMScript] Output elif where possible

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


##########
src/printer/tvmscript_printer.cc:
##########
@@ -1259,10 +1259,22 @@ Doc TVMScriptPrinter::VisitStmt_(const IfThenElseNode* op) {
   Doc doc;
   doc << "if " << Print(op->condition) << ":";
   doc << Doc::Indent(4, Doc::NewLine() << PrintBody(op->then_case));
-  if (!is_one(op->condition) && op->else_case) {
-    doc << Doc::NewLine();
-    doc << "else:" << Doc::Indent(4, Doc::NewLine() << PrintBody(op->else_case.value()));
+
+  Optional<Stmt> else_case = op->else_case;

Review Comment:
   would that be possible that we can add a comment here or a code snippet in the PR to show the elif print before and after this change. Otherwise LGTM. 



-- 
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] Lunderberg commented on a diff in pull request #13433: [TVMScript] Output elif where possible

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


##########
src/printer/tvmscript_printer.cc:
##########
@@ -1259,10 +1259,22 @@ Doc TVMScriptPrinter::VisitStmt_(const IfThenElseNode* op) {
   Doc doc;
   doc << "if " << Print(op->condition) << ":";
   doc << Doc::Indent(4, Doc::NewLine() << PrintBody(op->then_case));
-  if (!is_one(op->condition) && op->else_case) {
-    doc << Doc::NewLine();
-    doc << "else:" << Doc::Indent(4, Doc::NewLine() << PrintBody(op->else_case.value()));
+
+  Optional<Stmt> else_case = op->else_case;

Review Comment:
   Certainly!  Added a quick example to the PR description.



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