Go to the documentation of this file.
25 #ifndef MSHADOW_EXTENSION_FLIP_H_
26 #define MSHADOW_EXTENSION_FLIP_H_
28 #include "../extension.h"
39 template<
typename SrcExp,
typename Device,
40 typename DType,
int srcdim>
44 Device, srcdim, DType> {
56 for (
int i = dim + 1; i < srcdim; ++i) {
60 template<
typename E,
int etype>
82 template<
typename SrcExp,
typename Device,
83 typename DType,
int srcdim>
84 inline FlipExp<SrcExp, Device, DType, srcdim>
92 template<
typename SrcExp,
typename Device,
93 typename DType,
int srcdim>
96 Device, DType, srcdim> &t) {
100 template<
typename SrcExp,
typename Device,
101 typename DType,
int srcdim>
109 template<
typename SrcExp,
typename Device,
110 typename DType,
int srcdim>
118 template<
typename SrcExp,
typename Device,
119 typename DType,
int srcdim>
123 : src_(
MakePlan(e.src_)), stride_j_(e.stride_j_),
124 trailing_(e.trailing_), stride_(e.stride_) {}
127 const index_t low = idx%trailing_;
129 const index_t x = high%stride_;
131 idx = (high*stride_+stride_-1-x)*trailing_+low;
132 return src_.Eval(idx/stride_j_, idx%stride_j_);
136 const index_t low = idx%trailing_;
138 const index_t x = high%stride_;
140 idx = (high*stride_+stride_-1-x)*trailing_+low;
141 return src_.REval(idx/stride_j_, idx%stride_j_);
146 const index_t stride_j_, trailing_, stride_;
150 #endif // MSHADOW_EXTENSION_FLIP_H_
static const int kDevMask
Definition: expr_engine-inl.h:264
const Container & self(void) const
Definition: expression.h:82
computaion stream structure, used for asynchronous computations
Definition: tensor.h:488
index_t trailing_
Definition: flip.h:46
Tensor RValue, this is the super type of all kinds of possible tensors.
Definition: tensor.h:514
static Stream< Device > * Get(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:228
runtime shape checking template get the shape of an expression, report error if shape mismatch
Definition: expr_engine-inl.h:364
Definition: expr_engine-inl.h:345
Plan(const FlipExp< SrcExp, Device, DType, srcdim > &e)
Definition: flip.h:122
static Shape< dim > Check(const E &t)
static Stream< Device > * Get(const FlipExp< SrcExp, Device, DType, srcdim > &t)
Definition: flip.h:104
void operator=(const expr::Exp< E, DType, etype > &exp)
Definition: flip.h:62
FlipExp(const SrcExp &src, int dim)
Definition: flip.h:50
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:262
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
index_t shape_[kDimension]
storing the dimension information
Definition: tensor.h:86
FlipExp< SrcExp, Device, DType, srcdim > flip(const TRValue< SrcExp, Device, srcdim, DType > &src, int dim)
Flip a Tensor.
Definition: flip.h:85
const SrcExp & src_
Definition: flip.h:45
static const int kDim
Definition: expr_engine-inl.h:263
static Shape< srcdim > Check(const FlipExp< SrcExp, Device, DType, srcdim > &t)
Definition: flip.h:95
int32_t index_t
type that will be used for index
Definition: base.h:328
Definition: expr_engine-inl.h:58
slice expression, slice a tensor's channel
Definition: flip.h:41
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
index_t stride_j_
Definition: flip.h:48
void operator=(const DType &exp)
Definition: flip.h:66
overloaded + operator between half_t and bf16_t
Definition: base.h:319
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: flip.h:125
Shape< srcdim > shape_
Definition: flip.h:49
index_t stride_
Definition: flip.h:47
FlipExp< SrcExp, Device, DType, srcdim > & __assign(DType s)
operator overload
Definition: expression.h:178
MSHADOW_XINLINE DType & REval(index_t i, index_t j) const
Definition: flip.h:134