26 #ifndef MSHADOW_EXTENSION_CHOOSE_H_ 27 #define MSHADOW_EXTENSION_CHOOSE_H_ 29 #include "../extension.h" 39 template<
typename SrcExp,
typename IndexExp,
typename DType>
41 public Exp<MatChooseRowElementExp<SrcExp, IndexExp, DType>,
42 DType, type::kChainer> {
49 : src_(src), index_(index) {}
52 template<
typename SrcExp,
typename IndexExp,
53 typename DType,
typename IDType,
int e1,
int e2>
58 ::Error_Expression_Does_Not_Meet_Dimension_Req();
65 template<
typename SrcExp,
typename IndexExp,
typename DType>
74 return src_.Eval(x, idx);
82 template<
typename SrcExp,
typename IndexExp,
typename DType>
88 template<
int dim,
typename SrcExp,
typename IndexExp,
typename DType>
93 <<
"MatChooseRowElementExp only support 1 dimension output";
96 CHECK_EQ(shape1[0], shape2[0])
97 <<
"mat_choose_row_element index length and number of rows in matrix";
102 template<
typename SrcExp,
typename IndexExp,
typename DType>
104 static const int kDim = 1;
109 #endif // MSHADOW_EXTENSION_CHOOSE_H_ Make a choice of index in the lowest changing dimension.
Definition: choose.h:40
Definition: expr_engine-inl.h:59
used to help static type check
Definition: expr_engine-inl.h:331
const IndexExp & index_
index operand
Definition: choose.h:46
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:223
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:263
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: choose.h:72
const SrcExp & src_
source operand
Definition: choose.h:44
int32_t index_t
type that will be used for index
Definition: base.h:336
static Shape< dim > Check(const MatChooseRowElementExp< SrcExp, IndexExp, DType > &t)
Definition: choose.h:91
MatChooseRowElementExp< SrcExp, IndexExp, DType > mat_choose_row_element(const Exp< SrcExp, DType, e1 > &src, const Exp< IndexExp, IDType, e2 > &index)
Definition: choose.h:55
runtime shape checking template get the shape of an expression, report error if shape mismatch ...
Definition: expr_engine-inl.h:365
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:80
const SubType & self(void) const
Definition: expression.h:83
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:240
MatChooseRowElementExp(const SrcExp &src, const IndexExp &index)
constructor
Definition: choose.h:48
overloaded + operator between half_t and bf16_t
Definition: base.h:327
Plan(const MatChooseRowElementExp< SrcExp, IndexExp, DType > &e)
Definition: choose.h:68