class NDArray{
private:
Context ctx_;
typeFlag dtype_;
std::vector<size_t> shape_;
std::shared_ptr<TBlob<dtype_, ctx_.dev_type_, ctx_.dev_id_> > data_;
public:
// constructor
NDArray();
NDArray(const NDArray &obj);
explicit NDArray(const size_t size);
I want to instantiate data_ member after the constructor, where I initialize the ctx_ and dtype_ member
inline NDArray::NDArray(): ctx_(Context()), shape_{0}, dtype_(typeFlag::kFloat32), {}
inline NDArray::NDArray(const NDArray &obj): ctx_(obj.ctx_), shape_(obj.shape_), dtype_(obj.dtype_), data_(obj.data_){}
Then I got errors:
NDArray.hpp:18:31: error: invalid use of non-static data member ‘mxnet::NDArray::dtype_’
std::shared_ptr<TBlob<dtype_, ctx_.dev_type_, ctx_.dev_id_> data_;
^
NDArray.hpp:16:18: note: declared here
typeFlag dtype_;
What can I do to achieve my goal? Could you plz help me
EDIT
template<typeFlag dtype, Context::DeviceType ctx_type, int ctx_id>
class TBlob{
friend class NDArray;
public:
TBlob();
TBlob(const TBlob<dtype, ctx_type, ctx_id> &obj);
explicit TBlob(const size_t &size);
explicit TBlob(const std::vector<size_t> &shape);
TBlob(const float *data, const size_t size);
TBlob(const float *data, const std::vector<size_t> shape);
TBlob(const uint8_t *data, const size_t size);
TBlob(const uint8_t *data, const std::vector<size_t> shape);
~TBlob();
private:
void *dptr_;
std::vector<size_t> shape_;
};
template<typeFlag dtype, Context::DeviceType ctx_type, int ctx_id>
inline TBlob<dtype, ctx_type, ctx_id>::TBlob(): dptr_(nullptr), shape_{0} {}
template<typeFlag dtype, Context::DeviceType ctx_type, int ctx_id>
inline TBlob<dtype, ctx_type, ctx_id>::TBlob(const TBlob<dtype, ctx_type, ctx_id> &obj): dptr_(obj.dptr_), shape_(obj.shape_) {}