Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / shape_infer / built-in / ie_eltwise_shape_infer.hpp
index ce7248c..652f8ab 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -9,6 +9,7 @@
 #include <memory>
 #include <string>
 #include <vector>
+#include <algorithm>
 
 namespace InferenceEngine {
 namespace ShapeInfer {
@@ -20,7 +21,7 @@ class EltWiseShapeProp : public BuiltInShapeInferImpl {
 public:
     explicit EltWiseShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
 
-    void inferShapesImpl(const std::vector<SizeVector>& inShapes,
+    void inferShapesImpl(const std::vector<Blob::CPtr>& inBlobs,
                          const std::map<std::string, std::string>& params,
                          const std::map<std::string, Blob::Ptr>& blobs,
                          std::vector<SizeVector>& outShapes) override {
@@ -28,8 +29,23 @@ public:
         EltwiseLayer eltwiseLayer(lp);
         eltwiseLayer.params = params;
         eltwiseLayer.type = _type;
-        validate(&eltwiseLayer, inShapes, params, blobs);
-        outShapes.push_back(inShapes[0]);
+        validate(&eltwiseLayer, inBlobs, params, blobs);
+
+        if (inShapes.size() == 1) {
+            outShapes.push_back(inShapes[0]);
+        } else {
+            SizeVector outShape((std::max)(inShapes[0], inShapes[1]));
+            for (size_t ind = 0; ind < outShape.size(); ++ind) {
+                if (ind < inShapes[0].size() && ind < inShapes[1].size()) {
+                    outShape[ind] = (std::max)(inShapes[0][ind], inShapes[1][ind]);
+                } else if (ind >= inShapes[0].size()) {
+                    outShape[ind] = inShapes[1][ind];
+                } else {
+                    outShape[ind] = inShapes[0][ind];
+                }
+            }
+            outShapes.push_back(outShape);
+        }
     }
 };