Apache SINGA
A distributed deep learning platform .
|
namespace for mshadow More...
Namespaces | |
expr | |
namespace for abstract expressions and expressions template, have no dependecy on tensor.h, These data structure takes no charge in computations, they are only used to define operations and represent expression in a symbolic way | |
op | |
operations for algorithm | |
red | |
namespace for potential reducer operations | |
sse2 | |
namespace to support sse2 vectorization | |
sv | |
namespace for savers | |
utils | |
namespace for helper utils of the project | |
Classes | |
struct | Shape |
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... | |
struct | cpu |
device name CPU More... | |
struct | gpu |
device name CPU More... | |
struct | Tensor |
general tensor More... | |
struct | Tensor< Device, 1 > |
class | TensorContainer |
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... | |
struct | MapExpCPUEngine |
struct | MapExpCPUEngine< false, SV, dim, E, etype > |
struct | MapExpCPUEngine< true, SV, dim, E, etype > |
class | Random |
random number generator More... | |
class | Random< cpu > |
CPU random number generator. More... | |
Typedefs | |
typedef float | real_t |
type that will be used for content | |
typedef unsigned | index_t |
type that will be used for index | |
Functions | |
MSHADOW_XINLINE Shape< 1 > | Shape1 (index_t s0) |
construct a one dimension shape, stride will equal s0 More... | |
MSHADOW_XINLINE Shape< 2 > | Shape2 (index_t s1, index_t s0) |
construct a two dimension shape, stride will equal s0 More... | |
MSHADOW_XINLINE Shape< 3 > | Shape3 (index_t s2, index_t s1, index_t s0) |
construct a three dimension shape, stride will equal s0 More... | |
MSHADOW_XINLINE Shape< 4 > | Shape4 (index_t s3, index_t s2, index_t s1, index_t s0) |
construct a four dimension shape, stride will equal s0 More... | |
void | InitTensorEngine (int device_id=0) |
initialize tensor engine, used to call intialization functions of dependent libs this function should be called before all GPU tensor operations, for using tensors in CPU, this call is actually not needed More... | |
void | ShutdownTensorEngine (void) |
Shutdown tensor engine, this function should be called after all GPU tensor operations, for using tensors in CPU, this call is actually not needed. | |
template<int dim> | |
void | AllocSpace (Tensor< cpu, dim > &obj, bool pad=MSHADOW_ALLOC_PAD) |
CPU/CPU: allocate space for CTensor, according to the shape in the obj this function is responsible to set the stride_ in each obj.shape. More... | |
template<int dim> | |
void | AllocSpace (Tensor< gpu, dim > &obj, bool pad=MSHADOW_ALLOC_PAD) |
refer to comment of cpu ver More... | |
template<int dim> | |
void | FreeSpace (Tensor< cpu, dim > &obj) |
CPU/GPU: free the space of tensor, will set obj.dptr to NULL. More... | |
template<int dim> | |
void | FreeSpace (Tensor< gpu, dim > &obj) |
refer to comment of cpu ver More... | |
template<typename Device , int dim> | |
Tensor< Device, dim > | NewTensor (const Shape< dim > &shape, real_t initv, bool pad=MSHADOW_ALLOC_PAD) |
CPU/GPU: short cut to allocate and initialize a Tensor. More... | |
template<int dim> | |
void | Copy (Tensor< cpu, dim > dst, const Tensor< cpu, dim > &src) |
copy data from one tensor to another, with same shape More... | |
template<int dim> | |
void | Copy (Tensor< cpu, dim > dst, const Tensor< gpu, dim > &src) |
refer to comment of cpu ver More... | |
template<int dim> | |
void | Copy (Tensor< gpu, dim > dst, const Tensor< cpu, dim > &src) |
refer to comment of cpu ver More... | |
template<int dim> | |
void | Copy (Tensor< gpu, dim > dst, const Tensor< gpu, dim > &src) |
refer to comment of cpu ver More... | |
void | Softmax (Tensor< cpu, 2 > dst, const Tensor< cpu, 2 > &energy) |
CPU/GPU: normalize softmax: dst[i][j] = exp( energy[i][j] ) /( sum_j exp( energy[i][j] ) ) More... | |
void | Softmax (Tensor< gpu, 2 > dst, const Tensor< gpu, 2 > &energy) |
refer to comment of cpu ver More... | |
template<typename Saver , int dim, typename E , int etype> | |
void | MapExp (Tensor< cpu, dim > dst, const expr::Exp< E, etype > &exp) |
CPU/GPU: map a expression to a tensor, this function calls MapPlan. More... | |
template<typename Saver , int dim, typename E , int etype> | |
void | MapExp (Tensor< gpu, dim > dst, const expr::Exp< E, etype > &exp) |
refer to comment of cpu ver More... | |
template<typename Saver , typename Reducer , typename E , int etype> | |
void | MapReduceKeepLowest (Tensor< cpu, 1 > dst, const expr::Exp< E, etype > &exp, real_t scale=1.0f) |
CPU/GPU: map a expression, do reduction to 1D Tensor in lowest dimension (dimension 0) More... | |
template<typename Saver , typename Reducer , typename E , int etype> | |
void | MapReduceKeepLowest (Tensor< gpu, 1 > dst, const expr::Exp< E, etype > &exp, real_t scale=1.0f) |
refer to comment of cpu ver More... | |
template<typename Saver , typename Reducer , int dimkeep, typename E , int etype> | |
void | MapReduceKeepHighDim (Tensor< cpu, 1 > dst, const expr::Exp< E, etype > &exp, real_t scale=1.0f) |
CPU/GPU: map a expression, do reduction to 1D Tensor in third dimension (dimension 2) More... | |
template<typename Saver , typename Reducer , int dimkeep, typename E , int etype> | |
void | MapReduceKeepHighDim (Tensor< gpu, 1 > dst, const expr::Exp< E, etype > &exp, real_t scale=1.0f) |
refer to comment of cpu ver More... | |
template<typename Saver , typename E , int dim> | |
void | MapPlan (Tensor< cpu, dim > _dst, const expr::Plan< E > &plan) |
void | Softmax (Tensor< cpu, 1 > dst, const Tensor< cpu, 1 > &energy) |
template<typename A , typename B , int dim> | |
void | Copy (Tensor< A, dim > _dst, Tensor< B, dim > _src, cudaMemcpyKind kind) |
template<int dim, typename TStream > | |
void | SaveBinary (TStream &fo, const Tensor< cpu, dim > &src) |
CPU/GPU: save a tensor by binary format, for GPU version, a temp Tensor<cpu,dim> storage will be allocated. More... | |
template<int dim, typename TStream > | |
void | SaveBinary (TStream &fo, const Tensor< gpu, dim > &src) |
refer to comment of cpu ver More... | |
template<int dim, typename TStream > | |
void | LoadBinary (TStream &fi, Tensor< cpu, dim > &dst, bool pre_alloc) |
CPU/GPU: load a tensor by binary format, for GPU version, a temp Tensor<cpu,dim> storage will be allocated if pre_alloc is true , then space in dst is preallocated, and must have same shape of the tensor loaded if pre_alloc is false, then dst originally does not have space allocated, LoadBinary will allocate space for dst. More... | |
template<int dim, typename TStream > | |
void | LoadBinary (TStream &fi, Tensor< gpu, dim > &dst, bool pre_alloc) |
refer to comment of cpu ver More... | |
template<typename SV , typename E , int dim> | |
void | MapSSEPlan (Tensor< cpu, dim > _dst, const expr::SSEPlan< E > &plan) |
use SSEPlan to compute result | |
Variables | |
const unsigned | kRandBufferSize = 1000000 |
buffer size for each random number generator | |
const float | kPi = 3.1415926f |
pi | |
namespace for mshadow
|
inline |
CPU/CPU: allocate space for CTensor, according to the shape in the obj this function is responsible to set the stride_ in each obj.shape.
dim | specify the dim of tensor |
obj | the tensor object, with shape specified |
pad | whether padding dimension 0, to make last dimension aligned, padding may help improve efficiency of matrix multiplications if true, will allocate space with stride_ that may not equals shape[0] if false, will allocate continuous space |
|
inline |
refer to comment of cpu ver
|
inline |
copy data from one tensor to another, with same shape
dim | specify the dim of tensor |
dst | target tensor |
src | source tensor |
|
inline |
refer to comment of cpu ver
|
inline |
refer to comment of cpu ver
|
inline |
refer to comment of cpu ver
|
inline |
CPU/GPU: free the space of tensor, will set obj.dptr to NULL.
dim | specify the dim of tensor |
obj | the tensor object |
|
inline |
refer to comment of cpu ver
|
inline |
initialize tensor engine, used to call intialization functions of dependent libs this function should be called before all GPU tensor operations, for using tensors in CPU, this call is actually not needed
device_id | GPU device id to be choosed |
|
inline |
CPU/GPU: load a tensor by binary format, for GPU version, a temp Tensor<cpu,dim> storage will be allocated if pre_alloc is true , then space in dst is preallocated, and must have same shape of the tensor loaded if pre_alloc is false, then dst originally does not have space allocated, LoadBinary will allocate space for dst.
fi | output binary stream |
dst | destination file |
pre_alloc | whether space is pre-allocated, if false, space allocation will happen |
dim | dimension of tensor |
TStream | type of stream, need to support Read, Write, one example is utils::IStream. |
|
inline |
refer to comment of cpu ver
|
inline |
CPU/GPU: map a expression to a tensor, this function calls MapPlan.
Saver | specify storage method |
dim | dim of the tensor, during usage, there is no need to specify this parameter |
E | specifies the expression type, not need to specify this parameter during usage |
etype | expression type |
dst | destination |
exp | expression |
|
inline |
refer to comment of cpu ver
|
inline |
CPU/GPU: map a expression, do reduction to 1D Tensor in third dimension (dimension 2)
Saver | specify storage method |
Reducer | specify a reducer method |
E | specifies the expression type, not need to specify this parameter during usage |
dimkeep | the target dimension to be kept, should be larger than 0, for 0, use MapReduceKeepLowest |
etype | expression type |
dst | destination |
exp | expression |
scale | scale the result before save |
|
inline |
refer to comment of cpu ver
|
inline |
CPU/GPU: map a expression, do reduction to 1D Tensor in lowest dimension (dimension 0)
Saver | specify storage method |
Reducer | specify a reducer method |
E | specifies the expression type, not need to specify this parameter during usage |
etype | expression type |
dst | destination |
exp | expression |
scale | scale the result before save |
|
inline |
refer to comment of cpu ver
|
inline |
CPU/GPU: short cut to allocate and initialize a Tensor.
Device | device of tensor |
dim | dimention of tensor |
shape | shape of tensor |
initv | initialization value |
pad | : padding option |
|
inline |
CPU/GPU: save a tensor by binary format, for GPU version, a temp Tensor<cpu,dim> storage will be allocated.
fo | output binary stream |
src | source data file |
dim | dimension of tensor |
TStream | type of stream, need to support Read, Write, one example is utils::IStream. |
|
inline |
refer to comment of cpu ver
MSHADOW_XINLINE Shape<1> mshadow::Shape1 | ( | index_t | s0 | ) |
construct a one dimension shape, stride will equal s0
s0 | size of dimension 0 |
MSHADOW_XINLINE Shape<2> mshadow::Shape2 | ( | index_t | s1, |
index_t | s0 | ||
) |
construct a two dimension shape, stride will equal s0
s1 | size of dimension 1 |
s0 | size of dimension 0 |
MSHADOW_XINLINE Shape<3> mshadow::Shape3 | ( | index_t | s2, |
index_t | s1, | ||
index_t | s0 | ||
) |
construct a three dimension shape, stride will equal s0
s2 | size of dimension 2 |
s1 | size of dimension 1 |
s0 | size of dimension 0 |
MSHADOW_XINLINE Shape<4> mshadow::Shape4 | ( | index_t | s3, |
index_t | s2, | ||
index_t | s1, | ||
index_t | s0 | ||
) |
construct a four dimension shape, stride will equal s0
s3 | size of dimension 3 |
s2 | size of dimension 2 |
s1 | size of dimension 1 |
s0 | size of dimension 0 |
|
inline |
CPU/GPU: normalize softmax: dst[i][j] = exp( energy[i][j] ) /( sum_j exp( energy[i][j] ) )
dst | destination |
energy | input energy |
|
inline |
refer to comment of cpu ver