Go to the documentation of this file.
25 #ifndef MSHADOW_EXTENSION_ONE_HOT_H_
26 #define MSHADOW_EXTENSION_ONE_HOT_H_
28 #include "../extension.h"
38 template<
typename IndexExp,
typename DType>
40 public Exp<OneHotEncodeExp<IndexExp, DType>,
41 DType, type::kChainer> {
51 template<
typename IndexExp,
52 typename IDType,
int e1>
53 inline OneHotEncodeExp<IndexExp, default_real_t>
56 ::Error_Expression_Does_Not_Meet_Dimension_Req();
63 template<
typename IndexExp,
typename DType>
71 return static_cast<DType
>(x == idx);
78 template<
typename IndexExp,
typename DType>
79 inline Plan<OneHotEncodeExp<IndexExp, DType>, DType>
84 template<
int dim,
typename IndexExp,
typename DType>
89 <<
"OneHotEncodeExp only support 2 dimension output";
98 template<
typename IndexExp,
typename DType>
105 #endif // MSHADOW_EXTENSION_ONE_HOT_H_
static const int kDevMask
Definition: expr_engine-inl.h:264
const SubType & self(void) const
Definition: expression.h:82
OneHotEncodeExp(const IndexExp &index, index_t num_choices)
constructor
Definition: one_hot.h:47
used to help static type check
Definition: expr_engine-inl.h:330
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: one_hot.h:69
#define MSHADOW_XINLINE
Definition: base.h:228
OneHotEncodeExp< IndexExp, default_real_t > one_hot_encode(const Exp< IndexExp, IDType, e1 > &index, index_t num_choices)
Definition: one_hot.h:54
runtime shape checking template get the shape of an expression, report error if shape mismatch
Definition: expr_engine-inl.h:364
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
static const int kDim
Definition: expr_engine-inl.h:263
const IndexExp & index_
index operand
Definition: one_hot.h:43
int32_t index_t
type that will be used for index
Definition: base.h:328
Definition: expr_engine-inl.h:58
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
static Shape< dim > Check(const OneHotEncodeExp< IndexExp, DType > &t)
Definition: one_hot.h:87
Plan(const OneHotEncodeExp< IndexExp, DType > &e)
Definition: one_hot.h:66
Create a one-hot indicator array.
Definition: one_hot.h:39
index_t num_choices_
number of choices we can have.
Definition: one_hot.h:45