26 #ifndef MXNET_CPP_NDARRAY_H_ 27 #define MXNET_CPP_NDARRAY_H_ 136 NDArray(
const std::vector<mx_uint> &shape,
const Context &context,
137 bool delay_alloc =
true);
159 NDArray(
const std::vector<mx_float> &data,
const Shape &shape,
161 explicit NDArray(
const std::vector<mx_float> &data);
259 void SyncCopyFromCPU(
const mx_float *data,
size_t size);
269 void SyncCopyFromCPU(
const std::vector<mx_float> &data);
280 void SyncCopyToCPU(
mx_float *data,
size_t size = 0);
291 void SyncCopyToCPU(std::vector<mx_float> *data,
size_t size = 0);
310 size_t Offset(
size_t h = 0,
size_t w = 0)
const;
318 size_t Offset(
size_t c,
size_t h,
size_t w)
const;
325 mx_float At(
size_t h,
size_t w)
const;
333 mx_float At(
size_t c,
size_t h,
size_t w)
const;
351 void WaitToRead()
const;
361 static void WaitAll();
384 static void Load(
const std::string &file_name,
385 std::vector<NDArray> *array_list =
nullptr,
386 std::map<std::string, NDArray> *array_map =
nullptr);
392 static std::map<std::string, NDArray> LoadToMap(
const std::string &file_name);
398 static std::vector<NDArray> LoadToList(
const std::string &file_name);
404 static void Save(
const std::string &file_name,
405 const std::map<std::string, NDArray> &array_map);
411 static void Save(
const std::string &file_name,
412 const std::vector<NDArray> &array_list);
420 std::vector<mx_uint> GetShape()
const;
424 int GetDType()
const;
442 std::shared_ptr<NDBlob> blob_ptr_;
449 #endif // MXNET_CPP_NDARRAY_H_ NDBlob()
default constructor
Definition: ndarray.h:97
Symbol operator/(mx_float lhs, const Symbol &rhs)
namespace of mxnet
Definition: base.h:126
dynamic shape class that can hold shape of arbirary dimension
Definition: shape.h:42
MXNET_DLL int MXNDArrayFree(NDArrayHandle handle)
free the narray handle
~NDBlob()
destructor, free the NDArrayHandle
Definition: ndarray.h:106
static Context cpu(int device_id=0)
Return a CPU context.
Definition: ndarray.h:80
Symbol operator%(mx_float lhs, const Symbol &rhs)
DeviceType
Definition: ndarray.h:40
NDArray interface.
Definition: ndarray.h:120
NDBlob(NDArrayHandle handle)
construct with a NDArrayHandle
Definition: ndarray.h:102
void SampleGaussian(real_t mu, real_t sigma, NDArray *out)
Sample gaussian distribution for each elements of out.
void * NDArrayHandle
handle to NDArray
Definition: c_api.h:64
NDArrayHandle GetHandle() const
Definition: ndarray.h:439
NDArrayHandle handle_
the NDArrayHandle
Definition: ndarray.h:110
Symbol operator+(mx_float lhs, const Symbol &rhs)
unsigned int mx_uint
manually define unsigned int
Definition: c_api.h:57
void SampleUniform(real_t begin, real_t end, NDArray *out)
Sample uniform distribution for each elements of out.
DeviceType GetDeviceType() const
Definition: ndarray.h:60
std::ostream & operator<<(std::ostream &out, const NDArray &ndarray)
int GetDeviceId() const
Definition: ndarray.h:64
float mx_float
manually define float
Definition: c_api.h:59
Symbol operator-(mx_float lhs, const Symbol &rhs)
struct to store NDArrayHandle
Definition: ndarray.h:92
static Context gpu(int device_id=0)
Return a GPU context.
Definition: ndarray.h:71
Context interface.
Definition: ndarray.h:49
Symbol Reshape(const std::string &symbol_name, Symbol data, Shape shape=Shape(), bool reverse=false, Shape target_shape=Shape(), bool keep_highest=false)
Definition: op.h:1156
Symbol operator*(mx_float lhs, const Symbol &rhs)
Context(const DeviceType &type, int id)
Context constructor.
Definition: ndarray.h:56