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

 ##########
 File path: src/operator/tensor/broadcast_reduce_op.h
 ##########
 @@ -556,6 +556,179 @@ inline bool ReduceAxesOpForwardStorage(const 
nnvm::NodeAttrs& attrs,
   return dispatched;
 }
 
+
+using namespace mshadow_op::isnan_typed;
+
+struct argmax {
+  template<typename DType>
+  MSHADOW_XINLINE static void Map(index_t i, const int nWorkers,
+                                  const DType *in_data, DType *out_data,
+                                  uint32_t nSteps, uint32_t step, size_t shift,
+                                  void *pIdxStorage, bool use_uint16) {
+    // i - index of launched thread
+    // nWorkers - number of threads, assigned to work on one row/column
+    // iw - index of current thread among workers assigned to the same vector
+    int iw = 0;
+    const DType *pCurr = in_data;
+    if (nWorkers > 1) {
+      // in - the vector number which current thread is assigned to
+      const auto in = i / nWorkers;
+      iw = i % nWorkers;
+      pCurr += in % step + shift * (in / step) + iw * step;
+      nSteps = (nSteps + nWorkers - 1 - iw) / nWorkers;
+      step *= nWorkers;
+    } else {
+      pCurr += i % step + shift * (i / step);
+    }
+
+    uint32_t maxIdx = 0;
 
 Review comment:
   We are working to support the size of each dimension beyond INT32_MAX in 
MXNet 1.6. That's why I suggest you to use `index_t`. In 1.5.1, `index_t` is 
int32_t by default; if the compiler flag USE_INT64_TENSOR_SIZE = 1, index_t is 
int64_t. In 1.6 release, this compiler flag will be ON by default.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to