mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 20:09:23 +08:00
dnn(ocl4dnn): fuseLayer() use umat_input/outputBlobs for OpenCL target
Also, fix bug when use OPENCL target but no OpenCL runtime Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>
This commit is contained in:
parent
a47fbd2610
commit
1f465a0ef9
@ -1196,7 +1196,8 @@ struct Net::Impl
|
||||
// some other layers.
|
||||
|
||||
// TODO: OpenCL target support more fusion styles.
|
||||
if ( preferableTarget == DNN_TARGET_OPENCL && ld.layerInstance->type.compare("Convolution") )
|
||||
if ( preferableTarget == DNN_TARGET_OPENCL &&
|
||||
(!cv::ocl::useOpenCL() || ld.layerInstance->type.compare("Convolution")) )
|
||||
continue;
|
||||
|
||||
Ptr<Layer>& currLayer = ld.layerInstance;
|
||||
@ -1214,7 +1215,10 @@ struct Net::Impl
|
||||
{
|
||||
printf_(("\tfused with %s\n", nextBNormLayer->name.c_str()));
|
||||
bnormData->skipFlags[DNN_BACKEND_DEFAULT] = true;
|
||||
ld.outputBlobs = layers[lpNext.lid].outputBlobs;
|
||||
if ( preferableTarget == DNN_TARGET_OPENCL )
|
||||
ld.umat_outputBlobs = layers[lpNext.lid].umat_outputBlobs;
|
||||
else
|
||||
ld.outputBlobs = layers[lpNext.lid].outputBlobs;
|
||||
if( bnormData->consumers.size() == 1 )
|
||||
{
|
||||
nextData = &layers[bnormData->consumers[0].lid];
|
||||
@ -1234,7 +1238,10 @@ struct Net::Impl
|
||||
{
|
||||
printf_(("\tfused with %s\n", nextScaleLayer->name.c_str()));
|
||||
scaleData->skipFlags[DNN_BACKEND_DEFAULT] = true;
|
||||
ld.outputBlobs = layers[lpNext.lid].outputBlobs;
|
||||
if ( preferableTarget == DNN_TARGET_OPENCL )
|
||||
ld.umat_outputBlobs = layers[lpNext.lid].umat_outputBlobs;
|
||||
else
|
||||
ld.outputBlobs = layers[lpNext.lid].outputBlobs;
|
||||
if( scaleData->consumers.size() == 1 )
|
||||
{
|
||||
nextData = &layers[scaleData->consumers[0].lid];
|
||||
@ -1263,7 +1270,10 @@ struct Net::Impl
|
||||
LayerData *activData = nextData;
|
||||
printf_(("\tfused with %s\n", nextActivLayer->name.c_str()));
|
||||
activData->skipFlags[DNN_BACKEND_DEFAULT] = true;
|
||||
ld.outputBlobs = layers[lpNext.lid].outputBlobs;
|
||||
if ( preferableTarget == DNN_TARGET_OPENCL )
|
||||
ld.umat_outputBlobs = layers[lpNext.lid].umat_outputBlobs;
|
||||
else
|
||||
ld.outputBlobs = layers[lpNext.lid].outputBlobs;
|
||||
|
||||
if ( preferableTarget == DNN_TARGET_OPENCL )
|
||||
{
|
||||
@ -1325,13 +1335,13 @@ struct Net::Impl
|
||||
!nextData->type.compare("Power")) &&
|
||||
currLayer->setActivation(nextActivLayer) )
|
||||
{
|
||||
CV_Assert(firstConvLayerData->outputBlobs.size() == 1 && ld.inputBlobs.size() == 1);
|
||||
ld.inputBlobs.push_back(&firstConvLayerData->outputBlobs[0]);
|
||||
CV_Assert(firstConvLayerData->umat_outputBlobs.size() == 1 && ld.umat_inputBlobs.size() == 1);
|
||||
ld.umat_inputBlobs.push_back(firstConvLayerData->umat_outputBlobs[0]);
|
||||
printf_(("\tfused with %s\n", nextEltwiseLayer->name.c_str()));
|
||||
printf_(("\tfused with %s\n", nextActivLayer->name.c_str()));
|
||||
eltwiseData->skipFlags[DNN_BACKEND_DEFAULT] = true;
|
||||
nextData->skipFlags[DNN_BACKEND_DEFAULT] = true;
|
||||
ld.outputBlobs = layers[lpNext.lid].outputBlobs;
|
||||
ld.umat_outputBlobs = layers[lpNext.lid].umat_outputBlobs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user