You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/07/31 17:26:19 UTC

[GitHub] piiswrong commented on a change in pull request #7082: Sparse Tensor: request for reviews

piiswrong commented on a change in pull request #7082: Sparse Tensor: request for reviews
URL: https://github.com/apache/incubator-mxnet/pull/7082#discussion_r130403722
 
 

 ##########
 File path: src/c_api/c_api_ndarray.cc
 ##########
 @@ -301,10 +384,25 @@ void PushOperator(const OpStatePtr& state,
           engine::CallbackOnComplete on_complete) {
         OpContext opctx{is_train, rctx, on_complete, requested};
         std::vector<TBlob> input_blobs, output_blobs;
-        for (const auto& i : ndinputs) input_blobs.push_back(i.data());
-        for (const auto& i : ndoutputs) output_blobs.push_back(i.data());
-        std::vector<OpReqType> req(output_blobs.size(), kWriteTo);
-        fcompute(state, opctx, input_blobs, req, output_blobs);
+        std::vector<NDArray> temp_in, temp_out;
+        if (rctx.get_ctx().dev_mask() == gpu::kDevMask) {
+#if MXNET_USE_CUDA
+          GetDefaultBlobs<gpu>(ndinputs, &input_blobs, &temp_in, opctx);
+          GetDefaultBlobs<gpu>(ndoutputs, &output_blobs, &temp_out, opctx);
+          std::vector<OpReqType> req(output_blobs.size(), kWriteTo);
+          fcompute(state, opctx, input_blobs, req, output_blobs);
+          // cast to original storage type, if necessary
+          CastNonDefaultStorage<gpu>(ndoutputs, temp_out, opctx);
 
 Review comment:
   does this work with autograd? Is it tested?
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services