7 #ifndef MSHADOW_EXTENSION_CHOOSE_H_ 8 #define MSHADOW_EXTENSION_CHOOSE_H_ 10 #include "../extension.h" 20 template<
typename SrcExp,
typename IndexExp,
typename DType>
22 public Exp<MatChooseRowElementExp<SrcExp, IndexExp, DType>,
23 DType, type::kChainer> {
30 : src_(src), index_(index) {}
33 template<
typename SrcExp,
typename IndexExp,
34 typename DType,
typename IDType,
int e1,
int e2>
39 ::Error_Expression_Does_Not_Meet_Dimension_Req();
46 template<
typename SrcExp,
typename IndexExp,
typename DType>
55 return src_.Eval(x, idx);
63 template<
typename SrcExp,
typename IndexExp,
typename DType>
69 template<
int dim,
typename SrcExp,
typename IndexExp,
typename DType>
74 <<
"MatChooseRowElementExp only support 1 dimension output";
77 CHECK_EQ(shape1[0], shape2[0])
78 <<
"mat_choose_row_element index length and number of rows in matrix";
83 template<
typename SrcExp,
typename IndexExp,
typename DType>
85 static const int kDim = 1;
90 #endif // MSHADOW_EXTENSION_CHOOSE_H_ Make a choice of index in the lowest changing dimension.
Definition: choose.h:21
Definition: expr_engine-inl.h:40
used to help static type check
Definition: expr_engine-inl.h:312
const IndexExp & index_
index operand
Definition: choose.h:27
static Shape< dim > Check(const E &t)
#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
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: choose.h:53
const SrcExp & src_
source operand
Definition: choose.h:25
int32_t index_t
type that will be used for index
Definition: base.h:291
static Shape< dim > Check(const MatChooseRowElementExp< SrcExp, IndexExp, DType > &t)
Definition: choose.h:72
MatChooseRowElementExp< SrcExp, IndexExp, DType > mat_choose_row_element(const Exp< SrcExp, DType, e1 > &src, const Exp< IndexExp, IDType, e2 > &index)
Definition: choose.h:36
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
MatChooseRowElementExp(const SrcExp &src, const IndexExp &index)
constructor
Definition: choose.h:29
namespace for mshadow
Definition: base.h:282
Plan(const MatChooseRowElementExp< SrcExp, IndexExp, DType > &e)
Definition: choose.h:49