forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ExperimentalDetectron* shape infer old-style (openvinotoolkit#1962)
* ExperimentalDetectron* shape infer old-style * nGraph reshape tests
- Loading branch information
Evgenya Stepyreva
authored and
Rom
committed
Aug 28, 2020
1 parent
6000589
commit 27904ee
Showing
8 changed files
with
701 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ce-engine/src/legacy_api/src/shape_infer/built-in/ie_detectionoutput_onnx_shape_infer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (C) 2018-2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "ie_built_in_impl.hpp" | ||
|
||
namespace InferenceEngine { | ||
namespace ShapeInfer { | ||
|
||
/** | ||
*@brief Implementation of Shape inference for ExperimentalDetectronDetectionOutput layer | ||
*/ | ||
class ExperimentalDetectronDetectionOutputShapeProp : public BuiltInShapeInferImpl { | ||
protected: | ||
const int ROIS = 0; | ||
const int FEATMAPS = 1; | ||
|
||
public: | ||
explicit ExperimentalDetectronDetectionOutputShapeProp(const std::string& type): BuiltInShapeInferImpl(type) {} | ||
|
||
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 { | ||
LayerParams lp {}; | ||
CNNLayer cnnLayer(lp); | ||
cnnLayer.params = params; | ||
cnnLayer.type = _type; | ||
validate(&cnnLayer, inBlobs, params, blobs); | ||
|
||
auto rois_num = cnnLayer.GetParamAsUInt("max_detections_per_image"); | ||
outShapes.push_back({rois_num, 4}); | ||
|
||
auto num_outputs = cnnLayer.GetParamAsUInt("num_outputs"); | ||
if (num_outputs > 3) THROW_IE_EXCEPTION << "Incorrect value num_outputs: " << num_outputs; | ||
if (num_outputs >= 2) { | ||
outShapes.push_back({rois_num}); | ||
} | ||
if (num_outputs == 3) { | ||
outShapes.push_back({rois_num}); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace ShapeInfer | ||
} // namespace InferenceEngine |
57 changes: 57 additions & 0 deletions
57
...engine/src/legacy_api/src/shape_infer/built-in/ie_priorgridgenerator_onnx_shape_infer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (C) 2018-2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <ie_layers.h> | ||
|
||
#include <description_buffer.hpp> | ||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "ie_built_in_impl.hpp" | ||
|
||
namespace InferenceEngine { | ||
namespace ShapeInfer { | ||
|
||
/** | ||
*@brief Implementation of Shape inference for ExperimentalDetectronPriorGridGenerator layer | ||
*/ | ||
class ExperimentalDetectronPriorGridGeneratorShapeProp : public BuiltInShapeInferImpl { | ||
protected: | ||
const int PRIORS = 0; | ||
const int FEATMAP = 1; | ||
const int H = 2; | ||
const int W = 3; | ||
|
||
public: | ||
explicit ExperimentalDetectronPriorGridGeneratorShapeProp(const std::string& type): BuiltInShapeInferImpl(type) {} | ||
|
||
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 { | ||
LayerParams lp {}; | ||
CNNLayer cnnLayer(lp); | ||
cnnLayer.params = params; | ||
cnnLayer.type = _type; | ||
validate(&cnnLayer, inBlobs, params, blobs); | ||
|
||
const auto& priors_shape = inShapes.at(PRIORS); | ||
const auto priors_num = priors_shape.at(0); | ||
const auto& featmap_shape = inShapes.at(FEATMAP); | ||
const auto grid_height = featmap_shape.at(H); | ||
const auto grid_width = featmap_shape.at(W); | ||
|
||
const bool flatten = cnnLayer.GetParamAsBool("flatten", true); | ||
if (flatten) { | ||
outShapes.push_back({grid_height * grid_width * priors_num, 4}); | ||
} else { | ||
outShapes.push_back({grid_height, grid_width, priors_num, 4}); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace ShapeInfer | ||
} // namespace InferenceEngine |
40 changes: 40 additions & 0 deletions
40
inference-engine/src/legacy_api/src/shape_infer/built-in/ie_proposal_onnx_shape_infer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (C) 2018-2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "ie_built_in_impl.hpp" | ||
|
||
namespace InferenceEngine { | ||
namespace ShapeInfer { | ||
|
||
/** | ||
*@brief Implementation of Shape inference for ExperimentalDetectronGenerateProposalsSingleImage layer | ||
*/ | ||
class ExperimentalDetectronGenerateProposalsSingleImageShapeProp : public BuiltInShapeInferImpl { | ||
public: | ||
explicit ExperimentalDetectronGenerateProposalsSingleImageShapeProp(const std::string& type): BuiltInShapeInferImpl(type) {} | ||
|
||
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 { | ||
LayerParams lp {}; | ||
CNNLayer cnnLayer(lp); | ||
cnnLayer.params = params; | ||
cnnLayer.type = _type; | ||
validate(&cnnLayer, inBlobs, params, blobs); | ||
|
||
size_t post_nms_count = static_cast<size_t>(cnnLayer.GetParamAsInt("post_nms_count")); | ||
|
||
outShapes.push_back({post_nms_count, 4}); | ||
outShapes.push_back({post_nms_count, }); | ||
} | ||
}; | ||
|
||
} // namespace ShapeInfer | ||
} // namespace InferenceEngine |
50 changes: 50 additions & 0 deletions
50
...ngine/src/legacy_api/src/shape_infer/built-in/ie_roifeatureextractor_onnx_shape_infer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (C) 2018-2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "ie_built_in_impl.hpp" | ||
|
||
namespace InferenceEngine { | ||
namespace ShapeInfer { | ||
|
||
/** | ||
*@brief Implementation of Shape inference for ExperimentalDetectronROIFeatureExtractor layer | ||
*/ | ||
class ExperimentalDetectronROIFeatureExtractorShapeProp : public BuiltInShapeInferImpl { | ||
protected: | ||
const int ROIS = 0; | ||
const int FEATMAPS = 1; | ||
|
||
public: | ||
explicit ExperimentalDetectronROIFeatureExtractorShapeProp(const std::string& type): BuiltInShapeInferImpl(type) {} | ||
|
||
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 { | ||
LayerParams lp {}; | ||
CNNLayer cnnLayer(lp); | ||
cnnLayer.params = params; | ||
cnnLayer.type = _type; | ||
validate(&cnnLayer, inBlobs, params, blobs); | ||
|
||
size_t rois_num = inShapes.at(ROIS).at(0); | ||
size_t channels_num = inShapes.at(FEATMAPS).at(1); | ||
size_t output_size = static_cast<size_t>(cnnLayer.GetParamAsInt("output_size")); | ||
outShapes.push_back({rois_num, channels_num, output_size, output_size}); | ||
|
||
auto num_outputs = cnnLayer.GetParamAsUInt("num_outputs"); | ||
if (num_outputs > 2) THROW_IE_EXCEPTION << "Incorrect value num_outputs: " << num_outputs; | ||
if (num_outputs == 2) { | ||
outShapes.push_back({rois_num, 4}); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace ShapeInfer | ||
} // namespace InferenceEngine |
41 changes: 41 additions & 0 deletions
41
inference-engine/src/legacy_api/src/shape_infer/built-in/ie_topkrois_onnx_shape_infer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (C) 2018-2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <ie_layers.h> | ||
|
||
#include <description_buffer.hpp> | ||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "ie_built_in_impl.hpp" | ||
|
||
namespace InferenceEngine { | ||
namespace ShapeInfer { | ||
|
||
/** | ||
*@brief Implementation of Shape inference for ExperimentalDetectronTopKROIs layer | ||
*/ | ||
class ExperimentalDetectronTopKROIsShapeProp : public BuiltInShapeInferImpl { | ||
public: | ||
explicit ExperimentalDetectronTopKROIsShapeProp(const std::string& type): BuiltInShapeInferImpl(type) {} | ||
|
||
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 { | ||
LayerParams lp {}; | ||
CNNLayer cnnLayer(lp); | ||
cnnLayer.params = params; | ||
cnnLayer.type = _type; | ||
validate(&cnnLayer, inBlobs, params, blobs); | ||
|
||
const bool max_rois = cnnLayer.GetParamAsInt("max_rois"); | ||
outShapes.push_back({max_rois, 4}); | ||
} | ||
}; | ||
|
||
} // namespace ShapeInfer | ||
} // namespace InferenceEngine |
Oops, something went wrong.