eric-haibin-lin 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_r379856537
########## File path: include/mxnet/lib_api.h ########## @@ -229,20 +241,41 @@ 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. + std::vector<int64_t> indices; + + // For CSR, indptr gives the start and end index of data for each row. + // For row sparse, indptr is empty. + std::vector<int64_t> indptr; + + // 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) + : 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. Review comment: Is the TODO item done? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services