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/02/13 17:46:24 UTC
[GitHub] [incubator-mxnet] guanxinq commented on a change in pull request
#17569: [WIP] Adding sparse support to MXTensor for custom operators
guanxinq 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_r379018612
##########
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:
Adding default storage type here could enable the sparse support without any changing to previous implementation for dense.
----------------------------------------------------------------
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