eric-haibin-lin commented on a change in pull request #10371: [MXNET-263] Support for dot(dns, csr) = dns and dot(dns, csr.T) = dns on GPU URL: https://github.com/apache/incubator-mxnet/pull/10371#discussion_r180483375
########## File path: src/operator/tensor/dot-inl.cuh ########## @@ -895,6 +988,131 @@ inline void DotCsrRspDnsImpl(const OpContext& ctx, }); } +/* + * \brief GPU Impl of dot(dns, csr) = csr + */ +template<typename gpu> +inline void DotDnsCsrCsrImpl(const OpContext& ctx, + const TBlob& lhs, const NDArray& rhs, + const OpReqType req, NDArray* ret) { + LOG(FATAL) << "dot(dense, csr) = csr is not implemented on GPU"; +} + +/* + * \brief GPU Impl of dot(dns, csr) = dns and dot(dns, csr.T) = dns + */ +template<typename gpu> +inline void DotDnsCsrDnsImpl(const OpContext& ctx, + const TBlob& dns, const NDArray& rhs, + const OpReqType req, NDArray* ret, + const bool transpose_b) { + CHECK_EQ(req, kWriteTo); + CHECK_EQ(rhs.storage_type(), kCSRStorage); + + using namespace mshadow; + using namespace mshadow::expr; + using nnvm::dim_t; + + /* Initialize data structures */ + mshadow::Stream<gpu>* s = ctx.get_stream<gpu>(); + TBlob csr_data = rhs.data(); + TBlob csr_indices = rhs.aux_data(csr::kIdx); + TBlob csr_indptr = rhs.aux_data(csr::kIndPtr); + if (!rhs.storage_initialized()) { + FillZerosCsrImpl(s, *ret); + return; + } + + // if dot(dense, csr) = dns, transform to csc first + if (!transpose_b) { + // LOG(FATAL) << "dot(dns, csr) = dns not implemented yet"; + const nnvm::dim_t csr_rows = rhs.shape()[0]; + const nnvm::dim_t csr_cols = rhs.shape()[1]; + const nnvm::dim_t dns_rows = dns.shape_[0]; + const nnvm::dim_t nnz = rhs.storage_shape().Size(); + + MSHADOW_SGL_DBL_TYPE_SWITCH(csr_data.type_flag_, DType, { + MSHADOW_IDX_TYPE_SWITCH(csr_indices.type_flag_, IType, { + MSHADOW_IDX_TYPE_SWITCH(csr_indptr.type_flag_, CType, { + DType* csc_data_ptr = NULL; + unsigned long long* csc_indices_ptr = NULL; + unsigned long long* csc_indptr_ptr = NULL; + unsigned long long* col_counters = NULL; + size_t ull_mem_size = sizeof(unsigned long long); Review comment: What does ull mean? ---------------------------------------------------------------- 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