7 #ifndef MSHADOW_EXTENSION_PAD_H_ 8 #define MSHADOW_EXTENSION_PAD_H_ 9 #include "../extension.h" 18 template<
typename SrcExp,
typename DType,
int srcdim>
21 SrcExp, srcdim, DType> {
34 : src_(src), pad_y_(pad_y), pad_x_(pad_x) {
36 src_height_ = this->
shape_[srcdim - 2];
37 src_width_ = this->
shape_[srcdim - 1];
38 this->
shape_[srcdim - 2] += pad_y * 2;
39 this->
shape_[srcdim - 1] += pad_x * 2;
51 template<
typename SrcExp,
typename DType,
int etype>
55 ::Error_Expression_Does_Not_Meet_Dimension_Req();
68 template<
typename SrcExp,
typename DType,
int etype>
72 ::Error_Expression_Does_Not_Meet_Dimension_Req();
74 (src.
self(), pad_y, pad_x);
79 template<
typename SrcExp,
typename DType,
int srcdim>
85 new_height_(e.
shape_[srcdim - 2]),
89 const index_t y = i % new_height_;
90 const index_t c = i / new_height_;
91 if (y <
pad_y_ || x <
pad_x_)
return static_cast<DType
>(0);
97 return static_cast<DType
>(0);
111 #endif // MSHADOW_EXTENSION_PAD_H_ const SrcExp & src_
source operand
Definition: pad.h:23
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
index_t pad_y_
pad size in y
Definition: pad.h:25
padding expression, pad a image with zeros
Definition: pad.h:19
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:204
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: pad.h:87
int32_t index_t
type that will be used for index
Definition: base.h:291
index_t src_height_
source tensor height
Definition: pad.h:29
index_t src_width_
source tensor width
Definition: pad.h:31
index_t pad_x_
pad size in x
Definition: pad.h:27
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
Plan(const PaddingExp< SrcExp, DType, srcdim > &e)
Definition: pad.h:82
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:29
PaddingExp(const SrcExp &src, index_t pad_y, index_t pad_x)
constructor
Definition: pad.h:33