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

 ##########
 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:
   @apeforest: I could do that, but are you sure that you really need this? 
According to following comments from `config.mk`
   ```
   # Use int64_t type to represent the total number of elements in a tensor
   # This will cause performance degradation reported in issue #14496
   # Set to 1 for large tensor with tensor size greater than INT32_MAX i.e. 
2147483647
   # Note: the size of each dimension is still bounded by INT32_MAX
   USE_INT64_TENSOR_SIZE = 1
   ```
   **the size of each dimension is still bounded by INT32_MAX**. I think, even 
`uint32_t` currently used here should be more than enough. Or am I missing 
something?

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