zheng-da commented on a change in pull request #9947: [WIP] Performance 
optimization for dot(csr, rsp) on cpu
URL: https://github.com/apache/incubator-mxnet/pull/9947#discussion_r173386908
 
 

 ##########
 File path: src/operator/tensor/dot-inl.h
 ##########
 @@ -793,16 +764,21 @@ inline void DotCsrRspDnsImpl(const OpContext& ctx,
             mxnet_op::Kernel<mxnet_op::set_zero, cpu>::Launch(s, num_threads,
                                                               
ret->dptr<DType>());
           }
-          num_threads = mxnet_op::get_num_threads<cpu>(ret->shape_[0]);
-          dim_t seg_len = (ret->shape_[0] + num_threads - 1) / num_threads;
+          num_threads = ret->shape_[0];
           if (trans_lhs) {
             LOG(FATAL) << "DotCsrRspDnsImpl has not implemented dot(csr.T, 
rsp) = dns yet";
           } else {
+            const RType* row_idx_ptr = row_idx_r.dptr<RType>();
+            std::unordered_map<RType, dim_t> row_idx_map;
+            row_idx_map.reserve(nnr * 7);
+            for (dim_t ind = 0; ind < nnr; ind++) {
+              row_idx_map.emplace(row_idx_ptr[ind], ind);
+            }
 
 Review comment:
   @eric-haibin-lin if we maintain an array for mapping and an array for 
recording the number of non-zero entries in the mapping array, the overhead of 
cleaning the mapping is O(nnr).
   
   @reminisce depending on how we use a tree to store the index. we can achieve 
O(log_k N) accesses. in practice, k is a large number (e.g., 128), so it's 3 or 
4 memory accesses before finding the right location. memory overhead is 
O(min(N, k * nnr)). it might be better than using a single array or hashtable.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to