Go to the documentation of this file.
25 #ifndef MSHADOW_EXTENSION_RESHAPE_H_
26 #define MSHADOW_EXTENSION_RESHAPE_H_
27 #include "../extension.h"
38 template<
typename SrcExp,
typename DType,
int dimdst,
int dimsrc>
40 public MakeTensorExp<ReshapeExp<SrcExp, DType, dimdst, dimsrc>,
41 SrcExp, dimdst, DType> {
50 CHECK_EQ(ishape.
Size(), shape.
Size()) <<
"reshape size must match";
64 template<
typename SrcExp,
typename DType,
int etype,
int dimdst>
65 inline ReshapeExp<SrcExp, DType, dimdst, ExpInfo<SrcExp>::kDim>
73 template<
typename SrcExp,
typename DType,
int dimdst,
int dimsrc>
78 oshapex_(e.shape_[dimdst - 1]), ishapex_(e.ishapex_) {}
80 const index_t idx = y * oshapex_ + x;
81 return src_.Eval(idx / ishapex_, idx % ishapex_);
86 const index_t oshapex_, ishapex_;
89 template<
typename SrcExp,
typename DType,
int dimdst>
93 : src_(
MakePlan(e.src_)), oshapex_(e.shape_[dimdst - 1]) {
96 return src_.Eval(0, y * oshapex_ + x);
105 #endif // MSHADOW_EXTENSION_RESHAPE_H_
MSHADOW_XINLINE index_t Size(void) const
Definition: tensor.h:158
const SubType & self(void) const
Definition: expression.h:82
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:79
Plan(const ReshapeExp< SrcExp, DType, dimdst, dimsrc > &e)
Definition: reshape.h:76
#define MSHADOW_XINLINE
Definition: base.h:228
const SrcExp & src_
source expression
Definition: reshape.h:43
Plan(const ReshapeExp< SrcExp, DType, dimdst, 1 > &e)
Definition: reshape.h:92
ReshapeExp(const SrcExp &src, Shape< dimdst > shape)
constructor
Definition: reshape.h:47
static Shape< dim > Check(const E &t)
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:47
ReshapeExp< SrcExp, DType, dimdst, ExpInfo< SrcExp >::kDim > reshape(const Exp< SrcExp, DType, etype > &src, Shape< dimdst > oshape)
a expression that reshapes a tensor to another shape
Definition: reshape.h:66
reshape the content to another shape input: Tensor<Device,dimsrc>: ishape output: Tensor<Device,...
Definition: reshape.h:39
int32_t index_t
type that will be used for index
Definition: base.h:328
Definition: expr_engine-inl.h:58
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:95
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:319
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:43
shape of a tensor
Definition: tensor.h:64
index_t ishapex_
smallest dimension of input
Definition: reshape.h:45