asitstands commented on issue #11031: Use dtype=int for the indices returned by 
TopK
URL: 
https://github.com/apache/incubator-mxnet/issues/11031#issuecomment-392075252
 
 
   This could break existing code. Sometimes the resulting array of indices is 
subject to another operation. Then the result can become different if the dtype 
of the index array changes. Or it can make an error as some opertions can be 
applied to only floating point arrays.
   ```python
   nd.topk(nd.arange(10), k=2).mean()
   ```
   Currently the result is `[8.5]`, but the result is `[8]` if the dtype is 
integer. 
   ```python
   nd.gemm2(nd.topk(x, k=2), y)
   ```
   Currently this is allowed, but it'll cause an error if the dtype changes to 
integer.
   
   `multinomial` has a similar but opposite issue. It returns an index array of 
integer type, but it would be convenient to have floating point array sometimes 
(PR #10970). I think that it would be better if we can make `multinomial` and 
`topk` consistent.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to