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

 ##########
 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)
+  : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID), ctx(mx_ctx), 
stype(stype) {}
 
   /*! \brief populate internal tensor fields */
+  // To do: solve for CSR and row sparse.
   void setTensor(void *dptr, MXDType type, const int64_t* dims, int ndims,
-                 size_t vID, MXContext mx_ctx) {
-    data_ptr = dptr; dtype = type; verID = vID; ctx = mx_ctx;
+                 size_t vID, MXContext mx_ctx, MXStorageType stype = 
kDefaultStorage) {
 
 Review comment:
   Same as above, lets make storage type an argument to the function and just 
set it. No need for a default

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