On 29/5/21 5:28 pm, Ralf Gommers wrote:


On Fri, May 28, 2021 at 4:58 PM <kang...@mail.ustc.edu.cn <mailto:kang...@mail.ustc.edu.cn>> wrote:

    Hi all,

    Finding topk elements is widely used in several fields, but missed
    in NumPy.
    I implement this functionality named as  numpy.topk using core numpy
    functions and open a PR:

    https://github.com/numpy/numpy/pull/19117
    <https://github.com/numpy/numpy/pull/19117>

    Any discussion are welcome.


Thanks for the proposal Kang. I think this functionality is indeed a fairly obvious gap in what Numpy offers, and would make sense to add. A detailed comparison with other libraries would be very helpful here. TensorFlow and JAX call this function `top_k`, while PyTorch, Dask and MXNet call it `topk`.

Two things to look at in more detail here are:
1. complete signatures of the function in each of those libraries, and what the commonality is there. 2. the argument Eric made on your PR about consistency with sort/argsort, and if we want topk/argtopk? Also, do other libraries have `argtopk`?

Cheers,
Ralf


    Best wishes,

    Kang Kai


Did this function come up at all in the array-API consortium dicussions?

Matti

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to