7 #ifndef MSHADOW_EXTENSION_TAKE_H_ 8 #define MSHADOW_EXTENSION_TAKE_H_ 10 #include "../extension.h" 20 template<
typename IndexExp,
typename SrcExp,
typename DType>
21 struct TakeExp:
public Exp<TakeExp<IndexExp, SrcExp, DType>,
22 DType, type::kChainer> {
28 TakeExp(
const IndexExp &index,
const SrcExp &src)
29 : index_(index), src_(src) {}
34 template<
typename IndexExp,
49 template<
typename IndexExp,
typename SrcExp,
typename DType>
60 return static_cast<DType
>(
src_.Eval(idx, x));
68 template<
typename IndexExp,
typename SrcExp,
typename DType>
74 template<
int dim,
typename IndexExp,
typename SrcExp,
typename DType>
79 <<
"TakeExp only support 2D output";
90 template<
typename IndexExp,
typename SrcExp,
typename DType>
92 static const int kDim = 2;
99 #endif // MSHADOW_EXTENSION_TAKE_H_ static Shape< dim > Check(const TakeExp< IndexExp, SrcExp, DType > &t)
Definition: take.h:77
Definition: expr_engine-inl.h:40
TakeExp< IndexExp, SrcExp, DType > take(const Exp< IndexExp, DType, e1 > &index, const Exp< SrcExp, DType, e2 > &src)
Definition: take.h:39
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: take.h:58
static Shape< dim > Check(const E &t)
TakeExp(const IndexExp &index, const SrcExp &src)
Definition: take.h:28
#define MSHADOW_XINLINE
Definition: base.h:204
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:244
int32_t index_t
type that will be used for index
Definition: base.h:291
Take a column from a matrix.
Definition: take.h:21
Plan(const TakeExp< IndexExp, SrcExp, DType > &e)
Definition: take.h:52
runtime shape checking template get the shape of an expression, report error if shape mismatch ...
Definition: expr_engine-inl.h:346
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
namespace for mshadow
Definition: base.h:282
const IndexExp & index_
index oprand
Definition: take.h:24
const SrcExp & src_
embediing oprand
Definition: take.h:26