7 #ifndef MSHADOW_EXTENSION_SPATIAL_UPSAMPLING_NEAREST_H_ 8 #define MSHADOW_EXTENSION_SPATIAL_UPSAMPLING_NEAREST_H_ 9 #include "../extension.h" 20 template<
typename SrcExp,
typename DType,
int srcdim>
22 public MakeTensorExp<UpSamplingNearestExp<SrcExp, DType, srcdim>,
23 SrcExp, srcdim, DType> {
30 : src_(src), scale_(scale) {
38 template<
typename SrcExp,
typename DType,
int etype>
42 ::Error_Expression_Does_Not_Meet_Dimension_Req();
46 template<
typename SrcExp,
typename DType,
int srcdim>
52 new_height_(e.
shape_[srcdim - 2]),
56 const index_t y = i % new_height_;
57 const index_t c = i / new_height_;
60 return src_.Eval(c * src_height_ + h, w);
71 #endif // MSHADOW_EXTENSION_SPATIAL_UPSAMPLING_NEAREST_H_ Plan(const UpSamplingNearestExp< SrcExp, DType, srcdim > &e)
Definition: spatial_upsampling_nearest.h:49
Definition: expr_engine-inl.h:40
used to help static type check
Definition: expr_engine-inl.h:312
UpSamplingNearestExp< SrcExp, DType, ExpInfo< SrcExp >::kDim > upsampling_nearest(const Exp< SrcExp, DType, etype > &src, index_t scale)
Definition: spatial_upsampling_nearest.h:40
nearest neighboor upsampling out(x, y) = in(int(x / scale_x), int(y / scale_y))
Definition: spatial_upsampling_nearest.h:21
static Shape< dim > Check(const E &t)
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: spatial_upsampling_nearest.h:54
#define MSHADOW_XINLINE
Definition: base.h:204
index_t scale_
up sampling scale
Definition: spatial_upsampling_nearest.h:27
int32_t index_t
type that will be used for index
Definition: base.h:291
const SrcExp & src_
source oprand
Definition: spatial_upsampling_nearest.h:25
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
UpSamplingNearestExp(const SrcExp &src, index_t scale)
constructor
Definition: spatial_upsampling_nearest.h:29
namespace for mshadow
Definition: base.h:282
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:29