Fix Normalize layer for Mac
authorDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Tue, 16 Apr 2019 08:41:50 +0000 (11:41 +0300)
committerDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Tue, 16 Apr 2019 09:39:04 +0000 (12:39 +0300)
modules/dnn/src/layers/normalize_bbox_layer.cpp

index 8760cad..65640b6 100644 (file)
@@ -275,13 +275,13 @@ public:
             InferenceEngine::Blob::Ptr weights;
             if (blobs.empty())
             {
-                auto onesBlob = InferenceEngine::make_shared_blob<float>(InferenceEngine::Precision::FP32,
-                                                                         InferenceEngine::Layout::C,
-                                                                         {(size_t)numChannels});
-                onesBlob->allocate();
-                std::vector<float> ones(numChannels, 1);
-                onesBlob->set(ones);
-                weights = onesBlob;
+                weights = InferenceEngine::make_shared_blob<float>(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<BackendNode>(new InfEngineBackendNode(l));
         }