mxnet
Public Member Functions | List of all members
mxnet::TShape Class Reference

A Shape class that is used to represent shape of each tensor. More...

#include <tuple.h>

Inheritance diagram for mxnet::TShape:
Inheritance graph
Collaboration diagram for mxnet::TShape:
Collaboration graph

Public Member Functions

 TShape ()
 default constructor More...
 
 TShape (const int ndim, const dim_t value)
 
 TShape (const Tuple< dim_t > &s)
 copy constructor of TShape More...
 
 TShape (std::initializer_list< dim_t > init)
 constructor from initializer list More...
 
 TShape (Tuple< dim_t > &&s)
 move constructor. More...
 
template<typename RandomAccessIterator , typename std::enable_if< std::is_same< typename std::iterator_traits< RandomAccessIterator >::iterator_category, std::random_access_iterator_tag >::value, int >::type = 0>
 TShape (RandomAccessIterator begin, RandomAccessIterator end)
 construct the Tuple from content of iterator. This function is enforced with template arguments of random access iterator types. This is necessary to distinguish from another constructor: TShape(const int, const dim_t). More...
 
TShapeoperator= (const Tuple< dim_t > &src)
 assignment function from tshape More...
 
TShapeoperator= (Tuple< dim_t > &&src)
 move assignment function from tshape More...
 
size_t Size () const
 
size_t ProdShape (int dimstart, int dimend) const
 
const dim_tdata () const
 
dim_tdata ()
 
- Public Member Functions inherited from mxnet::Tuple< dim_t >
 Tuple ()=default
 default constructor More...
 
 Tuple (const Tuple< dim_t > &s)
 copy constructor from another tuple More...
 
 Tuple (std::initializer_list< dim_t > init)
 constructor from initializer list More...
 
 Tuple (std::vector< dim_t > init)
 constructor from vector More...
 
 Tuple (Tuple< dim_t > &&src)
 move constructor from Tuple More...
 
 Tuple (RandomAccessIterator begin, RandomAccessIterator end)
 construct the Tuple from content of iterator More...
 
 ~Tuple ()
 destructor More...
 
void assign (RandomAccessIterator begin, RandomAccessIterator end)
 Assign content to tuple from iterator. More...
 
void swap (Tuple< dim_t > &other)
 Swap current object with other. More...
 
Tuple< dim_t > & operator= (const Tuple< dim_t > &src)
 assignment from another tuple. More...
 
Tuple< dim_t > & operator= (Tuple< dim_t > &&src)
 assignment from rvalue of another tuple. More...
 
Tuple< dim_t > & operator= (std::initializer_list< dim_t > init)
 assignment from initializer list More...
 
bool operator== (const Tuple< dim_t > &s) const
 
bool operator!= (const Tuple< dim_t > &s) const
 
const dim_tbegin () const
 
dim_tbegin ()
 
const dim_tend () const
 
dim_tend ()
 
int ndim () const
 
dim_toperator[] (int i)
 get corresponding index More...
 
const dim_toperator[] (int i) const
 get corresponding index More...
 
void Save (dmlc::JSONWriter *writer) const
 Save Tuple to JSON. More...
 
void Save (TStream *strm) const
 save the content into binary stream More...
 
void Load (dmlc::JSONReader *reader)
 Load Tuple from JSON. More...
 
bool Load (TStream *strm)
 load the content from binary stream More...
 

Additional Inherited Members

- Protected Member Functions inherited from mxnet::Tuple< dim_t >
void SetDim (int ndim)
 
- Protected Attributes inherited from mxnet::Tuple< dim_t >
int ndim_
 number of dimension of the tuple More...
 
int num_heap_allocated_
 number of cells allocated in data_heap_ More...
 
dim_t data_stack_ [kStackCache]
 in stack space used to store shape when it is small More...
 
dim_tdata_heap_
 space to store shape when dimension is big More...
 
- Static Protected Attributes inherited from mxnet::Tuple< dim_t >
static const int kStackCache
 

Detailed Description

A Shape class that is used to represent shape of each tensor.

The ndim of a valid shape is an integer in range [-1, inf). ndim = -1 means the shape information is unknown and need to be inferred. ndim = 0 means the tensor with the shape is a scalar.

The dimension size of a valid shape is an integer in range [-1, inf). dim_size = -1 means the size of that dimension is unknown and need to be inferred. dim_size = 0 means that dimension is empty.

The definition of ndim = 0 and dim_size = 0 is consistent with NumPy.

Constructor & Destructor Documentation

mxnet::TShape::TShape ( )
inline

default constructor

mxnet::TShape::TShape ( const int  ndim,
const dim_t  value 
)
inline

constructor to construct a shape with all value.

Parameters
ndimthe number of dimension
valuethe dimension size for all dims
mxnet::TShape::TShape ( const Tuple< dim_t > &  s)
inline

copy constructor of TShape

Parameters
ssource shape.
mxnet::TShape::TShape ( std::initializer_list< dim_t init)
inline

constructor from initializer list

Parameters
initthe initializer_list
mxnet::TShape::TShape ( Tuple< dim_t > &&  s)
inline

move constructor.

Parameters
ssource shape.
template<typename RandomAccessIterator , typename std::enable_if< std::is_same< typename std::iterator_traits< RandomAccessIterator >::iterator_category, std::random_access_iterator_tag >::value, int >::type = 0>
mxnet::TShape::TShape ( RandomAccessIterator  begin,
RandomAccessIterator  end 
)
inline

construct the Tuple from content of iterator. This function is enforced with template arguments of random access iterator types. This is necessary to distinguish from another constructor: TShape(const int, const dim_t).

Parameters
beginthe beginning of iterator
endend the end of the iterator
Template Parameters
RandomAccessIteratoriterator type

Member Function Documentation

const dim_t* mxnet::TShape::data ( ) const
inline
Returns
the begin data pointer to content of the tuple
dim_t* mxnet::TShape::data ( )
inline
Returns
the begin data pointer to content of the tuple
TShape& mxnet::TShape::operator= ( const Tuple< dim_t > &  src)
inline

assignment function from tshape

Parameters
srcsource shape.
Returns
self.
TShape& mxnet::TShape::operator= ( Tuple< dim_t > &&  src)
inline

move assignment function from tshape

Parameters
srcsource shape.
Returns
self.
size_t mxnet::TShape::ProdShape ( int  dimstart,
int  dimend 
) const
inline
Returns
product shape in [dimstart,dimend)
Parameters
dimstartstart dimension
dimendend dimension
size_t mxnet::TShape::Size ( void  ) const
inline
Returns
total number of elements in the shape

The documentation for this class was generated from the following file: