@@ -1196,7 +1196,8 @@ struct Net::Impl
1196
1196
// some other layers.
1197
1197
1198
1198
// TODO: OpenCL target support more fusion styles.
1199
- if ( preferableTarget == DNN_TARGET_OPENCL && ld.layerInstance ->type .compare (" Convolution" ) )
1199
+ if ( preferableTarget == DNN_TARGET_OPENCL &&
1200
+ (!cv::ocl::useOpenCL () || ld.layerInstance ->type .compare (" Convolution" )) )
1200
1201
continue ;
1201
1202
1202
1203
Ptr<Layer>& currLayer = ld.layerInstance ;
@@ -1214,7 +1215,10 @@ struct Net::Impl
1214
1215
{
1215
1216
printf_ ((" \t fused with %s\n " , nextBNormLayer->name .c_str ()));
1216
1217
bnormData->skipFlags [DNN_BACKEND_DEFAULT] = true ;
1217
- ld.outputBlobs = layers[lpNext.lid ].outputBlobs ;
1218
+ if ( preferableTarget == DNN_TARGET_OPENCL )
1219
+ ld.umat_outputBlobs = layers[lpNext.lid ].umat_outputBlobs ;
1220
+ else
1221
+ ld.outputBlobs = layers[lpNext.lid ].outputBlobs ;
1218
1222
if ( bnormData->consumers .size () == 1 )
1219
1223
{
1220
1224
nextData = &layers[bnormData->consumers [0 ].lid ];
@@ -1234,7 +1238,10 @@ struct Net::Impl
1234
1238
{
1235
1239
printf_ ((" \t fused with %s\n " , nextScaleLayer->name .c_str ()));
1236
1240
scaleData->skipFlags [DNN_BACKEND_DEFAULT] = true ;
1237
- ld.outputBlobs = layers[lpNext.lid ].outputBlobs ;
1241
+ if ( preferableTarget == DNN_TARGET_OPENCL )
1242
+ ld.umat_outputBlobs = layers[lpNext.lid ].umat_outputBlobs ;
1243
+ else
1244
+ ld.outputBlobs = layers[lpNext.lid ].outputBlobs ;
1238
1245
if ( scaleData->consumers .size () == 1 )
1239
1246
{
1240
1247
nextData = &layers[scaleData->consumers [0 ].lid ];
@@ -1263,7 +1270,10 @@ struct Net::Impl
1263
1270
LayerData *activData = nextData;
1264
1271
printf_ ((" \t fused with %s\n " , nextActivLayer->name .c_str ()));
1265
1272
activData->skipFlags [DNN_BACKEND_DEFAULT] = true ;
1266
- ld.outputBlobs = layers[lpNext.lid ].outputBlobs ;
1273
+ if ( preferableTarget == DNN_TARGET_OPENCL )
1274
+ ld.umat_outputBlobs = layers[lpNext.lid ].umat_outputBlobs ;
1275
+ else
1276
+ ld.outputBlobs = layers[lpNext.lid ].outputBlobs ;
1267
1277
1268
1278
if ( preferableTarget == DNN_TARGET_OPENCL )
1269
1279
{
@@ -1325,13 +1335,13 @@ struct Net::Impl
1325
1335
!nextData->type .compare (" Power" )) &&
1326
1336
currLayer->setActivation (nextActivLayer) )
1327
1337
{
1328
- CV_Assert (firstConvLayerData->outputBlobs .size () == 1 && ld.inputBlobs .size () == 1 );
1329
- ld.inputBlobs .push_back (& firstConvLayerData->outputBlobs [0 ]);
1338
+ CV_Assert (firstConvLayerData->umat_outputBlobs .size () == 1 && ld.umat_inputBlobs .size () == 1 );
1339
+ ld.umat_inputBlobs .push_back (firstConvLayerData->umat_outputBlobs [0 ]);
1330
1340
printf_ ((" \t fused with %s\n " , nextEltwiseLayer->name .c_str ()));
1331
1341
printf_ ((" \t fused with %s\n " , nextActivLayer->name .c_str ()));
1332
1342
eltwiseData->skipFlags [DNN_BACKEND_DEFAULT] = true ;
1333
1343
nextData->skipFlags [DNN_BACKEND_DEFAULT] = true ;
1334
- ld.outputBlobs = layers[lpNext.lid ].outputBlobs ;
1344
+ ld.umat_outputBlobs = layers[lpNext.lid ].umat_outputBlobs ;
1335
1345
}
1336
1346
}
1337
1347
}
0 commit comments