7 #ifndef MSHADOW_EXTENSION_UNPACK_PATCH2COL_H_ 8 #define MSHADOW_EXTENSION_UNPACK_PATCH2COL_H_ 9 #include "../extension.h" 20 template<
typename SrcExp,
typename DType,
int srcdim>
22 public MakeTensorExp<UnpackPatchToColXExp<SrcExp, DType, srcdim>,
50 : img_(img), psize_y_(psize_y), psize_x_(psize_x),
51 pstride_y_(pstride_y), pstride_x_(pstride_x),
52 pdilate_y_(pdilate_y), pdilate_x_(pdilate_x){
54 CHECK(imshape[srcdim - 1] >= psize_x && imshape[srcdim - 2] >= psize_y)
55 <<
"UnpackPatchToCol:image shape smaller than patch size";
56 this->i_channel_ = imshape[srcdim - 3];
57 this->i_height_ = imshape[srcdim - 2];
58 this->i_width_ = imshape[srcdim - 1];
61 const index_t o_height = (i_height_ -
62 (pdilate_y * (psize_y - 1) + 1)) / pstride_y + 1;
63 const index_t o_width = (i_width_ -
64 (pdilate_x * (psize_x - 1) + 1)) / pstride_x + 1;
65 this->
shape_[1] = o_height * o_width * num;
89 template<
typename SrcExp,
typename DType,
int etype>
94 ::Error_Expression_Does_Not_Meet_Dimension_Req();
96 (img.
self(), psize_y, psize_x, pstride, pstride, pdilate, pdilate);
102 template<
typename SrcExp,
typename DType,
int etype>
108 ::Error_Expression_Does_Not_Meet_Dimension_Req();
115 template<
typename SrcExp,
typename DType,
int srcdim>
132 const index_t jdivw = j / o_width_;
134 const index_t n = jdivw / o_height_;
151 #endif // MSHADOW_EXTENSION_UNPACK_PATCH2COL_H_ Definition: expr_engine-inl.h:40
used to help static type check
Definition: expr_engine-inl.h:312
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:43
index_t psize_x_
patch width
Definition: unpack_patch2col.h:29
unpack local (overlap) patches of image to column of mat, can be used to implement convolution...
Definition: unpack_patch2col.h:21
index_t pstride_y_
patch stride
Definition: unpack_patch2col.h:31
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:91
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:204
int32_t index_t
type that will be used for index
Definition: base.h:291
index_t i_height_
height of img
Definition: unpack_patch2col.h:39
index_t i_width_
width of img
Definition: unpack_patch2col.h:41
MSHADOW_XINLINE index_t ProdShape(int dimstart, int dimend) const
Definition: tensor.h:139
index_t pdilate_x_
Definition: unpack_patch2col.h:35
const SrcExp & img_
source operand
Definition: unpack_patch2col.h:25
index_t i_channel_
number of input channel
Definition: unpack_patch2col.h:37
MSHADOW_XINLINE DType Eval(index_t i, index_t j) const
Definition: unpack_patch2col.h:126
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
Plan(const UnpackPatchToColXExp< SrcExp, DType, srcdim > &e)
Definition: unpack_patch2col.h:118
index_t pdilate_y_
patch dilate
Definition: unpack_patch2col.h:34
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
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:29
index_t pstride_x_
Definition: unpack_patch2col.h:32
index_t psize_y_
patch height
Definition: unpack_patch2col.h:27