From 62d079fa699aed6a1e2fe6e9ad3b4de368a95146 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Tue, 16 Apr 2019 11:41:50 +0300 Subject: [PATCH] Fix Normalize layer for Mac --- .../dnn/src/layers/normalize_bbox_layer.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/dnn/src/layers/normalize_bbox_layer.cpp b/modules/dnn/src/layers/normalize_bbox_layer.cpp index 8760cad33b..65640b6905 100644 --- a/modules/dnn/src/layers/normalize_bbox_layer.cpp +++ b/modules/dnn/src/layers/normalize_bbox_layer.cpp @@ -275,13 +275,13 @@ public: InferenceEngine::Blob::Ptr weights; if (blobs.empty()) { - auto onesBlob = InferenceEngine::make_shared_blob(InferenceEngine::Precision::FP32, - InferenceEngine::Layout::C, - {(size_t)numChannels}); - onesBlob->allocate(); - std::vector ones(numChannels, 1); - onesBlob->set(ones); - weights = onesBlob; + weights = InferenceEngine::make_shared_blob(InferenceEngine::Precision::FP32, + InferenceEngine::Layout::C, + {(size_t)numChannels}); + weights->allocate(); + + Mat weightsMat = infEngineBlobToMat(weights).reshape(1, numChannels); + Mat(numChannels, 1, CV_32F, Scalar(1)).copyTo(weightsMat); l.getParameters()["channel_shared"] = false; } else @@ -290,11 +290,7 @@ public: weights = wrapToInfEngineBlob(blobs[0], {(size_t)numChannels}, InferenceEngine::Layout::C); l.getParameters()["channel_shared"] = blobs[0].total() == 1; } -#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2019R1) - l.getParameters()["weights"] = weights; -#else - l.addConstantData("weights", weights); -#endif + addConstantData("weights", weights, l); l.getParameters()["across_spatial"] = acrossSpatial; return Ptr(new InfEngineBackendNode(l)); }