mxnet
mirror.h
Go to the documentation of this file.
1 
7 #ifndef MSHADOW_EXTENSION_MIRROR_H_
8 #define MSHADOW_EXTENSION_MIRROR_H_
9 #include "../extension.h"
10 namespace mshadow {
11 namespace expr {
18 template<typename SrcExp, typename DType, int srcdim>
19 struct MirroringExp:
20  public MakeTensorExp<MirroringExp<SrcExp, DType, srcdim>,
21  SrcExp, srcdim, DType> {
23  const SrcExp &src_;
25  explicit MirroringExp(const SrcExp &src) : src_(src) {
27  }
28 };
37 template<typename SrcExp, typename DType, int etype>
41  ::Error_Expression_Does_Not_Meet_Dimension_Req();
43 }
44 //----------------------
45 // Execution plan
46 //----------------------
47 template<typename SrcExp, typename DType, int srcdim>
48 struct Plan<MirroringExp<SrcExp, DType, srcdim>, DType> {
49  public:
51  : src_(MakePlan(e.src_)), width_(e.shape_[srcdim - 1]) {}
52  MSHADOW_XINLINE DType Eval(index_t i, index_t j) const {
53  return src_.Eval(i, width_ - j - 1);
54  }
55 
56  private:
58  const index_t width_;
59 };
60 } // namespace expr
61 } // namespace mshadow
62 #endif // MSHADOW_EXTENSION_MIRROR_H_
MirroringExp(const SrcExp &src)
constructor
Definition: mirror.h:25
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: mirror.h:52
Definition: expr_engine-inl.h:40
used to help static type check
Definition: expr_engine-inl.h:312
MirroringExp< SrcExp, DType, ExpInfo< SrcExp >::kDim > mirror(const Exp< SrcExp, DType, etype > &src)
mirroring expression, mirror images in width
Definition: mirror.h:39
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:204
int32_t index_t
type that will be used for index
Definition: base.h:291
mirror expression, mirror a image in width
Definition: mirror.h:19
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
const SrcExp & src_
source operand
Definition: mirror.h:23
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
Plan(const MirroringExp< SrcExp, DType, srcdim > &e)
Definition: mirror.h:50
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:29