25 #ifndef MSHADOW_EXTENSION_TAKE_H_ 26 #define MSHADOW_EXTENSION_TAKE_H_ 28 #include "../extension.h" 38 template<
typename IndexExp,
typename SrcExp,
typename DType>
39 struct TakeExp:
public Exp<TakeExp<IndexExp, SrcExp, DType>,
40 DType, type::kChainer> {
46 TakeExp(
const IndexExp &index,
const SrcExp &src)
47 : index_(index), src_(src) {}
52 template<
typename IndexExp,
67 template<
typename IndexExp,
typename SrcExp,
typename DType>
78 return static_cast<DType
>(
src_.Eval(idx, x));
86 template<
typename IndexExp,
typename SrcExp,
typename DType>
92 template<
int dim,
typename IndexExp,
typename SrcExp,
typename DType>
97 <<
"TakeExp only support 2D output";
108 template<
typename IndexExp,
typename SrcExp,
typename DType>
110 static const int kDim = 2;
117 #endif // MSHADOW_EXTENSION_TAKE_H_ static Shape< dim > Check(const TakeExp< IndexExp, SrcExp, DType > &t)
Definition: take.h:95
const SubType & self(void) const
Definition: expression.h:82
Definition: expr_engine-inl.h:58
TakeExp< IndexExp, SrcExp, DType > take(const Exp< IndexExp, DType, e1 > &index, const Exp< SrcExp, DType, e2 > &src)
Definition: take.h:57
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: take.h:76
static Shape< dim > Check(const E &t)
TakeExp(const IndexExp &index, const SrcExp &src)
Definition: take.h:46
#define MSHADOW_XINLINE
Definition: base.h:230
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:262
int32_t index_t
type that will be used for index
Definition: base.h:343
Take a column from a matrix.
Definition: take.h:39
Plan(const TakeExp< IndexExp, SrcExp, DType > &e)
Definition: take.h:70
runtime shape checking template get the shape of an expression, report error if shape mismatch ...
Definition: expr_engine-inl.h:364
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
overloaded + operator between half_t and bf16_t
Definition: base.h:334
const IndexExp & index_
index oprand
Definition: take.h:42
const SrcExp & src_
embediing oprand
Definition: take.h:44