mxnet
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE > Struct Template Reference

general tensor More...

#include <tensor.h>

Inheritance diagram for mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >:
Inheritance graph
Collaboration diagram for mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >:
Collaboration graph

Public Member Functions

MSHADOW_XINLINE Tensor (void)
 default constructor More...
 
MSHADOW_XINLINE Tensor (const Shape< dimension > &shape)
 constructor from shape More...
 
MSHADOW_XINLINE Tensor (DType *dptr, const Shape< dimension > &shape)
 constructor from data pointer and shape, without stride More...
 
MSHADOW_XINLINE Tensor (DType *dptr, const Shape< dimension > &shape, Stream< Device > *stream)
 constructor from data pointer and shape, without stride More...
 
MSHADOW_XINLINE Tensor (DType *dptr, const Shape< dimension > &shape, index_t stride, Stream< Device > *stream)
 constructor from data pointer and shape More...
 
void set_stream (Stream< Device > *stream)
 set the stream to do computation of current tensor More...
 
template<int startdim>
MSHADOW_XINLINE index_t MemSize (void) const
 
MSHADOW_XINLINE bool CheckContiguous (void) const
 
MSHADOW_XINLINE index_t MSize (void) const
 
MSHADOW_XINLINE index_t size (int idx) const
 return size of i-th dimension, start counting from highest dimension More...
 
MSHADOW_XINLINE Tensor< Device, 1, DType > FlatTo1D (void) const
 flatten the tensor to 1 dimension More...
 
MSHADOW_XINLINE Tensor< Device, 2, DType > FlatTo2D (void) const
 flatten the tensor to 2 dimension, collapse the higher dimensions together More...
 
MSHADOW_XINLINE Tensor< Device, kSubdim, DType > operator[] (index_t idx) const
 get a element of dimension - 1 More...
 
MSHADOW_XINLINE Tensor< Device, dimension, DType > Slice (index_t begin, index_t end) const
 slice the tensor in highest dimension [begin,end) More...
 
Tensor< Device, dimension, DType > & operator= (const Tensor< Device, dimension, DType > &exp)
 implement the assignment of same type More...
 
template<typename E , int etype>
Tensor< Device, dimension, DType > & operator= (const expr::Exp< E, DType, etype > &exp)
 functions to fit expression template More...
 
Tensor< Device, dimension, DType > & operator= (const DType &exp)
 functions to fit expression template More...
 
- Public Member Functions inherited from mshadow::expr::RValueExp< Tensor< Device, dimension, DType >, DType >
const TransposeExp< Tensor< Device, dimension, DType >, DType > T (void) const
 transpose of a matrix More...
 
Tensor< Device, dimension, DType > & operator+= (DType s)
 operator overload More...
 
Tensor< Device, dimension, DType > & operator+= (const Exp< E, DType, etype > &exp)
 implementation of operator+= More...
 
Tensor< Device, dimension, DType > & operator-= (DType s)
 operator overload More...
 
Tensor< Device, dimension, DType > & operator-= (const Exp< E, DType, etype > &exp)
 implementation of operator-= More...
 
Tensor< Device, dimension, DType > & operator*= (DType s)
 operator overload More...
 
Tensor< Device, dimension, DType > & operator*= (const Exp< E, DType, etype > &exp)
 implementation of operator*= More...
 
Tensor< Device, dimension, DType > & operator/= (DType s)
 operator overload More...
 
Tensor< Device, dimension, DType > & operator/= (const Exp< E, DType, etype > &exp)
 implementation of operator/= More...
 
Tensor< Device, dimension, DType > & __assign (DType s)
 operator overload More...
 
Tensor< Device, dimension, DType > & __assign (const Exp< E, DType, etype > &exp)
 we can not define container = container More...
 
Tensor< Device, dimension, DType > & __assign (const Exp< Tensor< Device, dimension, DType >, DType, type::kRValue > &exp)
 operator overload, assign More...
 
- Public Member Functions inherited from mshadow::expr::Exp< Tensor< Device, dimension, DType >, DType, type::kRValue >
const Tensor< Device, dimension, DType > & self (void) const
 
