Go to the documentation of this file.
25 #ifndef MSHADOW_EXTENSION_MASK_H_
26 #define MSHADOW_EXTENSION_MASK_H_
28 #include "../extension.h"
38 template<
typename IndexExp,
typename SrcExp,
typename DType>
39 struct MaskExp:
public Exp<MaskExp<IndexExp, SrcExp, DType>,
40 DType, type::kChainer> {
46 MaskExp(
const IndexExp &index,
const SrcExp &src)
52 template<
typename IndexExp,
56 inline MaskExp<IndexExp, SrcExp, DType>
67 template<
typename IndexExp,
typename SrcExp,
typename DType>
75 return static_cast<DType
>(src_.Eval(y, x) * index_.Eval(0, y));
83 template<
typename IndexExp,
typename SrcExp,
typename DType>
84 inline Plan<MaskExp<IndexExp, SrcExp, DType>, DType>
89 template<
int dim,
typename IndexExp,
typename SrcExp,
typename DType>
94 <<
"MaskExp only support 2D output";
97 CHECK_EQ(dshape[0], wshape[0]) <<
"MaskExp require inputs in same first dimention";
106 template<
typename IndexExp,
typename SrcExp,
typename DType>
115 #endif // MSHADOW_EXTENSION_MASK_H_
static const int kDevMask
Definition: expr_engine-inl.h:264
const SubType & self(void) const
Definition: expression.h:82
#define MSHADOW_XINLINE
Definition: base.h:228
runtime shape checking template get the shape of an expression, report error if shape mismatch
Definition: expr_engine-inl.h:364
Plan(const MaskExp< IndexExp, SrcExp, DType > &e)
Definition: mask.h:70
const IndexExp & index_
index oprand
Definition: mask.h:42
static Shape< dim > Check(const E &t)
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:262
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
MaskExp< IndexExp, SrcExp, DType > mask(const Exp< IndexExp, DType, e1 > &index, const Exp< SrcExp, DType, e2 > &src)
Definition: mask.h:57
Broadcast a mask and do element-wise multiplication.
Definition: mask.h:39
static const int kDim
Definition: expr_engine-inl.h:263
int32_t index_t
type that will be used for index
Definition: base.h:328
Definition: expr_engine-inl.h:58
static Shape< dim > Check(const MaskExp< IndexExp, SrcExp, DType > &t)
Definition: mask.h:92
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
overloaded + operator between half_t and bf16_t
Definition: base.h:319
const SrcExp & src_
matrix oprand
Definition: mask.h:44
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: mask.h:74
MaskExp(const IndexExp &index, const SrcExp &src)
Definition: mask.h:46