7 #ifndef MSHADOW_EXTENSION_CHANNEL_POOL_H_ 8 #define MSHADOW_EXTENSION_CHANNEL_POOL_H_ 10 #include "../extension.h" 21 template<
typename Reducer,
typename SrcExp,
typename DType,
int srcdim>
23 public MakeTensorExp<ChannelPoolingExp<Reducer, SrcExp, DType, srcdim>,
24 SrcExp, srcdim, DType> {
36 : src_(src), nsize_(nsize), stride_(stride), pad_(pad) {
38 this->src_channel_ = this->
shape_[srcdim - 3];
39 CHECK_GE(this->
shape_[srcdim - 3], nsize_)
40 <<
"chpool: local size must be smaller than nchannels";
41 this->
shape_[srcdim - 3] = (this->src_channel_ - nsize + pad * 2 + 1) / stride;
55 template<
typename Reducer,
typename SrcExp,
typename DType,
int etype>
59 ::Error_Expression_Does_Not_Meet_Dimension_Req();
60 CHECK_EQ(nsize % 2, 1U) <<
"chpool: if no pad is specified, local size must be odd";
65 template<
typename Reducer,
typename SrcExp,
typename DType,
int etype>
69 ::Error_Expression_Does_Not_Meet_Dimension_Req();
77 template<
typename Reducer,
typename SrcExp,
typename DType,
int srcdim>
82 height_(e.
shape_[srcdim - 2]), width_(e.
shape_[srcdim - 1]),
94 DType res; Reducer::SetInitValue(res);
95 for (
index_t cc = cstart; cc < cend; ++cc) {
107 #endif // MSHADOW_EXTENSION_CHANNEL_POOL_H_ index_t pad_
pad of pooling of each side
Definition: channel_pool.h:32
ChannelPoolingExp< Reducer, SrcExp, DType, ExpInfo< SrcExp >::kDim > chpool(const Exp< SrcExp, DType, etype > &src, index_t nsize)
channel pooling, do reduction over (local nearby) channels, used to implement local response normaliz...
Definition: channel_pool.h:57
PaddingExp< SrcExp, DType, ExpInfo< SrcExp >::kDim > pad(const Exp< SrcExp, DType, etype > &src, index_t pad)
padding expression, pad a image with zeros on boundaries, padding affects shape[0], and shape[1]
Definition: pad.h:53
Definition: expr_engine-inl.h:40
used to help static type check
Definition: expr_engine-inl.h:312
channel pooling expression, do reduction over (local nearby) channels, used to implement local respon...
Definition: channel_pool.h:22
Definition: optional.h:241
index_t stride_
stride of pooling
Definition: channel_pool.h:30
ChannelPoolingExp(const SrcExp &src, index_t nsize, index_t stride, index_t pad)
constructor
Definition: channel_pool.h:35
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: channel_pool.h:85
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:204
index_t src_channel_
Definition: channel_pool.h:33
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:244
int32_t index_t
type that will be used for index
Definition: base.h:291
index_t nsize_
neighbor size
Definition: channel_pool.h:28
Plan(const ChannelPoolingExp< Reducer, SrcExp, DType, srcdim > &e)
Definition: channel_pool.h:80
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:61
const SubType & self(void) const
Definition: expression.h:64
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:221
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:25
namespace for mshadow
Definition: base.h:282
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:29
const SrcExp & src_
source operand
Definition: channel_pool.h:26