|
|
|
@ -115,9 +115,7 @@ public: |
|
|
|
|
|
|
|
|
|
virtual bool supportBackend(int backendId) CV_OVERRIDE |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || |
|
|
|
|
backendId == DNN_BACKEND_HALIDE && haveHalide() || |
|
|
|
|
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine(); |
|
|
|
|
return func.supportBackend(backendId, this->preferableTarget); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node) CV_OVERRIDE |
|
|
|
@ -238,6 +236,12 @@ struct ReLUFunctor |
|
|
|
|
|
|
|
|
|
explicit ReLUFunctor(float slope_=1.f) : slope(slope_) {} |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE || |
|
|
|
|
backendId == DNN_BACKEND_INFERENCE_ENGINE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
float s = slope; |
|
|
|
@ -353,6 +357,12 @@ struct ReLU6Functor |
|
|
|
|
CV_Assert(minValue <= maxValue); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE || |
|
|
|
|
backendId == DNN_BACKEND_INFERENCE_ENGINE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize ) |
|
|
|
@ -445,6 +455,12 @@ struct TanHFunctor |
|
|
|
|
{ |
|
|
|
|
typedef TanHLayer Layer; |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE || |
|
|
|
|
backendId == DNN_BACKEND_INFERENCE_ENGINE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize ) |
|
|
|
@ -509,6 +525,12 @@ struct SigmoidFunctor |
|
|
|
|
{ |
|
|
|
|
typedef SigmoidLayer Layer; |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE || |
|
|
|
|
backendId == DNN_BACKEND_INFERENCE_ENGINE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize ) |
|
|
|
@ -575,6 +597,11 @@ struct ELUFunctor |
|
|
|
|
|
|
|
|
|
explicit ELUFunctor() {} |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize ) |
|
|
|
@ -638,6 +665,11 @@ struct AbsValFunctor |
|
|
|
|
{ |
|
|
|
|
typedef AbsLayer Layer; |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize ) |
|
|
|
@ -701,6 +733,11 @@ struct BNLLFunctor |
|
|
|
|
{ |
|
|
|
|
typedef BNLLLayer Layer; |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize ) |
|
|
|
@ -751,6 +788,14 @@ struct PowerFunctor |
|
|
|
|
explicit PowerFunctor(float power_ = 1.f, float scale_ = 1.f, float shift_ = 0.f) |
|
|
|
|
: power(power_), scale(scale_), shift(shift_) {} |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int targetId) |
|
|
|
|
{ |
|
|
|
|
if (backendId == DNN_BACKEND_INFERENCE_ENGINE) |
|
|
|
|
return (targetId != DNN_TARGET_OPENCL && targetId != DNN_TARGET_OPENCL_FP16) || power == 1.0; |
|
|
|
|
else |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
float a = scale, b = shift, p = power; |
|
|
|
@ -853,6 +898,11 @@ struct ChannelsPReLUFunctor |
|
|
|
|
scale_umat = scale.getUMat(ACCESS_READ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool supportBackend(int backendId, int) |
|
|
|
|
{ |
|
|
|
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const |
|
|
|
|
{ |
|
|
|
|
CV_Assert(scale.isContinuous() && scale.type() == CV_32F); |
|
|
|
|