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";
51 ishapex_ = ishape[dimsrc - 1];
64 template<
typename SrcExp,
typename DType,
int etype,
int dimdst>
73 template<
typename SrcExp,
typename DType,
int dimdst,
int dimsrc>
80 const index_t idx = y * oshapex_ + x;
89 template<
typename SrcExp,
typename DType,
int dimdst>
96 return src_.Eval(0, y * oshapex_ + x);
105 #endif // MSHADOW_EXTENSION_RESHAPE_H_ const SubType & self(void) const
Definition: expression.h:82
Definition: expr_engine-inl.h:58
shape of a tensor
Definition: tensor.h:53
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:95
Plan(const ReshapeExp< SrcExp, DType, dimdst, dimsrc > &e)
Definition: reshape.h:76
Plan(const ReshapeExp< SrcExp, DType, dimdst, 1 > &e)
Definition: reshape.h:92
static Shape< dim > Check(const E &t)
const SrcExp & src_
source expression
Definition: reshape.h:43
#define MSHADOW_XINLINE
Definition: base.h:230
index_t ishapex_
smallest dimension of input
Definition: reshape.h:45
int32_t index_t
type that will be used for index
Definition: base.h:343
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
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:79
reshape the content to another shape input: Tensor<Device,dimsrc>: ishape output: Tensor<Device...
Definition: reshape.h:39
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
ReshapeExp(const SrcExp &src, Shape< dimdst > shape)
constructor
Definition: reshape.h:47
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:43
overloaded + operator between half_t and bf16_t
Definition: base.h:334
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:47
MSHADOW_XINLINE index_t Size(void) const
Definition: tensor.h:144