From c2ca3ee2faa52fd5bbbddeb8edc31a6edfedb207 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Mon, 9 Dec 2019 19:06:47 +0300 Subject: [PATCH] Fix weights fusion for Convolution and Deconvolution layers in nGraph --- modules/dnn/src/layers/convolution_layer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/dnn/src/layers/convolution_layer.cpp b/modules/dnn/src/layers/convolution_layer.cpp index 4d1fe5f5ae..a4406a6466 100644 --- a/modules/dnn/src/layers/convolution_layer.cpp +++ b/modules/dnn/src/layers/convolution_layer.cpp @@ -553,10 +553,10 @@ public: } else { - Mat newWeights = blobs[0].reshape(1, outCn); - Mat cvWeights = weightsMat.colRange(0, newWeights.cols); + Mat newWeights; + Mat cvWeights = weightsMat.colRange(0, blobs[0].total() / outCn); cvWeights.copyTo(newWeights); - ieWeights = std::make_shared(ngraph::element::f32, kernel_shape, blobs[0].data); + ieWeights = std::make_shared(ngraph::element::f32, kernel_shape, newWeights.data); } } @@ -2033,9 +2033,9 @@ public: if (fusedWeights) { - int inpCn = blobs[0].size[0]; - Mat newWeights = blobs[0].reshape(1, inpCn); + Mat newWeights; transpose(weightsMat, newWeights); + ieWeights = std::make_shared(ngraph::element::f32, kernel_shape, newWeights.data); } size_t batch = ieInpNode->get_shape()[0]; std::vector out_shape = {batch, (size_t)numOutput};