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 2020/03/02 19:32:13 UTC

[GitHub] [incubator-mxnet] samskalicky commented on a change in pull request #17569: [WIP] Adding sparse support to MXTensor for custom operators

samskalicky commented on a change in pull request #17569: [WIP] Adding sparse support to MXTensor for custom operators
URL: https://github.com/apache/incubator-mxnet/pull/17569#discussion_r386604044
 
 

 ##########
 File path: include/mxnet/lib_api.h
 ##########
 @@ -229,20 +241,53 @@ enum MXReturnValue {
   MX_SUCCESS = 1,
 };
 
+struct MXSparse {
+  // Pointer to data.
+  void *data{nullptr};
+  // length of (non-zero) data.
+  int64_t data_len;
+
+  // To store aux data for sparse.
+  // For CSR, indices stores the col index of non-zero values.
+  // For row sparse, indices store row index of rows which have non-zero values.
+  int64_t* indices;
+  int64_t indices_len;
+
+  // For CSR, indptr gives the start and end index of data for each row.
+  // For row sparse, indptr is empty. 
+  int64_t* indptr;
+  int64_t indptr_len;
+
+  void set(void *data_ptr, const int64_t* dims, int ndims, void *idx,
+          int64_t num_idx, void *idx_ptr = nullptr, int64_t num_idx_ptr = 0) {
+    data = data_ptr;
+    data_len = num_idx;
+
+    indices = (int64_t*)idx;
+    indices_len = num_idx;
+
+    if(idx_ptr) {
+      indptr = (int64_t*)idx_ptr;
+      indptr_len = num_idx_ptr;
+    }
+  }
 
 Review comment:
   Can we move this into the MXTensor struct and call it `setSparse` or create another `setTensor` that also take these arguments too?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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