|
|
|
@ -228,6 +228,7 @@ public: |
|
|
|
|
const Mat* src, *rois; |
|
|
|
|
Mat *dst, *mask; |
|
|
|
|
Size kernel, stride, pad; |
|
|
|
|
String padMode; |
|
|
|
|
int nstripes; |
|
|
|
|
bool computeMaxIdx; |
|
|
|
|
std::vector<int> ofsbuf; |
|
|
|
@ -238,7 +239,7 @@ public: |
|
|
|
|
computeMaxIdx(0), poolingType(MAX), spatialScale(0) {} |
|
|
|
|
|
|
|
|
|
static void run(const Mat& src, const Mat& rois, Mat& dst, Mat& mask, Size kernel, |
|
|
|
|
Size stride, Size pad, int poolingType, float spatialScale, |
|
|
|
|
Size stride, Size pad, String padMode, int poolingType, float spatialScale, |
|
|
|
|
bool computeMaxIdx, int nstripes) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(src.isContinuous(), dst.isContinuous(), |
|
|
|
@ -257,6 +258,7 @@ public: |
|
|
|
|
p.kernel = kernel; |
|
|
|
|
p.stride = stride; |
|
|
|
|
p.pad = pad; |
|
|
|
|
p.padMode = padMode; |
|
|
|
|
p.nstripes = nstripes; |
|
|
|
|
p.computeMaxIdx = computeMaxIdx; |
|
|
|
|
p.poolingType = poolingType; |
|
|
|
@ -336,7 +338,6 @@ public: |
|
|
|
|
yend = min(ystart + kernel_h, inp_height + pad_h); |
|
|
|
|
srcData = src->ptr<float>(n, c); |
|
|
|
|
} |
|
|
|
|
int ydelta = yend - ystart; |
|
|
|
|
ystart = max(ystart, 0); |
|
|
|
|
yend = min(yend, inp_height); |
|
|
|
|
float *dstData = dst->ptr<float>(n, c, y0); |
|
|
|
@ -500,15 +501,15 @@ public: |
|
|
|
|
} |
|
|
|
|
else if (poolingType == AVE) |
|
|
|
|
{ |
|
|
|
|
bool isSamePad = padMode == "SAME"; |
|
|
|
|
for( ; x0 < x1; x0++ ) |
|
|
|
|
{ |
|
|
|
|
int xstart = x0 * stride_w - pad_w; |
|
|
|
|
int xend = min(xstart + kernel_w, inp_width + pad_w); |
|
|
|
|
int xdelta = xend - xstart; |
|
|
|
|
xstart = max(xstart, 0); |
|
|
|
|
xend = min(xend, inp_width); |
|
|
|
|
float inv_kernel_area = 1.f/(ydelta*xdelta); |
|
|
|
|
|
|
|
|
|
float inv_kernel_area = isSamePad ? (yend - ystart) * (xend - xstart) : kernel.area(); |
|
|
|
|
inv_kernel_area = 1.0 / inv_kernel_area; |
|
|
|
|
#if CV_SIMD128 |
|
|
|
|
if( xstart > 0 && x0 + 7 < x1 && (x0 + 7) * stride_w - pad_w + kernel_w < inp_width ) |
|
|
|
|
{ |
|
|
|
@ -619,21 +620,21 @@ public: |
|
|
|
|
{ |
|
|
|
|
const int nstripes = getNumThreads(); |
|
|
|
|
Mat rois; |
|
|
|
|
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad, type, spatialScale, computeMaxIdx, nstripes); |
|
|
|
|
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad, padMode, type, spatialScale, computeMaxIdx, nstripes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void avePooling(Mat &src, Mat &dst) |
|
|
|
|
{ |
|
|
|
|
const int nstripes = getNumThreads(); |
|
|
|
|
Mat rois, mask; |
|
|
|
|
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad, type, spatialScale, computeMaxIdx, nstripes); |
|
|
|
|
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad, padMode, type, spatialScale, computeMaxIdx, nstripes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void roiPooling(const Mat &src, const Mat &rois, Mat &dst) |
|
|
|
|
{ |
|
|
|
|
const int nstripes = getNumThreads(); |
|
|
|
|
Mat mask; |
|
|
|
|
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad, type, spatialScale, computeMaxIdx, nstripes); |
|
|
|
|
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad, padMode, type, spatialScale, computeMaxIdx, nstripes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Ptr<BackendNode> initMaxPoolingHalide(const std::vector<Ptr<BackendWrapper> > &inputs) |
|
|
|
|