samskalicky commented on a change in pull request #17569: [WIP] Support sparse 
custom operator
URL: https://github.com/apache/incubator-mxnet/pull/17569#discussion_r378068778
 
 

 ##########
 File path: include/mxnet/lib_api.h
 ##########
 @@ -229,20 +241,54 @@ enum MXReturnValue {
   MX_SUCCESS = 1,
 };
 
+struct ChunkDense {
+  // Pointer to data.
+  void *data{nullptr};
+  // Size of data in bytes.
+  size_t dataSize{0};
+  // shape of data.
+  std::vector<int64_t> shape;
+  // Context of data.
+  // MXContext ctx;
+};
+
+struct ChunkSparse {
+  // Pointer to data.
+  void *data{nullptr};
+  // Size of data in bytes.
+  size_t dataSize{0};
+  // length  of data.
+  int64_t data_lens;
+
+  // To store aux data for sparse.
+  // for row_sparse, aux_data[0] = indices
+  // for csr, aux_data[0] = indptr, aux_data[1] = indices
+  std::vector<std::vector<int64_t>> aux_data;
+
+  // Lens of the aux_data.
+  // for row_sparse, aux_lens[0] = len(indices)
+  // for csr, aux_lens[0] = len(indptr), aux_lens[1] = len(indices)
+  std::vector<int64_t> aux_lens;
+  // Context of data.
+  // MXContext ctx;
+};
+
 /*!
  * \brief Tensor data structure used by custom operator
  */
 struct MXTensor {
-  MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {}
+  MXTensor() : data_ptr(nullptr), dtype(kUNSET), verID(0), 
stype(kDefaultStorage) {}
 
+  // Construtor for dense.
   MXTensor(void *data_ptr, const std::vector<int64_t> &shape, MXDType dtype,
-           size_t vID, MXContext mx_ctx)
-  : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID), ctx(mx_ctx) {}
+           size_t vID, MXContext mx_ctx, MXStorageType stype = kDefaultStorage)
 
 Review comment:
   Do we need to set a default? Lets simplify the code and just always have it 
be set in the constructor by adding another argument. MXTensors will only be 
created by infrastructure (not users) so no need to make "convenience" 
defaults. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to