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 2021/02/04 10:53:00 UTC

[GitHub] [tvm] Beya2019 opened a new pull request #7405: [TIR][Printer] Fix SelectNode TIRTextPrinter bracket mismatch

Beya2019 opened a new pull request #7405:
URL: https://github.com/apache/tvm/pull/7405


   1.TIRTextPrinter::VisitExpr_(const SelectNode* op) print miss matching closing parenthesis. When tvm::PrettyPrint is used, it will cause semantic misunderstanding.
    such as:
   Correct form:
   `(select((axis_k_w < 1), 0h, buffer1[((((axis_k_w*128)) + axis_c_in.inner) - 128)])*buffer2[((((axis_k_w*4096)) + (axis_c_in.inner*64)))])`
   
   Now Print Form(wrong):
   `(select((axis_k_w < 1), 0h, buffer1[((((axis_k_w*128)) + axis_c_in.inner) - 128)]*buffer2[((((axis_k_w*4096)) + (axis_c_in.inner*64)))])`
   
   2.Same as the `src/tir/ir/expr.cc` printing  form
   ```
   TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable)
       .set_dispatch<SelectNode>([](const ObjectRef& node, ReprPrinter* p) {
         auto* op = static_cast<const SelectNode*>(node.get());
         p->stream << "select(";
         p->Print(op->condition);
         p->stream << ", ";
         p->Print(op->true_value);
         p->stream << ", ";
         p->Print(op->false_value);
         p->stream << ")";
       });
   ```
   @tqchen @yzhliu  Would you please have a look at this? Thanks very much.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] Beya2019 edited a comment on pull request #7405: [TIR][Printer] Fix SelectNode TIRTextPrinter bracket mismatch

Posted by GitBox <gi...@apache.org>.
Beya2019 edited a comment on pull request #7405:
URL: https://github.com/apache/tvm/pull/7405#issuecomment-773741386


   > Nice catch! Is it possible to add unit test to avoid this?
   
   There are ready-made test cases in tvm, tests/python/unittest/test_target_codegen_opencl.py->test_opencl_ternary_expression()->check_select(), we only need add a print message in L51-L52:
   `print(tvm.lower(s, [A, C]))`
   
   Capture part of the printed information:
   **Before this submit:**
   ```
   primfn(A_1: handle, C_1: handle) -> ()
     attr = {"global_symbol": "main", "tir.noalias": True}
     buffers = {C: Buffer(C_2: Pointer(int16), int16, [1], []),
                A: Buffer(A_2: Pointer(int16), int16, [1], [])}
     buffer_map = {A_1: A, C_1: C} {
     C_2[0] = max(2i16, select((0 < cast(int32, (int16*)A_2[0])), 1i16, 3i16)
   }
   ```
   **After this submit:**
   ```
   primfn(A_1: handle, C_1: handle) -> ()
     attr = {"global_symbol": "main", "tir.noalias": True}
     buffers = {C: Buffer(C_2: Pointer(uint16), uint16, [1], []),
                A: Buffer(A_2: Pointer(uint16), uint16, [1], [])}
     buffer_map = {A_1: A, C_1: C} {
     C_2[0] = max(2u16, select((0 < cast(int32, (uint16*)A_2[0])), 1u16, 3u16))
   }
   ```
   
   
   Because this change does not affect the results of the operation, so few people usually pay attention.
   
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] comaniac commented on pull request #7405: [TIR][Printer] Fix SelectNode TIRTextPrinter bracket mismatch

Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #7405:
URL: https://github.com/apache/tvm/pull/7405#issuecomment-777923284


   Thanks @Beya2019 @junrushao1994 @ZihengJiang 


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] comaniac merged pull request #7405: [TIR][Printer] Fix SelectNode TIRTextPrinter bracket mismatch

Posted by GitBox <gi...@apache.org>.
comaniac merged pull request #7405:
URL: https://github.com/apache/tvm/pull/7405


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] Beya2019 edited a comment on pull request #7405: [TIR][Printer] Fix SelectNode TIRTextPrinter bracket mismatch

Posted by GitBox <gi...@apache.org>.
Beya2019 edited a comment on pull request #7405:
URL: https://github.com/apache/tvm/pull/7405#issuecomment-773741386


   > Nice catch! Is it possible to add unit test to avoid this?
   
   There are ready-made test cases in tvm, tests/python/unittest/test_target_codegen_opencl.py->test_opencl_ternary_expression()->check_select(), we only need add a print message in L51-L52:
   `print(tvm.lower(s, [A, C]))`
   
   Capture part of the printed information:
   **Before this submit:**
   ```
   primfn(A_1: handle, C_1: handle) -> ()
     attr = {"global_symbol": "main", "tir.noalias": True}
     buffers = {C: Buffer(C_2: Pointer(int16), int16, [1], []),
                A: Buffer(A_2: Pointer(int16), int16, [1], [])}
     buffer_map = {A_1: A, C_1: C} {
     C_2[0] = max(2i16, select((0 < cast(int32, (int16*)A_2[0])), 1i16, 3i16)
   }
   ```
   **After this submit:**
   ```
   primfn(A_1: handle, C_1: handle) -> ()
     attr = {"global_symbol": "main", "tir.noalias": True}
     buffers = {C: Buffer(C_2: Pointer(uint16), uint16, [1], []),
                A: Buffer(A_2: Pointer(uint16), uint16, [1], [])}
     buffer_map = {A_1: A, C_1: C} {
     C_2[0] = max(2u16, select((0 < cast(int32, (uint16*)A_2[0])), 1u16, 3u16))
   }
   ```
   
   
   Because this change does not affect the results of the operation, so few people usually pay attention.
   
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] Beya2019 commented on pull request #7405: [TIR][Printer] Fix SelectNode TIRTextPrinter bracket mismatch

Posted by GitBox <gi...@apache.org>.
Beya2019 commented on pull request #7405:
URL: https://github.com/apache/tvm/pull/7405#issuecomment-773741386


   > Nice catch! Is it possible to add unit test to avoid this?
   
   There are ready-made test cases in tvm, tests/python/unittest/test_target_codegen_opencl.py->test_opencl_ternary_expression()->check_select(), we only need add a print message in L51-L52:
   `print(tvm.lower(s, [A, C]))`
   
   Capture part of the printed information:
   ```
   primfn(A_1: handle, C_1: handle) -> ()
     attr = {"global_symbol": "main", "tir.noalias": True}
     buffers = {C: Buffer(C_2: Pointer(int16), int16, [1], []),
                A: Buffer(A_2: Pointer(int16), int16, [1], [])}
     buffer_map = {A_1: A, C_1: C} {
     C_2[0] = max(2i16, select((0 < cast(int32, (int16*)A_2[0])), 1i16, 3i16))
   }
   ```
   Because this change does not affect the results of the operation, so few people usually pay attention.
   
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] Beya2019 commented on pull request #7405: [TIR][Printer] Fix SelectNode TIRTextPrinter bracket mismatch

Posted by GitBox <gi...@apache.org>.
Beya2019 commented on pull request #7405:
URL: https://github.com/apache/tvm/pull/7405#issuecomment-773741386


   > Nice catch! Is it possible to add unit test to avoid this?
   
   There are ready-made test cases in tvm, tests/python/unittest/test_target_codegen_opencl.py->test_opencl_ternary_expression()->check_select(), we only need add a print message in L51-L52:
   `print(tvm.lower(s, [A, C]))`
   
   Capture part of the printed information:
   ```
   primfn(A_1: handle, C_1: handle) -> ()
     attr = {"global_symbol": "main", "tir.noalias": True}
     buffers = {C: Buffer(C_2: Pointer(int16), int16, [1], []),
                A: Buffer(A_2: Pointer(int16), int16, [1], [])}
     buffer_map = {A_1: A, C_1: C} {
     C_2[0] = max(2i16, select((0 < cast(int32, (int16*)A_2[0])), 1i16, 3i16))
   }
   ```
   Because this change does not affect the results of the operation, so few people usually pay attention.
   
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org