mirror of
https://github.com/opencv/opencv.git
synced 2025-08-05 22:19:14 +08:00
Merge pull request #12031 from alalek:dnn_ocl_eliminate_getUMat_with_bad_lifetime
This commit is contained in:
commit
7d40fcead5
@ -866,6 +866,16 @@ public:
|
||||
for (int i = 0; i < inputs.size(); ++i)
|
||||
CV_Assert(inputs[i].u != outputs[0].u);
|
||||
|
||||
if (umat_blobs.empty())
|
||||
{
|
||||
size_t n = blobs.size();
|
||||
umat_blobs.resize(n);
|
||||
for (size_t i = 0; i < n; i++)
|
||||
{
|
||||
blobs[i].copyTo(umat_blobs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (convolutionOp.empty())
|
||||
{
|
||||
OCL4DNNConvConfig config;
|
||||
@ -1637,14 +1647,6 @@ public:
|
||||
Ptr<BaseConvolutionLayer> ConvolutionLayer::create(const LayerParams ¶ms)
|
||||
{
|
||||
Ptr<ConvolutionLayerImpl> l(new ConvolutionLayerImpl(params));
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
size_t n = params.blobs.size();
|
||||
l->umat_blobs.resize(n);
|
||||
for (int i = 0; i < n; i++)
|
||||
l->umat_blobs[i] = params.blobs[i].getUMat(ACCESS_READ);
|
||||
#endif
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
|
@ -563,10 +563,10 @@ bool OCL4DNNConvSpatial<Dtype>::Forward(const UMat& bottom,
|
||||
}
|
||||
|
||||
if (use_half_ && bias_half.empty() && !bias.empty())
|
||||
convertFp16((UMat&)bias, bias_half);
|
||||
convertFp16(bias, bias_half);
|
||||
|
||||
if (use_half_ && weights_half.empty())
|
||||
convertFp16((UMat&)weight, weights_half);
|
||||
convertFp16(weight, weights_half);
|
||||
|
||||
prepareKernel(bottom, top, weight, (use_half_) ? bias_half : bias, numImages);
|
||||
if (bestKernelConfig.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user