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 2020/05/10 07:48:38 UTC

[GitHub] [incubator-tvm] roastduck opened a new pull request #5553: Enable HoistIfThenElse in the default lowering procedure

roastduck opened a new pull request #5553:
URL: https://github.com/apache/incubator-tvm/pull/5553


   Enabling the `HoistIfThenElse` pass (#3865) in the default lowering procedure. `HoistIfThenElse` can be very helpful for sparse applications, since `LoopPartition` cannot eliminate their if statements with dynamic (unknown at compile time) conditions.
   
   Changes:
   - Move `HoistIfThenElse` from `src/tir/pass` to `src/tir/transform`.
   - Added it into `lower`.
   - Fixed a breaking test.
   
   @tqchen Requesting for a review.


----------------------------------------------------------------
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] [incubator-tvm] roastduck commented on pull request #5553: Enable HoistIfThenElse in the default lowering procedure

Posted by GitBox <gi...@apache.org>.
roastduck commented on pull request #5553:
URL: https://github.com/apache/incubator-tvm/pull/5553#issuecomment-626296808


   Well, a test for TensorCore fails.
   
   `HoistIfThenElse` transforms
   
   ```
   for (n.inner, 0, 2) {
     for (o.inner, 0, 2) {
       if ((((threadIdx.y*2) + n.inner) < 2)) {
         if ((((threadIdx.z*2) + o.inner) < 4)) {
           if ((threadIdx.y < 1)) {
             if ((threadIdx.z < 2)) {
               tvm_store_matrix_sync(Conv.wmma.accumulator, 16, 16, 16, ((n.inner*2) + o.inner), tvm_access_ptr(type_annotation(), Conv, (((((threadIdx.y*401408) + (n.inner*200704)) + (blockIdx.z*1024)) + (threadIdx.z*512)) + (o.inner*256)), 256, 2), 16, "row_major")
             }
           }
         }
       }
     }
   }
   ```
   
   into
   
   ```
   if ((((threadIdx.y*2) + n.inner) < 2)) {
     if ((threadIdx.y < 1)) {
       if ((threadIdx.z < 2)) {
         for (n.inner, 0, 2) {
           for (o.inner, 0, 2) {
             if ((((threadIdx.z*2) + o.inner) < 4)) {
               tvm_store_matrix_sync(Conv.wmma.accumulator, 16, 16, 16, ((n.inner*2) + o.inner), tvm_access_ptr(type_annotation(), Conv, (((((threadIdx.y*401408) + (n.inner*200704)) + (blockIdx.z*1024)) + (threadIdx.z*512)) + (o.inner*256)), 256, 2), 16, "row_major")
             }
           }
         }
       }
     }
   }
   ```
   
   where the `if` containing `n.inner` is wrongly hoisted, seeming like a bug of `HoistIfThenElse`. I will try to dig it out.


----------------------------------------------------------------
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] [incubator-tvm] roastduck commented on pull request #5553: Enable HoistIfThenElse in the default lowering procedure

Posted by GitBox <gi...@apache.org>.
roastduck commented on pull request #5553:
URL: https://github.com/apache/incubator-tvm/pull/5553#issuecomment-626306519


   Fixed and added an extra test.


----------------------------------------------------------------
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] [incubator-tvm] roastduck commented on pull request #5553: [TIR] Enable HoistIfThenElse in the default lowering procedure

Posted by GitBox <gi...@apache.org>.
roastduck commented on pull request #5553:
URL: https://github.com/apache/incubator-tvm/pull/5553#issuecomment-626459848


   Fixed a bug where `if` nodes containing thread indices could be hoisted over the definition of the indices. This would happen when `Attr` node for `thread_extent` is scheduled into the body of a `For` node, using a `compute_at` command.


----------------------------------------------------------------
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] [incubator-tvm] roastduck commented on pull request #5553: [TIR] Enable HoistIfThenElse in the default lowering procedure

Posted by GitBox <gi...@apache.org>.
roastduck commented on pull request #5553:
URL: https://github.com/apache/incubator-tvm/pull/5553#issuecomment-626669556


   Since there are too many bugs in `HoistIfThenElse`, let's track them in another issue, and enable the pass after they are all fixed. Closing for now.


----------------------------------------------------------------
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] [incubator-tvm] roastduck commented on pull request #5553: [TIR] Enable HoistIfThenElse in the default lowering procedure

Posted by GitBox <gi...@apache.org>.
roastduck commented on pull request #5553:
URL: https://github.com/apache/incubator-tvm/pull/5553#issuecomment-626343810


   Renamed `Var`s in hoisted `else_case`s, to be different from those in `then_case`s, so that SSA verification won't panic.


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