You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/09/20 16:08:31 UTC

[GitHub] [incubator-mxnet] drivanov commented on a change in pull request #16218: Improving performance of argmax operator

drivanov commented on a change in pull request #16218: Improving performance of argmax operator
URL: https://github.com/apache/incubator-mxnet/pull/16218#discussion_r326699897
 
 

 ##########
 File path: src/operator/tensor/broadcast_reduce_op_index.cu
 ##########
 @@ -43,5 +43,18 @@ NNVM_REGISTER_OP(pick)
 NNVM_REGISTER_OP(_backward_pick)
 .set_attr<FCompute>("FCompute<gpu>", PickOpBackward<gpu>);
 
+template<>
+int DefineNumbWorkers<gpu>(const TShape &shape, int axis) {
+  const auto nSteps = static_cast<uint32_t>(shape[axis]);
+  const auto nThreads = shape.Size()/nSteps;
+  if (nThreads > nSteps)
+    return 1;
+
+  const auto a = static_cast<float>(nSteps)/nThreads;
+  const auto b = log2f(a);
+  const auto numbWorkers = pow(2, (b * 5 + 28)/11);
 
 Review comment:
   This is just a heuristic. Experimenting with different values `(shape, axis, numbWorkers)`, I accumulated a lot of data, it turned out that they almost perfectly corresponded to this formula.
   

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


With regards,
Apache Git Services