eric-haibin-lin commented on a change in pull request #11113: Support for
dot(dns, csr) = dns and dot(dns, csr.T) = dns on CPU
URL: https://github.com/apache/incubator-mxnet/pull/11113#discussion_r194201555
##########
File path: src/operator/tensor/dot-inl.h
##########
@@ -1031,13 +1129,58 @@ inline void DotDnsCsrCsrImpl(const OpContext& ctx,
const cpu& cpu_dev,
}
/*
- * \brief Impl of dot(dns, csr) = dense (GPU only)
+ * \brief Impl of dot(dns, csr) = dns and dot(dns, csr.T) = dns
*/
inline void DotDnsCsrDnsImpl(const OpContext& ctx, const cpu& cpu_dev,
- const TBlob& dns, const NDArray& rhs,
- const OpReqType req, NDArray* ret,
- const bool transpose_b) {
- LOG(FATAL) << "dot(dense, csr) = dense is not implemented on CPU";
+ const TBlob& dns, const NDArray& rhs,
+ const OpReqType req, NDArray* ret,
+ const bool transpose_b) {
+ if (req == kNullOp) return;
+ CHECK_EQ(rhs.storage_type(), kCSRStorage);
+ mshadow::Stream<cpu>* s = ctx.get_stream<cpu>();
+ if (!rhs.storage_initialized()) {
+ FillZerosCsrImpl(s, *ret);
+ return;
+ }
+
+ using nnvm::dim_t;
+
+ const TBlob data_r = rhs.data();
+ const TBlob indptr_r = rhs.aux_data(csr::kIndPtr);
+ const TBlob col_idx_r = rhs.aux_data(csr::kIdx);
+ const TBlob& data_l = dns;
+ const TBlob data_out = ret->data();
+
+ MSHADOW_SGL_DBL_TYPE_SWITCH(data_r.type_flag_, DType, { // data type
+ MSHADOW_IDX_TYPE_SWITCH(indptr_r.type_flag_, IType, { // indptr type
+ MSHADOW_IDX_TYPE_SWITCH(col_idx_r.type_flag_, CType, { // col idx type
+ dim_t num_threads;
+ if (req == kWriteTo) {
Review comment:
req == writeto || req == writeinplace
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services