You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/06 22:05:24 UTC

[GitHub] eric-haibin-lin closed pull request #10813: Fix context handling when creating sparse arrays from definition

eric-haibin-lin closed pull request #10813: Fix context handling when creating sparse arrays from definition
URL: https://github.com/apache/incubator-mxnet/pull/10813
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/mxnet/ndarray/sparse.py b/python/mxnet/ndarray/sparse.py
index c7355c2e46d..c45de54c1ff 100644
--- a/python/mxnet/ndarray/sparse.py
+++ b/python/mxnet/ndarray/sparse.py
@@ -992,10 +992,16 @@ def _csr_matrix_from_definition(data, indices, indptr, shape=None, ctx=None,
     # to accept np.ndarray types to copy from to result.data and aux_data
     if not isinstance(data, NDArray):
         data = _array(data, ctx, dtype)
+    else:
+        data = data.as_in_context(ctx)
     if not isinstance(indptr, NDArray):
         indptr = _array(indptr, ctx, indptr_type)
+    else:
+        indptr = indptr.as_in_context(ctx)
     if not isinstance(indices, NDArray):
         indices = _array(indices, ctx, indices_type)
+    else:
+        indices = indices.as_in_context(ctx)
     if shape is None:
         if indices.shape[0] == 0:
             raise ValueError('invalid shape')
@@ -1153,8 +1159,12 @@ def _row_sparse_ndarray_from_definition(data, indices, shape=None, ctx=None,
     # to accept np.ndarray types to copy from to result.data and aux_data
     if not isinstance(data, NDArray):
         data = _array(data, ctx, dtype)
+    else:
+        data = data.as_in_context(ctx)
     if not isinstance(indices, NDArray):
         indices = _array(indices, ctx, indices_type)
+    else:
+        indices = indices.as_in_context(ctx)
     if shape is None:
         num_indices = indices.shape[0]
         if num_indices == 0:


 

----------------------------------------------------------------
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