1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2020-03-09 19:50:00 +00:00
9 changed files with 623 additions and 3 deletions
+39 -3
View File
@@ -57,6 +57,9 @@
#include "opencl_kernels_dnn.hpp"
using namespace cv::dnn::ocl4dnn;
#endif
#ifdef HAVE_TENGINE
#include "../tengine4dnn/include/tengine_graph_convolution.hpp"
#endif
#ifdef HAVE_CUDA
#include "../cuda4dnn/primitives/convolution.hpp"
@@ -1427,10 +1430,43 @@ public:
}
}
int nstripes = std::max(getNumThreads(), 1);
#ifdef HAVE_TENGINE
int inch = inputs[0].size[1]; // inch
int in_h = inputs[0].size[2]; // in_h
int in_w = inputs[0].size[3]; // in_w
ParallelConv::run(inputs[0], outputs[0], weightsMat, biasvec, reluslope,
kernel_size, strides, pads_begin, pads_end, dilations, activ.get(), ngroups, nstripes);
int out_b = outputs[0].size[0]; // out batch size
int outch = outputs[0].size[1]; // outch
int out_h = outputs[0].size[2]; // out_h
int out_w = outputs[0].size[3]; // out_w
float *input_ = inputs[0].ptr<float>();
float *output_ = outputs[0].ptr<float>();
float *kernel_ = weightsMat.ptr<float>();
float *teg_bias = &biasvec[0];
bool tengine_ret = tengine_forward(input_, inch, ngroups, in_h, in_w,
output_, out_b, outch, out_h, out_w,
kernel_, kernel_size.size(), kernel.height, kernel.width,
teg_bias, stride.height, stride.width,
pad.height, pad.width, dilation.height, dilation.width,
weightsMat.step1(), padMode);
/* activation */
if((true == tengine_ret) && activ )
{
int out_cstep = out_h * out_w; // out_cstep
ActivationLayer* activ_ = activ.get();
activ_->forwardSlice(output_, output_, out_cstep, out_cstep, 0, outch);
}
if(false == tengine_ret)
#endif
{
int nstripes = std::max(getNumThreads(), 1);
ParallelConv::run(inputs[0], outputs[0], weightsMat, biasvec, reluslope,
kernel_size, strides, pads_begin, pads_end, dilations, activ.get(), ngroups, nstripes);
}
}
#ifdef HAVE_CUDA