26 #ifndef MSHADOW_EXTENSION_ONE_HOT_H_ 27 #define MSHADOW_EXTENSION_ONE_HOT_H_ 29 #include "../extension.h" 39 template<
typename IndexExp,
typename DType>
41 public Exp<OneHotEncodeExp<IndexExp, DType>,
42 DType, type::kChainer> {
49 : index_(index), num_choices_(num_choices) {}
52 template<
typename IndexExp,
53 typename IDType,
int e1>
57 ::Error_Expression_Does_Not_Meet_Dimension_Req();
64 template<
typename IndexExp,
typename DType>
72 return static_cast<DType
>(x == idx);
79 template<
typename IndexExp,
typename DType>
85 template<
int dim,
typename IndexExp,
typename DType>
90 <<
"OneHotEncodeExp only support 2 dimension output";
99 template<
typename IndexExp,
typename DType>
101 static const int kDim = 2;
106 #endif // MSHADOW_EXTENSION_ONE_HOT_H_ index_t num_choices_
number of choices we can have.
Definition: one_hot.h:46
Definition: expr_engine-inl.h:59
used to help static type check
Definition: expr_engine-inl.h:331
static Shape< dim > Check(const OneHotEncodeExp< IndexExp, DType > &t)
Definition: one_hot.h:88
Create a one-hot indicator array.
Definition: one_hot.h:40
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
int32_t index_t
type that will be used for index
Definition: base.h:336
runtime shape checking template get the shape of an expression, report error if shape mismatch ...
Definition: expr_engine-inl.h:365
OneHotEncodeExp(const IndexExp &index, index_t num_choices)
constructor
Definition: one_hot.h:48
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
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: one_hot.h:70
const IndexExp & index_
index operand
Definition: one_hot.h:44
overloaded + operator between half_t and bf16_t
Definition: base.h:327
Plan(const OneHotEncodeExp< IndexExp, DType > &e)
Definition: one_hot.h:67
OneHotEncodeExp< IndexExp, default_real_t > one_hot_encode(const Exp< IndexExp, IDType, e1 > &index, index_t num_choices)
Definition: one_hot.h:55