Apache SINGA
A distributed deep learning platform .
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | List of all members
mshadow::TensorContainer< Device, dimension > Class Template Reference

tensor container that does memory allocation and resize like STL, use it to save the lines of FreeSpace in class. Do not abuse it, efficiency can come from pre-allocation and no re-allocation More...

#include <tensor_container.h>

Inheritance diagram for mshadow::TensorContainer< Device, dimension >:
mshadow::Tensor< Device, dimension > mshadow::expr::ContainerExp< Tensor< Device, dimension > > mshadow::expr::Exp< Tensor< Device, dimension >, type::kContainer >

Public Member Functions

 TensorContainer (bool pad=MSHADOW_ALLOC_PAD)
 constructor More...
 
 TensorContainer (const Shape< dimension > &shape)
 constructor More...
 
 TensorContainer (const Shape< dimension > &shape, real_t initv)
 constructor More...
 
void Resize (const Shape< dimension > &shape)
 resize the container to given shape, content is NOT preserved More...
 
void Resize (const Shape< dimension > &shape, real_t initv)
 resize the container to given shape, and initialize, content is NOT preserved More...
 
void set_pad (bool pad)
 set whether padding is allowed in tensor
 
template<typename TStream >
void SaveBinary (TStream &fo) const
 save by binary format More...
 
template<typename TStream >
void LoadBinary (TStream &fi)
 load by binary format, a temp Tensor<cpu,dim> storage will be allocated More...
 
Tensor< Device, dimension > & operator= (real_t s)
 
template<typename E >
Tensor< Device, dimension > & operator= (const expr::Exp< E, expr::type::kMapper > &exp)
 
template<typename E >
Tensor< Device, dimension > & operator= (const expr::Exp< E, expr::type::kComplex > &exp)
 
- Public Member Functions inherited from mshadow::Tensor< Device, dimension >
MSHADOW_XINLINE Tensor (void)
 default constructor
 
MSHADOW_XINLINE Tensor (const Shape< dimension > &shape)
 constructor from shape
 
MSHADOW_XINLINE Tensor (real_t *dptr, const Shape< dimension > &shape)
 constructor from data pointer and shape
 
MSHADOW_XINLINE Tensor< Device, 2 > FlatTo2D (void) const
 flatten the tensor to 2 dimension, collapse the higher dimensions together More...
 
MSHADOW_XINLINE Tensor< Device,
kSubdim
operator[] (index_t idx) const
 get a element of dimension - 1 More...
 
MSHADOW_XINLINE Tensor< Device,
dimension > 
Slice (index_t begin, index_t end) const
 slice the tensor in highest dimension [begin,end) More...
 
Tensor< Device, dimension > & operator= (real_t s)
 functions to fit expression template
 
template<typename E >
Tensor< Device, dimension > & operator= (const expr::Exp< E, expr::type::kMapper > &exp)
 functions to fit expression template
 
template<typename E >
Tensor< Device, dimension > & operator= (const expr::Exp< E, expr::type::kComplex > &exp)
 functions to fit expression template
 
- Public Member Functions inherited from mshadow::expr::ContainerExp< Tensor< Device, dimension > >
const TransposeExp< Tensor
< Device, dimension > > 
T (void) const
 transpose of a matrix More...
 
Tensor< Device, dimension > & operator+= (real_t s)
 operator overload
 
Tensor< Device, dimension > & operator+= (const Exp< E, etype > &exp)
 implementation of operator+=
 
Tensor< Device, dimension > & operator-= (real_t s)
 operator overload
 
Tensor< Device, dimension > & operator-= (const Exp< E, etype > &exp)
 implementation of operator-=
 
Tensor< Device, dimension > & operator*= (real_t s)
 operator overload
 
Tensor< Device, dimension > & operator*= (const Exp< E, etype > &exp)
 implementation of operator*=
 
Tensor< Device, dimension > & operator/= (real_t s)
 operator overload
 
Tensor< Device, dimension > & operator/= (const Exp< E, etype > &exp)
 implementation of operator/=
 
Tensor< Device, dimension > & __assign (real_t s)
 operator overload
 
Tensor< Device, dimension > & __assign (const Exp< E, type::kMapper > &exp)
 implementation of operator=, note that we can not define container = container
 
Tensor< Device, dimension > & __assign (const Exp< E, type::kComplex > &exp)
 implementation of operator=, note that we can not define container = container
 
- Public Member Functions inherited from mshadow::expr::Exp< Tensor< Device, dimension >, type::kContainer >
const Tensor< Device, dimension > & self (void) const
 
Tensor< Device, dimension > & refself (void)
 

Additional Inherited Members

- Public Attributes inherited from mshadow::Tensor< Device, dimension >
real_tdptr
 pointer to the data
 
Shape< dimension > shape
 shape of the tensor
 
- Static Public Attributes inherited from mshadow::Tensor< Device, dimension >
static const bool kDevCPU = Device::kDevCPU
 whether current type lies in cpu
 
static const int kSubdim = dimension - 1
 dimension of subtype
 

Detailed Description

template<typename Device, int dimension>
class mshadow::TensorContainer< Device, dimension >

tensor container that does memory allocation and resize like STL, use it to save the lines of FreeSpace in class. Do not abuse it, efficiency can come from pre-allocation and no re-allocation

Template Parameters
Devicewhich device the tensor is on
dimensiondimension of the tensor

Constructor & Destructor Documentation

template<typename Device, int dimension>
mshadow::TensorContainer< Device, dimension >::TensorContainer ( bool  pad = MSHADOW_ALLOC_PAD)
inline

constructor

Parameters
padwhether use padding alignment in space allocation
template<typename Device, int dimension>
mshadow::TensorContainer< Device, dimension >::TensorContainer ( const Shape< dimension > &  shape)
inline

constructor

Parameters
shapeintial shape
template<typename Device, int dimension>
mshadow::TensorContainer< Device, dimension >::TensorContainer ( const Shape< dimension > &  shape,
real_t  initv 
)
inline

constructor

Parameters
shapeintial shape
initvintial value

Member Function Documentation

template<typename Device, int dimension>
template<typename TStream >
void mshadow::TensorContainer< Device, dimension >::LoadBinary ( TStream &  fi)
inline

load by binary format, a temp Tensor<cpu,dim> storage will be allocated

Parameters
fiinput binary stream
Template Parameters
TStreamtype of stream, need to support Read, Write, one example is utils::IStream.
template<typename Device, int dimension>
void mshadow::TensorContainer< Device, dimension >::Resize ( const Shape< dimension > &  shape)
inline

resize the container to given shape, content is NOT preserved

Parameters
shapetarget shape
template<typename Device, int dimension>
void mshadow::TensorContainer< Device, dimension >::Resize ( const Shape< dimension > &  shape,
real_t  initv 
)
inline

resize the container to given shape, and initialize, content is NOT preserved

Parameters
shapetarget shape
initvinitialization value
template<typename Device, int dimension>
template<typename TStream >
void mshadow::TensorContainer< Device, dimension >::SaveBinary ( TStream &  fo) const
inline

save by binary format

Parameters
fooutput binary stream
Template Parameters
TStreamtype of stream, need to support Read, Write, one example is utils::IStream.

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