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_r173340887
########## 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: we can use an array to map row id to the physical location. It will take O(N) memory. we can potentially use a tree (e.g., B+tree) to map row ids. In this case, we can trade off the number of memory accesses with memory size. ---------------------------------------------------------------- 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