Tensor< Device, dimension, DType > * ptrself (void)
 

Public Attributes

DType * dptr_ = nullptr
 pointer to the data More...
 
Shape< dimension > shape_
 shape of the tensor More...
 
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 More...
 
Stream< Device > * stream_
 stream where the computation lies stream is a device dependency concept where each computation More...
 

Static Public Attributes

static const bool kDevCPU = Device::kDevCPU
 whether current type lies in cpu More...
 
static const int kSubdim = dimension - 1
 dimension of subtype More...
 

Detailed Description

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
struct mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >

general tensor

Template Parameters
Devicewhich device the tensor is on
dimensiondimension of the tensor
DTypethe type of elements in the tensor

Constructor & Destructor Documentation

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::Tensor ( void  )
inline

default constructor

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::Tensor ( const Shape< dimension > &  shape)
inline

constructor from shape

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::Tensor ( DType *  dptr,
const Shape< dimension > &  shape 
)
inline

constructor from data pointer and shape, without stride

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::Tensor ( DType *  dptr,
const Shape< dimension > &  shape,
Stream< Device > *  stream 
)
inline

constructor from data pointer and shape, without stride

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::Tensor ( DType *  dptr,
const Shape< dimension > &  shape,
index_t  stride,
Stream< Device > *  stream 
)
inline

constructor from data pointer and shape

Member Function Documentation

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE bool mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::CheckContiguous ( void  ) const
inline
Returns
whether the tensor's memory is continuous x dimension same as stride
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE Tensor<Device, 1, DType> mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::FlatTo1D ( void  ) const
inline

flatten the tensor to 1 dimension

Returns
tensor after flatten
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE Tensor<Device, 2, DType> mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::FlatTo2D ( void  ) const
inline

flatten the tensor to 2 dimension, collapse the higher dimensions together

Returns
tensor after flatten
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
template<int startdim>
MSHADOW_XINLINE index_t mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::MemSize ( void  ) const
inline
Returns
memory cost of the tensor, including the aligned x dimension
Template Parameters
startdimthe starting dimension
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE index_t mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::MSize ( void  ) const
inline
Returns
memory cost of the tensor, including the aligned x dimension
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
Tensor<Device, dimension, DType>& mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::operator= ( const Tensor< Device, dimension, DType > &  exp)
inline

implement the assignment of same type

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
template<typename E , int etype>
Tensor<Device, dimension, DType>& mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::operator= ( const expr::Exp< E, DType, etype > &  exp)
inline

functions to fit expression template

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
Tensor<Device, dimension, DType>& mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::operator= ( const DType &  exp)
inline

functions to fit expression template

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE Tensor<Device, kSubdim, DType> mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::operator[] ( index_t  idx) const
inline

get a element of dimension - 1

Parameters
idxindex
Returns
the result tensor
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
void mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::set_stream ( Stream< Device > *  stream)
inline

set the stream to do computation of current tensor

Parameters
streamthe computation stream
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE index_t mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::size ( int  idx) const
inline

return size of i-th dimension, start counting from highest dimension

Parameters
idxthe dimension count from the highest dimensin
Returns
the size
template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
MSHADOW_XINLINE Tensor<Device, dimension, DType> mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::Slice ( index_t  begin,
index_t  end 
) const
inline

slice the tensor in highest dimension [begin,end)

Parameters
beginbegin position of slice
endend position of slice
Returns
tensor after slice

Member Data Documentation

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
DType* mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::dptr_ = nullptr

pointer to the data

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
const bool mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::kDevCPU = Device::kDevCPU
static

whether current type lies in cpu

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
const int mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::kSubdim = dimension - 1
static

dimension of subtype

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
Shape<dimension> mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::shape_

shape of the tensor

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
Stream<Device>* mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::stream_

stream where the computation lies stream is a device dependency concept where each computation

template<typename Device, int dimension, typename DType MSHADOW_DEFAULT_DTYPE>
index_t mshadow::Tensor< Device, dimension, MSHADOW_DEFAULT_DTYPE >::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


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