25 #ifndef MSHADOW_EXTENSION_SPATIAL_UPSAMPLING_NEAREST_H_ 26 #define MSHADOW_EXTENSION_SPATIAL_UPSAMPLING_NEAREST_H_ 27 #include "../extension.h" 38 template<
typename SrcExp,
typename DType,
int srcdim>
40 public MakeTensorExp<UpSamplingNearestExp<SrcExp, DType, srcdim>,
41 SrcExp, srcdim, DType> {
48 : src_(src), scale_(scale) {
56 template<
typename SrcExp,
typename DType,
int etype>
60 ::Error_Expression_Does_Not_Meet_Dimension_Req();
64 template<
typename SrcExp,
typename DType,
int srcdim>
70 new_height_(e.
shape_[srcdim - 2]),
74 const index_t y = i % new_height_;
75 const index_t c = i / new_height_;
78 return src_.Eval(c * src_height_ + h, w);
89 #endif // MSHADOW_EXTENSION_SPATIAL_UPSAMPLING_NEAREST_H_ const SubType & self(void) const
Definition: expression.h:82
Plan(const UpSamplingNearestExp< SrcExp, DType, srcdim > &e)
Definition: spatial_upsampling_nearest.h:67
Definition: expr_engine-inl.h:58
used to help static type check
Definition: expr_engine-inl.h:330
UpSamplingNearestExp< SrcExp, DType, ExpInfo< SrcExp >::kDim > upsampling_nearest(const Exp< SrcExp, DType, etype > &src, index_t scale)
Definition: spatial_upsampling_nearest.h:58
nearest neighboor upsampling out(x, y) = in(int(x / scale_x), int(y / scale_y))
Definition: spatial_upsampling_nearest.h:39
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:230
index_t scale_
up sampling scale
Definition: spatial_upsampling_nearest.h:45
int32_t index_t
type that will be used for index
Definition: base.h:343
const SrcExp & src_
source oprand
Definition: spatial_upsampling_nearest.h:43
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:43
UpSamplingNearestExp(const SrcExp &src, index_t scale)
constructor
Definition: spatial_upsampling_nearest.h:47
overloaded + operator between half_t and bf16_t
Definition: base.h:334
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:47
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: spatial_upsampling_nearest.h:72