25 #ifndef MSHADOW_EXTENSION_PAD_H_ 26 #define MSHADOW_EXTENSION_PAD_H_ 27 #include "../extension.h" 36 template<
typename SrcExp,
typename DType,
int srcdim>
39 SrcExp, srcdim, DType> {
52 : src_(src), pad_y_(pad_y), pad_x_(pad_x) {
54 src_height_ = this->
shape_[srcdim - 2];
55 src_width_ = this->
shape_[srcdim - 1];
56 this->
shape_[srcdim - 2] += pad_y * 2;
57 this->
shape_[srcdim - 1] += pad_x * 2;
69 template<
typename SrcExp,
typename DType,
int etype>
73 ::Error_Expression_Does_Not_Meet_Dimension_Req();
86 template<
typename SrcExp,
typename DType,
int etype>
90 ::Error_Expression_Does_Not_Meet_Dimension_Req();
92 (src.
self(), pad_y, pad_x);
97 template<
typename SrcExp,
typename DType,
int srcdim>
103 new_height_(e.
shape_[srcdim - 2]),
107 const index_t y = i % new_height_;
108 const index_t c = i / new_height_;
109 if (y <
pad_y_ || x <
pad_x_)
return static_cast<DType
>(0);
115 return static_cast<DType
>(0);
129 #endif // MSHADOW_EXTENSION_PAD_H_ MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: pad.h:105
const SrcExp & src_
source operand
Definition: pad.h:41
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:71
const SubType & self(void) const
Definition: expression.h:82
Definition: expr_engine-inl.h:58
used to help static type check
Definition: expr_engine-inl.h:330
index_t pad_y_
pad size in y
Definition: pad.h:43
padding expression, pad a image with zeros
Definition: pad.h:37
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:230
int32_t index_t
type that will be used for index
Definition: base.h:343
index_t src_height_
source tensor height
Definition: pad.h:47
index_t src_width_
source tensor width
Definition: pad.h:49
index_t pad_x_
pad size in x
Definition: pad.h:45
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
overloaded + operator between half_t and bf16_t
Definition: base.h:334
Plan(const PaddingExp< SrcExp, DType, srcdim > &e)
Definition: pad.h:100
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:47
PaddingExp(const SrcExp &src, index_t pad_y, index_t pad_x)
constructor
Definition: pad.h:51