[OP] Topk and arange + Update submodules #4565

merged 10 commits into from Jan 7, 2017


None yet

2 participants


Continuing of #4403

  1. Fix the argument of batch_dot
  2. New operators: topk, sort, argsort, arange. (Also, the previous internal operators _zeros and _ones have been added to the python script as mx.sym.zeros and mx.sym.ones)
  3. Move operator to operator/tensor: BlockGrad
  4. Add the argument dtype to initialization operators (_zeros, _ones, _arange)
  5. Enable gradient for argmax and argmin by adding the gradient node to _zeros.

Some Notes:

  1. The implementation of TopK is not so optimized at this stage. The implementation is to first sort the data and then keep the top k indices/values. In the future, we will try to refactor the implementation using CUB(https://nvlabs.github.io/cub/)
  2. The "axis" argument is supported in topk and topk is equivalent to argsort and sort if we set "k<1" and ret_typ = "indices" or "value"
  3. The arange operator has an additional "repeat" argument, which indicates the number of times each element will be repeated in the generation process. This can be helpful for implementing the "meshgrid".
sxjscience added some commits Jan 6, 2017
@sxjscience sxjscience initial add topk arange
fix arange

Put back ones and zeros


fix default ctx
@sxjscience sxjscience fix lint 6e914c6
@sxjscience sxjscience Update Submodules
+ batch_id = F<mshadow_op::floor>(indices / static_cast<real_t>(element_num));
+ // Since the SortByKey performs stable sort, the second SortByKey will reorder
+ // the sorted_dat based on the order of the batch_id
+ SortByKey(batch_id, sorted_dat, true);
piiswrong Jan 6, 2017 Member

this is good for now. Let's try thrust later


LGTM. PLease fix warnings as they are treated as errors now.

sxjscience added some commits Jan 7, 2017
@sxjscience sxjscience Merge remote-tracking branch 'refs/remotes/dmlc/master' into topk_ara…
@sxjscience sxjscience Update MShadow f7a303d
@sxjscience sxjscience fix warning
@sxjscience sxjscience fix pylint
@sxjscience sxjscience Merge branch 'master' into topk_arange_rebase5
@sxjscience sxjscience style fix
@sxjscience sxjscience Merge branch 'master' into topk_arange_rebase5
@sxjscience sxjscience merged commit 9f9c135 into dmlc:master Jan 7, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
default Build finished.
@sxjscience sxjscience deleted the sxjscience:topk_arange_rebase5 branch Jan 8, 2017
@rravu3 rravu3 pushed a commit to rravu3/mxnet that referenced this pull request Jan 21, 2017
@sxjscience sxjscience + Rahul Ravu [OP] Topk and arange + Update submodules (#4565)
* initial add topk arange

fix arange

Put back ones and zeros


fix default ctx

* fix lint

* Update Submodules

* Update MShadow

* fix warning

* fix pylint

* style fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment