Apache SINGA
A distributed deep learning platform .
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
mshadow::Shape< dimension > Struct Template Reference

shape of a tensor IMPORTANT NOTE: this shape is different from numpy.shape shape[0] gives the lowest dimension, shape[dimension-1] gives the highest dimension shape[k] corresponds to k-th dimension of tensor More...

#include <tensor.h>

Public Member Functions

MSHADOW_XINLINE Shape (void)
 default constructor, do nothing
 
MSHADOW_XINLINE Shape (const Shape< dimension > &s)
 constuctor
 
MSHADOW_XINLINE index_toperator[] (index_t idx)
 get corresponding index More...
 
MSHADOW_XINLINE const index_toperator[] (index_t idx) const
 get corresponding index More...
 
MSHADOW_XINLINE bool operator== (const Shape< kMaxShape > &s) const
 
MSHADOW_XINLINE Shape< 2 > FlatTo2D (void) const
 
MSHADOW_XINLINE size_t Size (void) const
 
MSHADOW_XINLINE size_t MSize (void) const
 
MSHADOW_XINLINE index_t ProdShape (int dimstart, int dimend) const
 
MSHADOW_XINLINE Shape< kSubShapeSubShape (void) const
 get subshape More...
 

Public Attributes

index_t shape_ [kMaxShape]
 storing the dimension information
 
index_t stride_
 storing the stride information in x dimension this is used to deal with pitch allocation in gpu or sse(align x dimension to 64bit) for efficiency
 

Static Public Attributes

static const int kMaxShape = dimension
 maximum dimension of tensor
 
static const int kSubShape = dimension - 1
 maximum dimension minus 1
 

Detailed Description

template<int dimension>
struct mshadow::Shape< dimension >

shape of a tensor IMPORTANT NOTE: this shape is different from numpy.shape shape[0] gives the lowest dimension, shape[dimension-1] gives the highest dimension shape[k] corresponds to k-th dimension of tensor

Template Parameters
dimensiondimension of tensor

Member Function Documentation

template<int dimension>
MSHADOW_XINLINE Shape<2> mshadow::Shape< dimension >::FlatTo2D ( void  ) const
inline

flatten the higher dimension to second dimension, return a 2D shape

Returns
the flat 2d shape
template<int dimension>
MSHADOW_XINLINE size_t mshadow::Shape< dimension >::MSize ( void  ) const
inline
Returns
memory size, including the aligned x dimension
template<int dimension>
MSHADOW_XINLINE bool mshadow::Shape< dimension >::operator== ( const Shape< kMaxShape< dimension > > &  s) const
inline
Returns
whether two shape equals
template<int dimension>
MSHADOW_XINLINE index_t& mshadow::Shape< dimension >::operator[] ( index_t  idx)
inline

get corresponding index

Parameters
idxdimension index
Returns
the corresponding dimension size
template<int dimension>
MSHADOW_XINLINE const index_t& mshadow::Shape< dimension >::operator[] ( index_t  idx) const
inline

get corresponding index

Parameters
idxdimension index
Returns
the corresponding dimension size
template<int dimension>
MSHADOW_XINLINE index_t mshadow::Shape< dimension >::ProdShape ( int  dimstart,
int  dimend 
) const
inline
Returns
product shape in [dimstart,dimend)
Parameters
dimstartstart dimension
dimendend dimension
template<int dimension>
MSHADOW_XINLINE size_t mshadow::Shape< dimension >::Size ( void  ) const
inline
Returns
number of valid elements
template<int dimension>
MSHADOW_XINLINE Shape<kSubShape> mshadow::Shape< dimension >::SubShape ( void  ) const
inline

get subshape

Returns
subshape

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