7 #ifndef MSHADOW_EXTENSION_RESHAPE_H_ 8 #define MSHADOW_EXTENSION_RESHAPE_H_ 9 #include "../extension.h" 20 template<
typename SrcExp,
typename DType,
int dimdst,
int dimsrc>
22 public MakeTensorExp<ReshapeExp<SrcExp, DType, dimdst, dimsrc>,
23 SrcExp, dimdst, DType> {
32 CHECK_EQ(ishape.
Size(), shape.
Size()) <<
"reshape size must match";
33 ishapex_ = ishape[dimsrc - 1];
46 template<
typename SrcExp,
typename DType,
int etype,
int dimdst>
55 template<
typename SrcExp,
typename DType,
int dimdst,
int dimsrc>
62 const index_t idx = y * oshapex_ + x;
71 template<
typename SrcExp,
typename DType,
int dimdst>
78 return src_.Eval(0, y * oshapex_ + x);
87 #endif // MSHADOW_EXTENSION_RESHAPE_H_ MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:61
MSHADOW_XINLINE index_t Size(void) const
Definition: tensor.h:126
Definition: expr_engine-inl.h:40
shape of a tensor
Definition: tensor.h:35
Plan(const ReshapeExp< SrcExp, DType, dimdst, dimsrc > &e)
Definition: reshape.h:58
Plan(const ReshapeExp< SrcExp, DType, dimdst, 1 > &e)
Definition: reshape.h:74
static Shape< dim > Check(const E &t)
const SrcExp & src_
source expression
Definition: reshape.h:25
#define MSHADOW_XINLINE
Definition: base.h:204
index_t ishapex_
smallest dimension of input
Definition: reshape.h:27
int32_t index_t
type that will be used for index
Definition: base.h:291
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:48
reshape the content to another shape input: Tensor<Device,dimsrc>: ishape output: Tensor<Device...
Definition: reshape.h:21
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:61
const SubType & self(void) const
Definition: expression.h:64
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:221
ReshapeExp(const SrcExp &src, Shape< dimdst > shape)
constructor
Definition: reshape.h:29
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:25
namespace for mshadow
Definition: base.h:282
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: reshape.h:77
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:29