Go to the documentation of this file.
24 #ifndef MSHADOW_EXTENSION_SLICE_H_
25 #define MSHADOW_EXTENSION_SLICE_H_
27 #include "../extension.h"
38 template<
typename SrcExp,
39 typename Device,
typename DType,
40 int srcdim,
int dimsrc_m_slice>
43 srcdim, dimsrc_m_slice>,
44 Device, srcdim, DType> {
45 static const int dimslice = srcdim - dimsrc_m_slice;
55 <<
"The slice went out of range. ";
58 template<
typename E,
int etype>
80 template<
int sdim,
typename SrcExp,
81 typename Device,
typename DType,
int srcdim>
82 inline SliceExp<SrcExp, Device, DType, srcdim, srcdim - sdim>
85 ::Error_Expression_Does_Not_Meet_Dimension_Req();
86 return SliceExp<SrcExp, Device, DType, srcdim, srcdim - sdim>(src.
self(), begin, end);
92 template<
typename SrcExp,
93 typename Device,
typename DType,
94 int srcdim,
int dimsrc_m_slice>
97 Device, DType, srcdim, dimsrc_m_slice> &t) {
101 template<
typename SrcExp,
102 typename Device,
typename DType,
103 int srcdim,
int dimsrc_m_slice>
111 template<
typename SrcExp,
112 typename Device,
typename DType,
113 int srcdim,
int dimsrc_m_slice>
121 template<
typename SrcExp,
122 typename Device,
typename DType,
123 int srcdim,
int dimsrc_m_slice>
124 struct Plan<
SliceExp<SrcExp, Device, DType, srcdim, dimsrc_m_slice>, DType> {
126 static const int dimslice = srcdim - dimsrc_m_slice;
129 height_(e.shape_.ProdShape(dimslice + 1, srcdim - 1)),
130 ch_begin_(e.ch_begin_), ch_old_(e.ch_old_), ch_(e.shape_[dimslice]) {}
134 const index_t c = i % ch_ + ch_begin_;
137 return src_.Eval((b * ch_old_ + c) * height_ + y, x);
142 const index_t c = i % ch_ + ch_begin_;
145 return src_.REval((b * ch_old_ + c) * height_ + y, x);
150 const index_t height_, ch_begin_, ch_old_, ch_;
153 template<
typename SrcExp,
154 typename Device,
typename DType,
160 ch_begin_(e.ch_begin_) {}
162 return src_.Eval(y, x + ch_begin_);
165 return src_.REval(y, x + ch_begin_);
174 #endif // MSHADOW_EXTENSION_SLICE_H_
MSHADOW_XINLINE DType & REval(index_t y, index_t x)
Definition: slice.h:164
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
Shape< srcdim > shape_
Definition: slice.h:49
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
MSHADOW_XINLINE DType & REval(index_t i, index_t j)
Definition: slice.h:139
static const int dimslice
Definition: slice.h:45
Plan(const SliceExp< SrcExp, Device, DType, srcdim, dimsrc_m_slice > &e)
Definition: slice.h:127
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
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: slice.h:161
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
index_t shape_[kDimension]
storing the dimension information
Definition: tensor.h:86
static Shape< srcdim > Check(const SliceExp< SrcExp, Device, DType, srcdim, dimsrc_m_slice > &t)
Definition: slice.h:96
slice expression, slice a tensor's channel
Definition: slice.h:41
static Stream< Device > * Get(const SliceExp< SrcExp, Device, DType, srcdim, dimsrc_m_slice > &t)
Definition: slice.h:106
static const int kDim
Definition: expr_engine-inl.h:263
void operator=(const DType &exp)
Definition: slice.h:64
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.h:46
void operator=(const expr::Exp< E, DType, etype > &exp)
Definition: slice.h:60
Plan(const SliceExp< SrcExp, Device, DType, srcdim, 1 > &e)
Definition: slice.h:158
overloaded + operator between half_t and bf16_t
Definition: base.h:319
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: slice.h:131
index_t ch_old_
Definition: slice.h:48
SliceExp< SrcExp, Device, DType, srcdim, dimsrc_m_slice > & __assign(DType s)
operator overload
Definition: expression.h:178
index_t ch_begin_
Definition: slice.h:47
SliceExp(const SrcExp &src, index_t begin, index_t end)
Definition: slice.h:50