7 #ifndef MSHADOW_TENSOR_CONTAINER_H_ 8 #define MSHADOW_TENSOR_CONTAINER_H_ 21 template<
typename Device,
int dimension,
typename DType = default_real_t>
43 this->AllocByShape(shape);
53 this->AllocByShape(shape);
69 if (src.
dptr_ != NULL) {
70 this->AllocByShape(src.
shape_);
84 this->AllocByShape(shape);
112 template<
typename TStream>
121 template<
typename TStream>
127 Copy(*
this, tmp, &stream);
137 this->pad_ = src.pad_;
139 if (src.
dptr_ != NULL) {
173 if (data_.
dptr_ != NULL) {
177 this->data_.
shape_[0] = 0;
180 }
catch (
const dmlc::Error &e) {
208 #endif // MSHADOW_TENSOR_CONTAINER_H_ void FreeSpace(Tensor< cpu, dim, DType > *obj)
CPU/GPU: free the space of tensor, will set obj.dptr to NULL.
Definition: tensor_cpu-inl.h:122
void Resize(const Shape< dimension > &shape, DType initv)
resize the container to given shape, and initialize, content is NOT preserved
Definition: tensor_container.h:99
PaddingExp< SrcExp, DType, ExpInfo< SrcExp >::kDim > pad(const Exp< SrcExp, DType, etype > &src, index_t pad)
padding expression, pad a image with zeros on boundaries, padding affects shape[0], and shape[1]
Definition: pad.h:53
Tensor< Device, dimension, DType > & operator=(const expr::Exp< E, DType, expr::type::kComplex > &exp)
functions to fit expression template
Definition: tensor_container.h:164
DType * dptr_
pointer to the data
Definition: tensor.h:416
TensorContainer(const Shape< dimension > &shape, DType initv)
constructor
Definition: tensor_container.h:50
void LoadBinary(TStream &fi, Tensor< cpu, dim, DType > *dst, bool pre_alloc)
CPU/GPU: load a tensor by binary format, for GPU version, a temp Tensor<cpu,dim> storage will be allo...
Definition: io.h:107
void Copy(Tensor< cpu, dim, DType > dst, const Tensor< cpu, dim, DType > &src, Stream< cpu > *stream=NULL)
copy data from one tensor to another, with same shape
Definition: tensor_cpu-inl.h:127
shape of a tensor
Definition: tensor.h:35
void set_pad(bool pad)
set whether padding is allowed in tensor
Definition: tensor_container.h:104
Shape< dimension > shape_
shape of the tensor
Definition: tensor.h:418
TensorContainer(bool pad=MSHADOW_ALLOC_PAD)
constructor
Definition: tensor_container.h:28
Tensor< Device, dimension, DType > & operator=(const expr::Exp< E, DType, expr::type::kChainer > &exp)
functions to fit expression template
Definition: tensor_container.h:158
void Release(void)
Release the llocated space, The TensorContainer is still functionable, but will restart allocating sp...
Definition: tensor_container.h:172
MSHADOW_XINLINE Shape< 2 > FlatTo2D(void) const
Definition: tensor.h:114
#define MSHADOW_ALLOC_PAD
whether do padding during allocation
Definition: base.h:54
void AllocSpace(Tensor< cpu, dim, DType > *obj, bool pad=MSHADOW_ALLOC_PAD)
CPU/CPU: allocate space for CTensor, according to the shape in the obj this function is responsible t...
Definition: tensor_cpu-inl.h:98
TensorContainer(const Shape< dimension > &shape)
constructor
Definition: tensor_container.h:40
Tensor< Device, dimension, DType > & operator=(DType s)
functions to fit expression template
Definition: tensor_container.h:146
tensor container that does memory allocation and resize like STL, use it to save the lines of FreeSpa...
Definition: tensor_container.h:22
void SaveBinary(TStream &fo) const
save by binary format
Definition: tensor_container.h:113
index_t shape_[kDimension]
storing the dimension information
Definition: tensor.h:57
~TensorContainer(void) MSHADOW_THROW_EXCEPTION
Definition: tensor_container.h:74
void LoadBinary(TStream &fi)
load by binary format, a temp Tensor<cpu,dim> storage will be allocated
Definition: tensor_container.h:122
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:61
namespace for mshadow
Definition: base.h:282
#define MSHADOW_THROW_EXCEPTION
Definition: base.h:234
MSHADOW_XINLINE index_t size(int idx) const
return size of i-th dimension, start counting from highest dimension
Definition: tensor.h:487
Tensor< Device, dimension, DType > & operator=(const expr::Exp< E, DType, expr::type::kMapper > &exp)
functions to fit expression template
Definition: tensor_container.h:152
void SaveBinary(TStream &fo, const Tensor< cpu, dim, DType > &src)
CPU/GPU: save a tensor by binary format, for GPU version, a temp Tensor<cpu,dim> storage will be allo...
Definition: io.h:89
index_t stride_
storing the stride information in x dimension this is used to deal with pitch allocation in gpu or ss...
Definition: tensor.h:423
Tensor< Device, dimension, DType > & __assign(DType s)
operator overload
Definition: expression.h:160
general tensor
Definition: tensor.h:402
void Resize(const Shape< dimension > &shape)
resize the container to given shape, content is NOT preserved
Definition: tensor_container.h:81
Stream< Device > * stream_
stream where the computation lies stream is a device dependency concept where each computation ...
Definition: tensor.h:428
computaion stream structure, used for asynchronous computations
Definition: tensor.h:365