mxnet
|
A dynamic sized array data structure that is optimized for storing small number of elements with same type. More...
#include <tuple.h>
Public Member Functions | |
Tuple ()=default | |
default constructor More... | |
~Tuple () | |
destructor More... | |
Tuple (const Tuple< ValueType > &s) | |
copy constructor from another tuple More... | |
Tuple (std::initializer_list< ValueType > init) | |
constructor from initializer list More... | |
Tuple (std::vector< ValueType > init) | |
constructor from vector More... | |
Tuple (Tuple< ValueType > &&src) | |
move constructor from Tuple More... | |
template<typename RandomAccessIterator > | |
Tuple (RandomAccessIterator begin, RandomAccessIterator end) | |
construct the Tuple from content of iterator More... | |
template<typename RandomAccessIterator > | |
void | assign (RandomAccessIterator begin, RandomAccessIterator end) |
Assign content to tuple from iterator. More... | |
void | swap (Tuple< ValueType > &other) |
Swap current object with other. More... | |
Tuple< ValueType > & | operator= (const Tuple< ValueType > &src) |
assignment from another tuple. More... | |
Tuple< ValueType > & | operator= (Tuple< ValueType > &&src) |
assignment from rvalue of another tuple. More... | |
Tuple< ValueType > & | operator= (std::initializer_list< ValueType > init) |
assignment from initializer list More... | |
bool | operator== (const Tuple< ValueType > &s) const |
bool | operator!= (const Tuple< ValueType > &s) const |
const ValueType * | begin () const |
ValueType * | begin () |
const ValueType * | end () const |
ValueType * | end () |
int | ndim () const |
ValueType & | operator[] (int i) |
get corresponding index More... | |
const ValueType & | operator[] (int i) const |
get corresponding index More... | |
void | Save (dmlc::JSONWriter *writer) const |
Save Tuple to JSON. More... | |
void | Load (dmlc::JSONReader *reader) |
Load Tuple from JSON. More... | |
template<typename DType = ValueType, typename TStream > | |
void | Save (TStream *strm) const |
save the content into binary stream More... | |
template<typename DType = ValueType, typename TStream > | |
bool | Load (TStream *strm) |
load the content from binary stream More... | |
Protected Member Functions | |
void | SetDim (int ndim) |
Protected Attributes | |
int | ndim_ {0} |
number of dimension of the tuple More... | |
int | num_heap_allocated_ {0} |
number of cells allocated in data_heap_ More... | |
ValueType | data_stack_ [kStackCache] |
in stack space used to store shape when it is small More... | |
ValueType * | data_heap_ {nullptr} |
space to store shape when dimension is big More... | |
Static Protected Attributes | |
static const int | kStackCache = 4 |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Tuple< ValueType > &t) |
allow output string of tuple to ostream More... | |
std::istream & | operator>> (std::istream &is, Tuple< ValueType > &t) |
read tuple from the istream More... | |
A dynamic sized array data structure that is optimized for storing small number of elements with same type.
Data will be stored in stack when number of elements is small. It is suitable to hold shape of Tensor.
The ndim of a valid tuple is an integer in range [0, inf). ndim = 0 means the tuple is empty.
ValueType | The type of data stored inside tuple. |
|
default |
default constructor
|
inline |
destructor
|
inline |
copy constructor from another tuple
s | the source tuple |
|
inline |
constructor from initializer list
init | the initializer_list |
|
inline |
constructor from vector
init | the vector |
|
inline |
move constructor from Tuple
src | the source shape |
|
inline |
construct the Tuple from content of iterator
begin | the beginning of iterator |
end | end the end of the iterator |
RandomAccessIterator | iterator type |
|
inline |
Assign content to tuple from iterator.
begin | the beginning of iterator |
end | end the end of the iterator |
RandomAccessIterator | iterator type |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Load Tuple from JSON.
reader | JSONReader |
|
inline |
load the content from binary stream
strm | the output stream |
DType | data type that load from |
TStream | any stream type that have write |
ValueType | The type of data stored inside tuple. |
|
inline |
|
inline |
s | the tuple to compare against |
|
inline |
assignment from another tuple.
src | source tuple |
|
inline |
assignment from rvalue of another tuple.
src | source tuple |
|
inline |
assignment from initializer list
init | the source initializer list |
|
inline |
s | the tuple to compare against |
|
inline |
get corresponding index
i | dimension index |
|
inline |
get corresponding index
i | dimension index |
|
inline |
Save Tuple to JSON.
writer | JSONWriter |
|
inline |
save the content into binary stream
strm | the output stream |
DType | data type that save to |
TStream | any stream type that have write |
ValueType | The type of data stored inside tuple. |
|
inlineprotected |
|
inline |
Swap current object with other.
other | another object to be swapped. |
|
friend |
allow output string of tuple to ostream
os | the output stream |
t | the tuple |
|
friend |
read tuple from the istream
is | the input stream |
t | The tuple |
|
protected |
space to store shape when dimension is big
|
protected |
in stack space used to store shape when it is small
|
staticprotected |
|
protected |
number of dimension of the tuple
|
protected |
number of cells allocated in data_heap_