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/10/28 01:35:50 UTC

[GitHub] [incubator-tvm] hzfan edited a comment on pull request #6771: [ARITH] Tight bound for floormod

hzfan edited a comment on pull request #6771:
URL: https://github.com/apache/incubator-tvm/pull/6771#issuecomment-717639785


   @tqchen  The ir (before narrowing) is like
   ```
   for (ax0.ax1.fused.ax2.outer.fused: int64, 0i64, 42i64) "parallel" {
     for (n.oc_chunk.fused.oh.outer.fused: int64, 0i64, a_very_long_upper_bound) {
       ...
       ...
       for (oh.inner: int32, 0, 2) {
         for (ow.inner: int32, 0, 14) {
           for (oc_block: int32, 0, 16) "vectorized" {
             ...floormod(n.oc_chunk.fused.oh.outer.fused, cast(int64, floordiv(((cast(int32, ((floormod(ax0.ax1.fused.ax2.outer.fused, 7i64)*2i64) + 1i64)) + 1) - cast(int32, (floormod(ax0.ax1.fused.ax2.outer.fused, 7i64)*2i64))), 2)))...
           }
         }
       }
     }
   }
   ```
   Let `a = n.oc_chunk.fused.oh.outer.fused` (the first operand of floormod), `b = cast(int64, floordiv(((cast(int32, ((floormod(ax0.ax1.fused.ax2.outer.fused, 7i64)*2i64) + 1i64)) + 1) - cast(int32, (floormod(ax0.ax1.fused.ax2.outer.fused, 7i64)*2i64))), 2))` (second operand of floormod)
   `const_int_bound` gives `0 <= a <= 6` and `-5 <= b <= 7`.
   
   In a simplified form, 
   ```
   b = floordiv(c * 2 + 2 - c * 2, 2), where
   c = floormod(ax0.ax1.fused.ax2.outer.fused, 7)
   ```
   
   I guess `c * 2 + 2 - c * 2` is not simplified as `2`, instead, its bound is analyzed directly, so the min becomes negative due to the minus operation.


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