25 #ifndef MSHADOW_EXTENSION_CHOOSE_H_ 26 #define MSHADOW_EXTENSION_CHOOSE_H_ 28 #include "../extension.h" 38 template<
typename SrcExp,
typename IndexExp,
typename DType>
40 public Exp<MatChooseRowElementExp<SrcExp, IndexExp, DType>,
41 DType, type::kChainer> {
48 : src_(src), index_(index) {}
51 template<
typename SrcExp,
typename IndexExp,
52 typename DType,
typename IDType,
int e1,
int e2>
57 ::Error_Expression_Does_Not_Meet_Dimension_Req();
64 template<
typename SrcExp,
typename IndexExp,
typename DType>
73 return src_.Eval(x, idx);
81 template<
typename SrcExp,
typename IndexExp,
typename DType>
87 template<
int dim,
typename SrcExp,
typename IndexExp,
typename DType>
92 <<
"MatChooseRowElementExp only support 1 dimension output";
95 CHECK_EQ(shape1[0], shape2[0])
96 <<
"mat_choose_row_element index length and number of rows in matrix";
101 template<
typename SrcExp,
typename IndexExp,
typename DType>
103 static const int kDim = 1;
108 #endif // MSHADOW_EXTENSION_CHOOSE_H_ Make a choice of index in the lowest changing dimension.
Definition: choose.h:39
const SubType & self(void) const
Definition: expression.h:82
Definition: expr_engine-inl.h:58
used to help static type check
Definition: expr_engine-inl.h:330
const IndexExp & index_
index operand
Definition: choose.h:45
static Shape< dim > Check(const E &t)
#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
const SrcExp & src_
source operand
Definition: choose.h:43
int32_t index_t
type that will be used for index
Definition: base.h:343
static Shape< dim > Check(const MatChooseRowElementExp< SrcExp, IndexExp, DType > &t)
Definition: choose.h:90
MatChooseRowElementExp< SrcExp, IndexExp, DType > mat_choose_row_element(const Exp< SrcExp, DType, e1 > &src, const Exp< IndexExp, IDType, e2 > &index)
Definition: choose.h:54
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
MatChooseRowElementExp(const SrcExp &src, const IndexExp &index)
constructor
Definition: choose.h:47
overloaded + operator between half_t and bf16_t
Definition: base.h:334
Plan(const MatChooseRowElementExp< SrcExp, IndexExp, DType > &e)
Definition: choose.h:67
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: choose.h:71