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/03/02 12:14:09 UTC

[GitHub] [tvm] codeislife99 commented on pull request #7562: Add segment sum Op to relay and corresponding TF Ops , fix scatter_add dynamic bug

codeislife99 commented on pull request #7562:
URL: https://github.com/apache/tvm/pull/7562#issuecomment-788795464


   
   Hey @masahi , upon closely reading the Embedding Bag documentation, it seems that: (Referencing the `sparse_segment_sum` example)
   1. When `inputs` is 1D , and `offsets` is given, we simple have to convert `offsets` into `segment_ids` and `inputs` would directly be `indices`. To convert `offsets` into `segment_ids` we have to use a combination of `adjacent_difference`, `arange` and  `repeat` : For example: `offsets` of `[0,4]` with size of 10 would translate to `[0, 0, 0, 0, 1, 1, 1, 1, 1, 1]` and `relay.segment_sum` could be called on it. 
   2. When `inputs` is 2D, its more easier where we convert the input size `[B,N]` to `[0,0,0... Ntimes ... ,1,1,1,... N Times ..... B-1,B-1, .... N Times]`  This would require `arange` and `repeat`.  And then use `inputs` as `indices` like before and the converted input size (now 1D) as `segment_ids`. 
   
   Now all of these ops exist except `adjacent_difference` although @ymwangg wrote an IR for it. Is it possible to call it in any form or if not , do you think its worthwhile to make it an op ? [Numpy equivalent](https://numpy.org/doc/stable/reference/generated/numpy.ediff1d.html)
   
   Let me know your thoughts on the best way to reuse existing code. After that implementation would be only a trivial few lines.
   
   


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