mxnet
|
ndarray interface More...
#include <ndarray.h>
Public Member Functions | |
NDArray () | |
default cosntructor More... | |
NDArray (const TShape &shape, Context ctx, bool delay_alloc=false, int dtype=mshadow::default_type_flag) | |
constructing a new dynamic NDArray More... | |
NDArray (const TBlob &data, int dev_id) | |
constructing a static NDArray that shares data with TBlob Use with caution: allocate ONLY ONE NDArray for each TBlob, make sure the memory region is available through out the life of NDArray More... | |
const TShape & | shape () const |
TBlob | data () const |
Context | ctx () const |
int | dtype () const |
bool | is_none () const |
void | WaitToRead () const |
Block until all the pending write operations with respect to current NDArray are finished, and read can be performed. More... | |
void | WaitToWrite () const |
Block until all the pending read/write operations with respect to current NDArray are finished, and write can be performed. More... | |
Engine::VarHandle | var () const |
void | Save (dmlc::Stream *strm) const |
save the content into binary stream More... | |
bool | Load (dmlc::Stream *strm) |
load the content from binary stream More... | |
NDArray & | operator= (real_t scalar) |
set all the elements in ndarray to be scalar More... | |
NDArray & | operator+= (const NDArray &src) |
elementwise add to current space this mutate the current NDArray More... | |
NDArray & | operator+= (const real_t &src) |
elementwise add to current space this mutate the current NDArray More... | |
NDArray & | operator-= (const NDArray &src) |
elementwise subtract from current ndarray this mutate the current NDArray More... | |
NDArray & | operator-= (const real_t &src) |
elementwise subtract from current ndarray this mutate the current NDArray More... | |
NDArray & | operator*= (const NDArray &src) |
elementwise multiplication to current ndarray this mutate the current NDArray More... | |
NDArray & | operator*= (const real_t &src) |
elementwise multiplication to current ndarray this mutate the current NDArray More... | |
NDArray & | operator/= (const NDArray &src) |
elementwise division from current ndarray this mutate the current NDArray More... | |
NDArray & | operator/= (const real_t &src) |
elementwise division from current ndarray this mutate the current NDArray More... | |
NDArray | T () const |
return transpose of current NDArray More... | |
NDArray | Copy (Context ctx) const |
return a new copy this NDArray More... | |
void | SyncCopyFromCPU (const void *data, size_t size) const |
Do a synchronize copy from a continugous CPU memory region. More... | |
void | SyncCopyToCPU (void *data, size_t size) const |
Do a synchronize copy to a continugous CPU memory region. More... | |
NDArray | Slice (index_t begin, index_t end) const |
Slice a NDArray. More... | |
NDArray | At (index_t idx) const |
Index a NDArray. More... | |
NDArray | Reshape (const TShape &shape) const |
Get an reshaped NDArray. More... | |
void | CheckAndAlloc () const |
Allocate the space if it is delayed allocated. This is an internal function used by system that normal user should not use. More... | |
Static Public Member Functions | |
static void | Save (dmlc::Stream *fo, const std::vector< NDArray > &data, const std::vector< std::string > &names) |
Save list of narray into the Stream.x. More... | |
static void | Load (dmlc::Stream *fi, std::vector< NDArray > *data, std::vector< std::string > *keys) |
Load list of narray into from the stream. More... | |
ndarray interface
|
inline |
default cosntructor
|
inline |
|
inline |
Allocate the space if it is delayed allocated. This is an internal function used by system that normal user should not use.
|
inline |
|
inline |
|
inline |
|
inline |
bool mxnet::NDArray::Load | ( | dmlc::Stream * | strm | ) |
load the content from binary stream
strm | the output stream |
|
static |
Load list of narray into from the stream.
fi | The stream of the input file. |
data | the NDArrays to be loaded |
keys | the name of the NDArray, if saved in the file. |
elementwise multiplication to current ndarray this mutate the current NDArray
src | the data to substract |
elementwise multiplication to current ndarray this mutate the current NDArray
src | the data to substract |
elementwise add to current space this mutate the current NDArray
src | the data to add |
elementwise add to current space this mutate the current NDArray
src | the data to add |
elementwise subtract from current ndarray this mutate the current NDArray
src | the data to substract |
elementwise subtract from current ndarray this mutate the current NDArray
src | the data to substract |
elementwise division from current ndarray this mutate the current NDArray
src | the data to substract |
elementwise division from current ndarray this mutate the current NDArray
src | the data to substract |
set all the elements in ndarray to be scalar
scalar | the scalar to set |
void mxnet::NDArray::Save | ( | dmlc::Stream * | strm | ) | const |
save the content into binary stream
strm | the output stream |
|
static |
Save list of narray into the Stream.x.
fo | The stream of output. |
data | the NDArrays to be saved. |
names | the name of the NDArray, optional, can be zero length. |
void mxnet::NDArray::SyncCopyFromCPU | ( | const void * | data, |
size_t | size | ||
) | const |
Do a synchronize copy from a continugous CPU memory region.
This function will call WaitToWrite before the copy is performed. This is useful to copy data from existing memory region that are not wrapped by NDArray(thus dependency not being tracked).
data | the data source to copy from. |
size | the size of the source array, in sizeof(DType) not raw btyes. |
void mxnet::NDArray::SyncCopyToCPU | ( | void * | data, |
size_t | size | ||
) | const |
Do a synchronize copy to a continugous CPU memory region.
This function will call WaitToRead before the copy is performed. This is useful to copy data from existing memory region that are not wrapped by NDArray(thus dependency not being tracked).
data | the data source to copyinto. |
size | the memory size we want to copy into, in sizeof(DType) not raw btyes. |
NDArray mxnet::NDArray::T | ( | ) | const |
|
inline |
|
inline |
Block until all the pending write operations with respect to current NDArray are finished, and read can be performed.
|
inline |
Block until all the pending read/write operations with respect to current NDArray are finished, and write can be performed.
Push an empty mutable function to flush all preceding reads to the variable.