AndrewZhaoLuo opened a new pull request #9023:
URL: https://github.com/apache/tvm/pull/9023


   Negative indices are a pretty common feature in most modern programming 
languages and libraries. This proposed PR would add optional support for 
negative indices out of the box for tensors in TE.
   
   A lot of operators from other frontends support negative indices. See ONNX, 
numpy, and PyTorch where their tensors support negative indices out of the box.
   
   One benefit of this change is now it is trivial to change operators to 
support negative indices. This makes adapting frontends to our operators 
simpler. For example an operator using this simply has to turn the 
`support_negative_indices` flag to true for every relevant indexing operation. 
An example of doing this can be found in 
https://github.com/AndrewZhaoLuo/tvm/blob/02f1870d7f2e274cfd7e04678691da019ff201f0/include/tvm/topi/transform.h#L1265.
 Right now how we handle negative indices is by manually converting them to 
positive indices which can be cumbersome and results in lots of code 
duplication.
   
   The downside is that it technically adds a little more computation per 
indexing operation. While these operations are probably memory and not compute 
bound I am not 100% confident that setting `support_negative_indices=true` 
would not result in performance regressions.


-- 
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-unsubscr...@tvm.apache.org

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


Reply via email to