1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
7 #include "ie_built_in_impl.hpp"
13 namespace InferenceEngine {
14 namespace ShapeInfer {
17 *@brief Implementation of Shape inference for Gather layer
19 class GatherShapeProp : public BuiltInShapeInferImpl {
21 explicit GatherShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
23 void inferShapesImpl(const std::vector<Blob::CPtr>& inBlobs,
24 const std::map<std::string, std::string>& params,
25 const std::map<std::string, Blob::Ptr>& blobs,
26 std::vector<SizeVector>& outShapes) override {
28 GatherLayer gatherLayer(lp);
29 gatherLayer.params = params;
30 gatherLayer.type = _type;
31 validate(&gatherLayer, inBlobs, params, blobs);
33 int axis = gatherLayer.axis;
35 axis += inShapes[0].size();
38 outShapes[0].resize(inShapes[0].size() + inShapes[1].size() - 1);
39 for (int i = 0; i < axis; i++)
40 outShapes[0][i] = inShapes[0][i];
42 for (size_t i = 0; i < inShapes[1].size(); i++)
43 outShapes[0][i + axis] = inShapes[1][i];
45 for (size_t i = axis + 1; i < inShapes[0].size(); i++)
46 outShapes[0][i + inShapes[1].size() - 1] = inShapes[0][i];
50 } // namespace ShapeInfer
51 } // namespace InferenceEngine