1 // Copyright (C) 2018 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
7 #include <description_buffer.hpp>
8 #include "ie_built_in_impl.hpp"
15 namespace InferenceEngine {
16 namespace ShapeInfer {
19 *@brief Implementation of Shape inference for ArgMax layer
21 class ArgMaxShapeProp : public BuiltInShapeInferImpl {
23 explicit ArgMaxShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
25 void inferShapesImpl(const std::vector<SizeVector>& inShapes,
26 const std::map<std::string, std::string>& params,
27 const std::map<std::string, Blob::Ptr>& blobs,
28 std::vector<SizeVector>& outShapes) override {
30 CNNLayer cnnLayer(lp);
31 cnnLayer.params = params;
32 cnnLayer.type = _type;
33 validate(&cnnLayer, inShapes, params, blobs);
34 auto out_max_val = static_cast<size_t>(cnnLayer.GetParamAsInt("out_max_val", 0));
35 auto top_k = static_cast<size_t>(cnnLayer.GetParamAsInt("top_k", 0));
37 bool isValidAxis = true;
39 axis = cnnLayer.GetParamAsInt("axis");
40 } catch(const details::InferenceEngineException &exception) {
44 auto firstInputShape = inShapes[0];
45 size_t num_top_axes = firstInputShape.size();
46 if (num_top_axes < 3) num_top_axes = 3;
48 SizeVector outputShape(num_top_axes, 1);
51 axis = static_cast<int>(firstInputShape.size() + axis);
53 outputShape = firstInputShape;
54 outputShape[axis] = top_k;
56 outputShape[0] = firstInputShape[0];
57 outputShape[2] = top_k;
62 outShapes.push_back(outputShape);
66 } // namespace ShapeInfer
67 } // namespace InferenceEngine