From 62d079fa699aed6a1e2fe6e9ad3b4de368a95146 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Tue, 16 Apr 2019 11:41:50 +0300 Subject: [PATCH 1/2] 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)); } From c667de9b68e10c5bddc64af0355f11932889f61a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 16 Apr 2019 18:13:14 +0300 Subject: [PATCH 2/2] dnn: force visibility(default) for IE headers --- modules/dnn/src/op_inf_engine.hpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/dnn/src/op_inf_engine.hpp b/modules/dnn/src/op_inf_engine.hpp index 48ee07e745..2219f926a7 100644 --- a/modules/dnn/src/op_inf_engine.hpp +++ b/modules/dnn/src/op_inf_engine.hpp @@ -15,14 +15,6 @@ #include "opencv2/dnn/utils/inference_engine.hpp" #ifdef HAVE_INF_ENGINE -#if defined(__GNUC__) && __GNUC__ >= 5 -//#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif -#include -#if defined(__GNUC__) && __GNUC__ >= 5 -//#pragma GCC diagnostic pop -#endif #define INF_ENGINE_RELEASE_2018R3 2018030000 #define INF_ENGINE_RELEASE_2018R4 2018040000 @@ -37,12 +29,32 @@ #define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000)) #define INF_ENGINE_VER_MAJOR_GE(ver) (((INF_ENGINE_RELEASE) / 10000) >= ((ver) / 10000)) #define INF_ENGINE_VER_MAJOR_LT(ver) (((INF_ENGINE_RELEASE) / 10000) < ((ver) / 10000)) +#define INF_ENGINE_VER_MAJOR_LE(ver) (((INF_ENGINE_RELEASE) / 10000) <= ((ver) / 10000)) #define INF_ENGINE_VER_MAJOR_EQ(ver) (((INF_ENGINE_RELEASE) / 10000) == ((ver) / 10000)) +#if defined(__GNUC__) && __GNUC__ >= 5 +//#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsuggest-override" +#endif + +#if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1) +#pragma GCC visibility push(default) +#endif + +#include + #if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R5) #include #endif +#if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1) +#pragma GCC visibility pop +#endif + +#if defined(__GNUC__) && __GNUC__ >= 5 +//#pragma GCC diagnostic pop +#endif + #endif // HAVE_INF_ENGINE namespace cv { namespace dnn {