26 #ifndef MSHADOW_EXTENSION_UNPACK_PATCH2COL_H_ 27 #define MSHADOW_EXTENSION_UNPACK_PATCH2COL_H_ 28 #include "../extension.h" 39 template<
typename SrcExp,
typename DType,
int srcdim>
41 public MakeTensorExp<UnpackPatchToColXExp<SrcExp, DType, srcdim>,
69 : img_(img), psize_y_(psize_y), psize_x_(psize_x),
70 pstride_y_(pstride_y), pstride_x_(pstride_x),
71 pdilate_y_(pdilate_y), pdilate_x_(pdilate_x){
73 CHECK(imshape[srcdim - 1] >= psize_x && imshape[srcdim - 2] >= psize_y)
74 <<
"UnpackPatchToCol:image shape smaller than patch size";
75 this->i_channel_ = imshape[srcdim - 3];
76 this->i_height_ = imshape[srcdim - 2];
77 this->i_width_ = imshape[srcdim - 1];
80 const index_t o_height = (i_height_ -
81 (pdilate_y * (psize_y - 1) + 1)) / pstride_y + 1;
82 const index_t o_width = (i_width_ -
83 (pdilate_x * (psize_x - 1) + 1)) / pstride_x + 1;
84 this->
shape_[1] = o_height * o_width * num;
108 template<
typename SrcExp,
typename DType,
int etype>
113 ::Error_Expression_Does_Not_Meet_Dimension_Req();
115 (img.
self(), psize_y, psize_x, pstride, pstride, pdilate, pdilate);
121 template<
typename SrcExp,
typename DType,
int etype>
127 ::Error_Expression_Does_Not_Meet_Dimension_Req();
134 template<
typename SrcExp,
typename DType,
int srcdim>
151 const index_t jdivw = j / o_width_;
153 const index_t n = jdivw / o_height_;
170 #endif // MSHADOW_EXTENSION_UNPACK_PATCH2COL_H_ Definition: expr_engine-inl.h:59
used to help static type check
Definition: expr_engine-inl.h:331
UnpackPatchToColXExp(const SrcExp &img, index_t psize_y, index_t psize_x, index_t pstride_y, index_t pstride_x, index_t pdilate_y, index_t pdilate_x)
constructor
Definition: unpack_patch2col.h:62
index_t psize_x_
patch width
Definition: unpack_patch2col.h:48
unpack local (overlap) patches of image to column of mat, can be used to implement convolution...
Definition: unpack_patch2col.h:40
index_t pstride_y_
patch stride
Definition: unpack_patch2col.h:50
UnpackPatchToColXExp< SrcExp, DType, ExpInfo< SrcExp >::kDim > unpack_patch2col(const Exp< SrcExp, DType, etype > &img, index_t psize_y, index_t psize_x, index_t pstride, index_t pdilate)
unpack local (overlap) patches of image to column of mat, can be used to implement convolution after ...
Definition: unpack_patch2col.h:110
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:223
int32_t index_t
type that will be used for index
Definition: base.h:336
index_t i_height_
height of img
Definition: unpack_patch2col.h:58
index_t i_width_
width of img
Definition: unpack_patch2col.h:60
MSHADOW_XINLINE index_t ProdShape(int dimstart, int dimend) const
Definition: tensor.h:158
index_t pdilate_x_
Definition: unpack_patch2col.h:54
const SrcExp & img_
source operand
Definition: unpack_patch2col.h:44
index_t i_channel_
number of input channel
Definition: unpack_patch2col.h:56
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: unpack_patch2col.h:145
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:80
const SubType & self(void) const
Definition: expression.h:83
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:240
Plan(const UnpackPatchToColXExp< SrcExp, DType, srcdim > &e)
Definition: unpack_patch2col.h:137
index_t pdilate_y_
patch dilate
Definition: unpack_patch2col.h:53
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:44
overloaded + operator between half_t and bf16_t
Definition: base.h:327
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:48
index_t pstride_x_
Definition: unpack_patch2col.h:51
index_t psize_y_
patch height
Definition: unpack_patch2col.h:46