26 #ifndef MSHADOW_EXTENSION_MASK_H_ 27 #define MSHADOW_EXTENSION_MASK_H_ 29 #include "../extension.h" 39 template<
typename IndexExp,
typename SrcExp,
typename DType>
40 struct MaskExp:
public Exp<MaskExp<IndexExp, SrcExp, DType>,
41 DType, type::kChainer> {
47 MaskExp(
const IndexExp &index,
const SrcExp &src)
48 : index_(index), src_(src) {}
53 template<
typename IndexExp,
68 template<
typename IndexExp,
typename SrcExp,
typename DType>
76 return static_cast<DType
>(
src_.Eval(y, x) *
index_.Eval(0, y));
84 template<
typename IndexExp,
typename SrcExp,
typename DType>
90 template<
int dim,
typename IndexExp,
typename SrcExp,
typename DType>
95 <<
"MaskExp only support 2D output";
98 CHECK_EQ(dshape[0], wshape[0]) <<
"MaskExp require inputs in same first dimention";
107 template<
typename IndexExp,
typename SrcExp,
typename DType>
109 static const int kDim = 2;
116 #endif // MSHADOW_EXTENSION_MASK_H_ MaskExp(const IndexExp &index, const SrcExp &src)
Definition: mask.h:47
Definition: expr_engine-inl.h:59
const SrcExp & src_
matrix oprand
Definition: mask.h:45
static Shape< dim > Check(const MaskExp< IndexExp, SrcExp, DType > &t)
Definition: mask.h:93
const IndexExp & index_
index oprand
Definition: mask.h:43
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
MaskExp< IndexExp, SrcExp, DType > mask(const Exp< IndexExp, DType, e1 > &index, const Exp< SrcExp, DType, e2 > &src)
Definition: mask.h:58
Plan(const MaskExp< IndexExp, SrcExp, DType > &e)
Definition: mask.h:71
int32_t index_t
type that will be used for index
Definition: base.h:336
Broadcast a mask and do element-wise multiplication.
Definition: mask.h:40
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
overloaded + operator between half_t and bf16_t
Definition: base.h:327
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: mask.h:75