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/06/09 06:21:05 UTC

[GitHub] [tvm] wzh99 opened a new issue, #11640: [Bug] Segmentation fault for type inference of reduction operators with `axis=[]`

wzh99 opened a new issue, #11640:
URL: https://github.com/apache/tvm/issues/11640

   Type inference of the following Relay function causes a segmentation fault:
   ```
   def @main(%x: Tensor[(1, 2, 3), float32]) {
     sum(%x, axis=[], keepdims=True, exclude=True)
   }
   ```
   
   ### Expected behavior
   
   The type inference pass accepts this function, since the type constraints of the reduction operator `sum` are not violated. 
   
   ### Actual behavior
   
   Segmentation fault. 
   
   ### Environment
   
   macOS 12.4. Compiled using Clang 13.1.6 with LLVM support. TVM commit [`df4f4c0b4`](https://github.com/apache/tvm/commit/df4f4c0b4bccd775af25967fdf057392c1a2826e). 
   
   ### Steps to reproduce
   
   ```python
   from tvm import relay, ir
   
   x = relay.var('x', shape=(1, 2, 3))
   y = relay.sum(x, axis=(), keepdims=True, exclude=True)
   mod = ir.IRModule.from_expr(y)
   mod = relay.transform.InferType()(mod)
   ```
   
   ### Possible fix
   
   https://github.com/apache/tvm/blob/df4f4c0b4bccd775af25967fdf057392c1a2826e/src/relay/op/tensor/reduce.cc#L72-L73
   
   ```c++
    ICHECK(in_axes[in_axes.size() - 1] < indim)
        << "Reduction axis " << in_axes[in_axes.size() - 1] << " exceeds input dimensions " << indim;
   ```
   
   When `in_axes` is empty, accessing it by index `in_axes.size() - 1` is invalid. To fix it, I suggest removing this `ICHECK` because the range of elements in `in_axes` seems to have been checked already in the previous for-loop. 
   


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

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


[GitHub] [tvm] masahi closed issue #11640: [Bug] Segmentation fault during type inference of reduction operators with `axis=[]`

Posted by GitBox <gi...@apache.org>.
masahi closed issue #11640: [Bug] Segmentation fault during type inference of reduction operators with `axis=[]`
URL: https://github.com/apache/tvm/issues/11640


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