|
|
@ -1196,7 +1196,8 @@ struct Net::Impl |
|
|
|
// some other layers.
|
|
|
|
// some other layers.
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: OpenCL target support more fusion styles.
|
|
|
|
// 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; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
Ptr<Layer>& currLayer = ld.layerInstance; |
|
|
|
Ptr<Layer>& currLayer = ld.layerInstance; |
|
|
@ -1214,7 +1215,10 @@ struct Net::Impl |
|
|
|
{ |
|
|
|
{ |
|
|
|
printf_(("\tfused with %s\n", nextBNormLayer->name.c_str())); |
|
|
|
printf_(("\tfused with %s\n", nextBNormLayer->name.c_str())); |
|
|
|
bnormData->skipFlags[DNN_BACKEND_DEFAULT] = true; |
|
|
|
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 ) |
|
|
|
if( bnormData->consumers.size() == 1 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nextData = &layers[bnormData->consumers[0].lid]; |
|
|
|
nextData = &layers[bnormData->consumers[0].lid]; |
|
|
@ -1234,7 +1238,10 @@ struct Net::Impl |
|
|
|
{ |
|
|
|
{ |
|
|
|
printf_(("\tfused with %s\n", nextScaleLayer->name.c_str())); |
|
|
|
printf_(("\tfused with %s\n", nextScaleLayer->name.c_str())); |
|
|
|
scaleData->skipFlags[DNN_BACKEND_DEFAULT] = true; |
|
|
|
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 ) |
|
|
|
if( scaleData->consumers.size() == 1 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nextData = &layers[scaleData->consumers[0].lid]; |
|
|
|
nextData = &layers[scaleData->consumers[0].lid]; |
|
|
@ -1263,7 +1270,10 @@ struct Net::Impl |
|
|
|
LayerData *activData = nextData; |
|
|
|
LayerData *activData = nextData; |
|
|
|
printf_(("\tfused with %s\n", nextActivLayer->name.c_str())); |
|
|
|
printf_(("\tfused with %s\n", nextActivLayer->name.c_str())); |
|
|
|
activData->skipFlags[DNN_BACKEND_DEFAULT] = true; |
|
|
|
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 ) |
|
|
|
if ( preferableTarget == DNN_TARGET_OPENCL ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1325,13 +1335,13 @@ struct Net::Impl |
|
|
|
!nextData->type.compare("Power")) && |
|
|
|
!nextData->type.compare("Power")) && |
|
|
|
currLayer->setActivation(nextActivLayer) ) |
|
|
|
currLayer->setActivation(nextActivLayer) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CV_Assert(firstConvLayerData->outputBlobs.size() == 1 && ld.inputBlobs.size() == 1); |
|
|
|
CV_Assert(firstConvLayerData->umat_outputBlobs.size() == 1 && ld.umat_inputBlobs.size() == 1); |
|
|
|
ld.inputBlobs.push_back(&firstConvLayerData->outputBlobs[0]); |
|
|
|
ld.umat_inputBlobs.push_back(firstConvLayerData->umat_outputBlobs[0]); |
|
|
|
printf_(("\tfused with %s\n", nextEltwiseLayer->name.c_str())); |
|
|
|
printf_(("\tfused with %s\n", nextEltwiseLayer->name.c_str())); |
|
|
|
printf_(("\tfused with %s\n", nextActivLayer->name.c_str())); |
|
|
|
printf_(("\tfused with %s\n", nextActivLayer->name.c_str())); |
|
|
|
eltwiseData->skipFlags[DNN_BACKEND_DEFAULT] = true; |
|
|
|
eltwiseData->skipFlags[DNN_BACKEND_DEFAULT] = true; |
|
|
|
nextData->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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|