Go to the documentation of this file.
24 #ifndef MSHADOW_EXTENSION_SLICE_EX_H_
25 #define MSHADOW_EXTENSION_SLICE_EX_H_
27 #include "../extension.h"
38 template<
typename SrcExp,
typename Device,
39 typename DType,
int srcdim>
43 Device, srcdim, DType> {
52 for (
int i = 0; i < srcdim; ++i) {
56 template<
typename E,
int etype>
78 template<
typename SrcExp,
typename Device,
79 typename DType,
int srcdim>
80 inline SliceExExp<SrcExp, Device, DType, srcdim>
83 ::Error_Expression_Does_Not_Meet_Dimension_Req();
90 template<
typename SrcExp,
typename Device,
91 typename DType,
int srcdim>
94 Device, DType, srcdim> &t) {
99 template<
typename SrcExp,
typename Device,
100 typename DType,
int srcdim>
108 template<
typename SrcExp,
typename Device,
109 typename DType,
int srcdim>
117 template<
typename SrcExp,
typename Device,
118 typename DType,
int srcdim>
122 : src_(
MakePlan(e.src_)), begin_(e.begin_),
123 src_shape_(e.src_shape_), shape_(e.shape_) {}
128 for (
int k = srcdim-2; k >= 0; --k) {
129 idx += stride * (i%shape_[k] + begin_[k]);
131 stride *= src_shape_[k];
133 return src_.Eval(idx, j + begin_[srcdim-1]);
139 for (
int k = srcdim-2; k >= 0; --k) {
140 idx += stride * (i%shape_[k] + begin_[k]);
142 stride *= src_shape_[k];
144 return src_.REval(idx, j + begin_[srcdim-1]);
153 #endif // MSHADOW_EXTENSION_SLICE_EX_H_
static const int kDevMask
Definition: expr_engine-inl.h:264
const Container & self(void) const
Definition: expression.h:82
computaion stream structure, used for asynchronous computations
Definition: tensor.h:488
SliceExp< SrcExp, Device, DType, srcdim, srcdim - sdim > slice(const TRValue< SrcExp, Device, srcdim, DType > &src, index_t begin, index_t end)
Slice a Tensor.
Definition: slice.h:83
Plan(const SliceExExp< SrcExp, Device, DType, srcdim > &e)
Definition: slice_ex.h:121
Tensor RValue, this is the super type of all kinds of possible tensors.
Definition: tensor.h:514
used to help static type check
Definition: expr_engine-inl.h:330
Shape< srcdim > src_shape_
Definition: slice_ex.h:45
void operator=(const DType &exp)
Definition: slice_ex.h:62
SliceExExp(const SrcExp &src, Shape< srcdim > begin, Shape< srcdim > end)
Definition: slice_ex.h:49
MSHADOW_XINLINE DType & REval(index_t i, index_t j)
Definition: slice_ex.h:135
static Stream< Device > * Get(const E &t)
#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
Definition: expr_engine-inl.h:345
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
Shape< srcdim > shape_
Definition: slice_ex.h:46
index_t shape_[kDimension]
storing the dimension information
Definition: tensor.h:86
static Stream< Device > * Get(const SliceExExp< SrcExp, Device, DType, srcdim > &t)
Definition: slice_ex.h:103
const Shape< srcdim > end_
Definition: slice_ex.h:48
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
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
const SrcExp & src_
Definition: slice_ex.h:44
overloaded + operator between half_t and bf16_t
Definition: base.h:319
static Shape< srcdim > Check(const SliceExExp< SrcExp, Device, DType, srcdim > &t)
Definition: slice_ex.h:93
slice expression, slice a tensor's channel
Definition: slice_ex.h:40
SliceExExp< SrcExp, Device, DType, srcdim > & __assign(DType s)
operator overload
Definition: expression.h:178
void operator=(const expr::Exp< E, DType, etype > &exp)
Definition: slice_ex.h:58
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: slice_ex.h:124
const Shape< srcdim > begin_
Definition: slice_ex.h:47