1 // Copyright (C) 2018-2019 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 RegionYolo layer
21 class RegionYoloShapeProp : public BuiltInShapeInferImpl {
23 explicit RegionYoloShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
25 void inferShapesImpl(const std::vector<Blob::CPtr>& inBlobs,
26 const std::map<std::string, std::string>& params,
27 const std::map<std::string, Blob::Ptr>& blobs,
28 std::vector<SizeVector>& outShapes) override {
31 layer.params = params;
36 std::vector<int> mask;
37 classes = layer.GetParamAsInt("classes", 1);
38 coords = layer.GetParamAsInt("coords", 1);
39 num = layer.GetParamAsInt("num", 1);
40 do_softmax = static_cast<bool>(layer.GetParamAsInt("do_softmax", 1));
41 mask = layer.GetParamAsInts("mask", {});
42 unsigned int axis = layer.GetParamAsUInt("axis", 1);
43 int end_axis = layer.GetParamAsInt("end_axis", 1);
44 if (end_axis < 0) end_axis += inShapes[0].size();
49 for (size_t i = 0; i < axis; i++) {
50 outShape.push_back(inShapes[0][i]);
52 for (size_t i = axis; i < end_axis + 1; i++) {
53 flat_dim *= inShapes[0][i];
55 outShape.push_back(flat_dim);
56 for (size_t i = end_axis + 1; i < inShapes[0].size(); i++) {
57 outShape.push_back(inShapes[0][i]);
60 outShape = {inShapes[0][0], (classes + coords + 1) * mask.size(), inShapes[0][2], inShapes[0][3]};
62 outShapes.push_back({outShape});
66 } // namespace ShapeInfer
67 } // namespace InferenceEngine