1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #29161 from abhishek-gola:lama_inpainting_bug

[BUG FIX] Fixed Conv+Add+BatchNorm fusion with correct BN scale on the residual
This commit is contained in:
Alexander Smorkalov
2026-05-27 20:23:50 +03:00
committed by GitHub
+4 -1
View File
@@ -195,8 +195,11 @@ public:
virtual bool fuseBatchNorm(const Ptr<Layer>& bnlayer) override
{
BatchNorm2Layer* bn = dynamic_cast<BatchNorm2Layer*>(bnlayer.get());
// addResidual means the graph order is conv->add->bn: the residual is added
// before BN, but the conv applies the fused BN scale only to conv(x), not to
// the residual. Refuse so BN stays separate and runs on (conv + residual).
if (fusedBatchNorm || !bn || bn->inputs.size() > 1 ||
fastActivation != FAST_ACTIV_NONE || !activ.empty())
fastActivation != FAST_ACTIV_NONE || !activ.empty() || addResidual)
return false;
fuseBatchNormWeights(bn);
fusedBatchNorm = true;