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_r379025696
##########
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:
Here, where we create the MXTensor objects, we should set whether the
MXTensor is a dense/CSR/RowSparse everytime, so theres no need for a default:
https://github.com/apache/incubator-mxnet/blob/f5a1014479351f3139b92c437d65de3a3a653196/include/mxnet/lib_api.h#L1114-L1118
----------------------------------------------------------------
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