26 #ifndef MSHADOW_EXTENSION_RESHAPE_H_ 27 #define MSHADOW_EXTENSION_RESHAPE_H_ 28 #include "../extension.h" 39 template<
typename SrcExp,
typename DType,
int dimdst,
int dimsrc>
41 public MakeTensorExp<ReshapeExp<SrcExp, DType, dimdst, dimsrc>,
42 SrcExp, dimdst, DType> {
51 CHECK_EQ(ishape.
Size(), shape.
Size()) <<
"reshape size must match";
52 ishapex_ = ishape[dimsrc - 1];
65 template<
typename SrcExp,
typename DType,
int etype,
int dimdst>
74 template<
typename SrcExp,
typename DType,
int dimdst,
int dimsrc>
81 const index_t idx = y * oshapex_ + x;
90 template<
typename SrcExp,
typename DType,
int dimdst>
97 return src_.Eval(0, y * oshapex_ + x);
106 #endif // MSHADOW_EXTENSION_RESHAPE_H_ MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:80
MSHADOW_XINLINE index_t Size(void) const
Definition: tensor.h:145
Definition: expr_engine-inl.h:59
shape of a tensor
Definition: tensor.h:54
Plan(const ReshapeExp< SrcExp, DType, dimdst, dimsrc > &e)
Definition: reshape.h:77
Plan(const ReshapeExp< SrcExp, DType, dimdst, 1 > &e)
Definition: reshape.h:93
static Shape< dim > Check(const E &t)
const SrcExp & src_
source expression
Definition: reshape.h:44
#define MSHADOW_XINLINE
Definition: base.h:223
index_t ishapex_
smallest dimension of input
Definition: reshape.h:46
int32_t index_t
type that will be used for index
Definition: base.h:336
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:67
reshape the content to another shape input: Tensor<Device,dimsrc>: ishape output: Tensor<Device...
Definition: reshape.h:40
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:80
const SubType & self(void) const
Definition: expression.h:83
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:240
ReshapeExp(const SrcExp &src, Shape< dimdst > shape)
constructor
Definition: reshape.h:48
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:44
overloaded + operator between half_t and bf16_t
Definition: base.h:327
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:96
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:48