Merge pull request #12031 from alalek:dnn_ocl_eliminate_getUMat_with_bad_lifetime

pull/12041/head
Alexander Alekhin 7 years ago
commit 7d40fcead5
  1. 18
      modules/dnn/src/layers/convolution_layer.cpp
  2. 4
      modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp

@ -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 &params)
{
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…
Cancel
Save