1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

dispatch: added CV_TRY_${OPT} macro, fix dnn build

- 1: OPT is available directly or via dispatcher
- 0: optimization is not compiled at all
This commit is contained in:
Alexander Alekhin
2017-06-27 17:05:15 +03:00
parent 9ee60dbff2
commit f8a75c4361
6 changed files with 47 additions and 19 deletions
+4 -4
View File
@@ -315,7 +315,7 @@ public:
int inpCnAll = input.size[1], width = input.size[3], height = input.size[2];
int inpCn = inpCnAll / ngroups;
p.is1x1_ = kernel == Size(0,0) && pad == Size(0, 0);
p.useAVX2 = checkHardwareSupport(CPU_AVX2);
p.useAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
int ncn = std::min(inpCn, (int)BLK_SIZE_CN);
p.ofstab_.resize(kernel.width*kernel.height*ncn);
@@ -486,7 +486,7 @@ public:
// now compute dot product of the weights
// and im2row-transformed part of the tensor
int bsz = ofs1 - ofs0;
#if CV_DNN_TRY_AVX2
#if CV_TRY_AVX2
if(useAVX2)
fastConv_avx2(wptr, wstep, biasptr, rowbuf0, data_out0 + ofs0,
outShape, bsz, vsz, vsz_a, relu, cn0 == 0);
@@ -776,7 +776,7 @@ public:
b_ = &b;
c_ = &c;
nstripes_ = nstripes;
useAVX2 = checkHardwareSupport(CPU_AVX2);
useAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
}
void operator()(const Range& range_) const
@@ -794,7 +794,7 @@ public:
size_t bstep = b_->step1();
size_t cstep = c_->step1();
#if CV_DNN_TRY_AVX2
#if CV_TRY_AVX2
if( useAVX2 )
fastGEMM_avx2( aptr, astep, bptr, bstep, cptr, cstep, mmax, kmax, nmax );
else
@@ -127,7 +127,7 @@ public:
biasMat_ = &biasMat;
dstMat_ = &dstMat;
nstripes_ = nstripes;
useAVX2_ = checkHardwareSupport(CPU_AVX2);
useAVX2_ = CV_CPU_HAS_SUPPORT_AVX2;
}
void operator()(const Range& r) const
@@ -161,7 +161,7 @@ public:
memcpy(sptr, sptr_, vecsize*sizeof(sptr[0]));
#if CV_DNN_TRY_AVX2
#if CV_TRY_AVX2
if( useAVX2_ )
fastGEMM1T_avx2( sptr, wptr, wstep, biasptr, dptr, nw, vecsize);
else
@@ -43,10 +43,6 @@
#include "layers_common.hpp"
#include "opencv2/core/hal/intrin.hpp"
#if CV_DNN_TRY_AVX2
#include <immintrin.h>
namespace cv {
namespace dnn {
@@ -334,7 +330,6 @@ void fastGEMM_avx2( const float* aptr, size_t astep, const float* bptr,
_mm256_storeu_ps(cptr3 + n + 8, d31);
}
}
_mm256_zeroupper();
for( ; n < nb; n++ )
{
@@ -350,9 +345,8 @@ void fastGEMM_avx2( const float* aptr, size_t astep, const float* bptr,
cptr0[n] = d0;
}
}
_mm256_zeroupper();
}
}
}
#endif
+1 -6
View File
@@ -63,9 +63,7 @@ void getConvPoolPaddings(const Size& inp, const Size& out,
const Size &kernel, const Size &stride,
const String &padMode, Size &pad);
#if CV_SSE2
#define CV_DNN_TRY_AVX2 1
#if CV_TRY_AVX2
void fastConv_avx2(const float* weights, size_t wstep, const float* bias,
const float* rowbuf, float* output, const int* outShape,
int blockSize, int vecsize, int vecsize_aligned,
@@ -76,9 +74,6 @@ void fastGEMM1T_avx2( const float* vec, const float* weights,
void fastGEMM_avx2( const float* aptr, size_t astep, const float* bptr0,
size_t bstep, float* cptr, size_t cstep,
int ma, int na, int nb );
#else
#define CV_DNN_TRY_AVX2 0
#endif
}