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

 ##########
 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:
   updated in eric-haibin-lin#134
   Since storage fallback doesn't add any additional node to the graph, it only 
changes the way a node executes, so I think it should be fine. 
   Autograd test with sparse input added in commit: 
https://github.com/eric-haibin-lin/mxnet/pull/134/commits/8fb3b9cdf265907ba838718638747e4edc5c802f
 
----------------------------------------------------------------
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