25 #ifndef MSHADOW_TENSOR_CONTAINER_H_ 26 #define MSHADOW_TENSOR_CONTAINER_H_ 39 template<
typename Device,
int dimension,
typename DType = default_real_t>
61 this->AllocByShape(shape);
71 this->AllocByShape(shape);
87 if (src.
dptr_ != NULL) {
88 this->AllocByShape(src.
shape_);
102 this->AllocByShape(shape);
130 template<
typename TStream>
139 template<
typename TStream>
145 Copy(*
this, tmp, &stream);
155 this->pad_ = src.pad_;
157 if (src.
dptr_ != NULL) {
191 if (data_.
dptr_ != NULL) {
195 this->data_.
shape_[0] = 0;
198 }
catch (
const dmlc::Error &e) {
226 #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:140
void Resize(const Shape< dimension > &shape, DType initv)
resize the container to given shape, and initialize, content is NOT preserved
Definition: tensor_container.h:117
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:71
Tensor< Device, dimension, DType > & operator=(const expr::Exp< E, DType, expr::type::kComplex > &exp)
functions to fit expression template
Definition: tensor_container.h:182
DType * dptr_
pointer to the data
Definition: tensor.h:434
TensorContainer(const Shape< dimension > &shape, DType initv)
constructor
Definition: tensor_container.h:68
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:125
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:145
shape of a tensor
Definition: tensor.h:53
void set_pad(bool pad)
set whether padding is allowed in tensor
Definition: tensor_container.h:122
Shape< dimension > shape_
shape of the tensor
Definition: tensor.h:436
TensorContainer(bool pad=MSHADOW_ALLOC_PAD)
constructor
Definition: tensor_container.h:46
Tensor< Device, dimension, DType > & operator=(const expr::Exp< E, DType, expr::type::kChainer > &exp)
functions to fit expression template
Definition: tensor_container.h:176
void Release(void)
Release the llocated space, The TensorContainer is still functionable, but will restart allocating sp...
Definition: tensor_container.h:190
void SaveBinary(TStream &fo) const
save by binary format
Definition: tensor_container.h:131
header file of tensor data structure and functions This lib requires explicit memory allocation and d...
#define MSHADOW_ALLOC_PAD
whether do padding during allocation
Definition: base.h:72
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:116
MSHADOW_XINLINE Shape< 2 > FlatTo2D(void) const
Definition: tensor.h:132
TensorContainer(const Shape< dimension > &shape)
constructor
Definition: tensor_container.h:58
Tensor< Device, dimension, DType > & operator=(DType s)
functions to fit expression template
Definition: tensor_container.h:164
tensor container that does memory allocation and resize like STL, use it to save the lines of FreeSpa...
Definition: tensor_container.h:40
MSHADOW_XINLINE index_t size(int idx) const
return size of i-th dimension, start counting from highest dimension
Definition: tensor.h:505
index_t shape_[kDimension]
storing the dimension information
Definition: tensor.h:75
~TensorContainer(void) MSHADOW_THROW_EXCEPTION
Definition: tensor_container.h:92
void LoadBinary(TStream &fi)
load by binary format, a temp Tensor<cpu,dim> storage will be allocated
Definition: tensor_container.h:140
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
overloaded + operator between half_t and bf16_t
Definition: base.h:334
#define MSHADOW_THROW_EXCEPTION
Definition: base.h:260
Tensor< Device, dimension, DType > & operator=(const expr::Exp< E, DType, expr::type::kMapper > &exp)
functions to fit expression template
Definition: tensor_container.h:170
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:107
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:441
Tensor< Device, dimension, DType > & __assign(DType s)
operator overload
Definition: expression.h:178
general tensor
Definition: tensor.h:420
void Resize(const Shape< dimension > &shape)
resize the container to given shape, content is NOT preserved
Definition: tensor_container.h:99
Stream< Device > * stream_
stream where the computation lies stream is a device dependency concept where each computation ...
Definition: tensor.h:446
computaion stream structure, used for asynchronous computations
Definition: tensor.h:383