1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
7 #include "ie_built_in_impl.hpp"
14 namespace InferenceEngine {
15 namespace ShapeInfer {
18 *@brief Implementation of Shape inference for EltWise layer
20 class EltWiseShapeProp : public BuiltInShapeInferImpl {
22 explicit EltWiseShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
24 void inferShapesImpl(const std::vector<Blob::CPtr>& inBlobs,
25 const std::map<std::string, std::string>& params,
26 const std::map<std::string, Blob::Ptr>& blobs,
27 std::vector<SizeVector>& outShapes) override {
29 EltwiseLayer eltwiseLayer(lp);
30 eltwiseLayer.params = params;
31 eltwiseLayer.type = _type;
32 validate(&eltwiseLayer, inBlobs, params, blobs);
34 if (inShapes.size() == 1) {
35 outShapes.push_back(inShapes[0]);
37 SizeVector outShape((std::max)(inShapes[0], inShapes[1]));
38 for (size_t ind = 0; ind < outShape.size(); ++ind) {
39 if (ind < inShapes[0].size() && ind < inShapes[1].size()) {
40 outShape[ind] = (std::max)(inShapes[0][ind], inShapes[1][ind]);
41 } else if (ind >= inShapes[0].size()) {
42 outShape[ind] = inShapes[1][ind];
44 outShape[ind] = inShapes[0][ind];
47 outShapes.push_back(outShape);
52 } // namespace ShapeInfer
53 } // namespace InferenceEngine