diff --git a/docs/template_plugin/tests/functional/op_reference/deformable_psroi_pooling.cpp b/docs/template_plugin/tests/functional/op_reference/deformable_psroi_pooling.cpp new file mode 100644 index 00000000000..5a3cc9f6410 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/deformable_psroi_pooling.cpp @@ -0,0 +1,354 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include "openvino/op/psroi_pooling.hpp" +#include "base_reference_test.hpp" +#include "openvino/opsets/opset1.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct DeformablePSROIPoolingParams { + template + DeformablePSROIPoolingParams(const size_t batch_in, const size_t channel_in, const size_t height_in, const size_t width_in, + const float spatial_scale, const size_t group_size, const int64_t spatial_bins_x, const int64_t spatial_bins_y, + const float trans_std, const int64_t part_size, const size_t rois_dim, + const ov::element::Type& iType, const bool is_input_generation_iota, const float inputValue, + const std::vector& roisValues, const std::vector& oValues, + const std::string& test_name = "", const std::string& mode = "bilinear_deformable") + : groupSize(group_size), + spatialBinsX(spatial_bins_x), + spatialBinsY(spatial_bins_y), + spatialScale(spatial_scale), + transStd(trans_std), + partSize(part_size), + mode(mode), + inputType(iType), + roisType(iType), + outType(iType), + roisData(CreateTensor(iType, roisValues)), + testcaseName(test_name) { + outputDim = (channel_in / (group_size * group_size)) - (static_cast(channel_in / (group_size * group_size)) % 2); + inputShape = Shape{batch_in, channel_in, height_in, width_in}; + roisShape = Shape{rois_dim, 5}; + + std::vector inputValues(shape_size(inputShape.get_shape())); + if (is_input_generation_iota) + std::iota(inputValues.begin(), inputValues.end(), inputValue); + else + std::fill(inputValues.begin(), inputValues.end(), inputValue); + inputData = CreateTensor(iType, inputValues); + + if (oValues.size() > 1) { + refData = CreateTensor(iType, oValues); + } else { + Shape output_shape{rois_dim, outputDim, group_size, group_size}; + std::vector expected_output_values(shape_size(output_shape)); + std::fill(expected_output_values.begin(), expected_output_values.end(), oValues[0]); + refData = CreateTensor(iType, expected_output_values); + } + } + + template + DeformablePSROIPoolingParams(const size_t batch_in, const size_t channel_in, const size_t height_in, const size_t width_in, + const float spatial_scale, const size_t group_size, const int64_t spatial_bins_x, const int64_t spatial_bins_y, + const float trans_std, const int64_t part_size, const size_t rois_dim, + const ov::element::Type& iType, const bool is_input_generation_iota, const float inputValue, const float offsetValue, + const std::vector& roisValues, const std::vector& oValues, + const std::string& test_name = "", const std::string& mode = "bilinear_deformable") + : groupSize(group_size), + spatialBinsX(spatial_bins_x), + spatialBinsY(spatial_bins_y), + spatialScale(spatial_scale), + transStd(trans_std), + partSize(part_size), + mode(mode), + inputType(iType), + roisType(iType), + offsetsType(iType), + outType(iType), + roisData(CreateTensor(iType, roisValues)), + testcaseName(test_name) { + outputDim = (channel_in / (group_size * group_size)) - ((channel_in / (group_size * group_size)) % 2); + inputShape = Shape{batch_in, channel_in, height_in, width_in}; + roisShape = Shape{rois_dim, 5}; + offsetsShape = Shape{rois_dim, 2, group_size, group_size}; + + std::vector inputValues(shape_size(inputShape.get_shape())); + if (is_input_generation_iota) + std::iota(inputValues.begin(), inputValues.end(), inputValue); + else + std::fill(inputValues.begin(), inputValues.end(), inputValue); + inputData = CreateTensor(iType, inputValues); + + std::vector offsetsValues(shape_size(offsetsShape.get_shape())); + std::fill(offsetsValues.begin(), offsetsValues.end(), offsetValue); + offsetsData = CreateTensor(iType, offsetsValues); + + if (oValues.size() > 1) { + refData = CreateTensor(iType, oValues); + } else { + Shape output_shape{rois_dim, outputDim, group_size, group_size}; + std::vector expected_output_values(shape_size(output_shape)); + std::fill(expected_output_values.begin(), expected_output_values.end(), oValues[0]); + refData = CreateTensor(iType, expected_output_values); + } + } + + size_t groupSize; + int64_t spatialBinsX; + int64_t spatialBinsY; + size_t outputDim; + float spatialScale; + float transStd; + int64_t partSize; + + std::string mode; + ov::PartialShape inputShape; + ov::PartialShape roisShape; + ov::PartialShape offsetsShape; + ov::element::Type inputType; + ov::element::Type roisType; + ov::element::Type offsetsType; + ov::element::Type outType; + ov::runtime::Tensor inputData; + ov::runtime::Tensor roisData; + ov::runtime::Tensor offsetsData; + ov::runtime::Tensor refData; + std::string testcaseName; +}; + +class ReferenceDeformablePSROIPoolingLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + if (params.offsetsShape.size() != 0) + inputData = {params.inputData, params.roisData, params.offsetsData}; + else + inputData = {params.inputData, params.roisData}; + refOutData = {params.refData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "inputShape=" << param.inputShape << "_"; + result << "roiShape=" << param.roisShape << "_"; + if (param.offsetsShape.size() != 0) + result << "offsetsShape=" << param.offsetsShape << "_"; + result << "outputDim=" << param.outputDim << "_"; + result << "iType=" << param.inputType << "_"; + if (param.testcaseName != "") { + result << "mode=" << param.spatialScale << "_"; + result << param.testcaseName; + } else { + result << "mode=" << param.spatialScale; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const DeformablePSROIPoolingParams& params) { + const auto input = std::make_shared(params.inputType, params.inputShape); + const auto rois = std::make_shared(params.roisType, params.roisShape); + if (params.offsetsShape.size() != 0) { + const auto offsets = std::make_shared(params.offsetsType, params.offsetsShape); + const auto DeformablePSROIPooling = std::make_shared(input, + rois, + offsets, + params.outputDim, + params.spatialScale, + params.groupSize, + params.mode, + params.spatialBinsX, + params.spatialBinsY, + params.transStd, + params.partSize); + return std::make_shared(NodeVector {DeformablePSROIPooling}, ParameterVector {input, rois, offsets}); + } else { + const auto DeformablePSROIPooling = std::make_shared(input, + rois, + params.outputDim, + params.spatialScale, + params.groupSize, + params.mode, + params.spatialBinsX, + params.spatialBinsY, + params.transStd, + params.partSize); + return std::make_shared(NodeVector {DeformablePSROIPooling}, ParameterVector {input, rois}); + } + } +}; + +TEST_P(ReferenceDeformablePSROIPoolingLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateDeformablePSROIPoolingFloatParams() { + using T = typename element_type_traits::value_type; + + std::vector deformablePSROIPoolingParams { + DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in + 0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 1, 2, // trans_std, part_size, rois_dim + IN_ET, true, 0, 0.0, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 2, 4, 6, + 0, 0, 3, 10, 4}, + std::vector{ + // First ROI + 0, 4, 8, 12, + 16, 20, 24, 28, + 32, 36, 40, 44, + 48, 52, 56, 60, + // Second ROI + 0, 4, 8, 12, + 16, 20, 24, 28, + 32, 36, 40, 44, + 48, 52, 56, 60}, + "offset_00"), + DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in + 0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 1, 2, // trans_std, part_size, rois_dim + IN_ET, true, 0, 0.2, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 2, 4, 6, + 0, 0, 3, 10, 4}, + std::vector{ + // First ROI + 0, 4, 8, 12, + 16, 20, 24, 28, + 32, 36, 40, 44, + 48, 52, 56, 60, + // Second ROI + 0, 4, 8, 12, + 16, 20, 24, 28, + 32, 36, 40, 44, + 48, 52, 56, 60}, + "offset_0p2"), + DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in + 0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 1, 2, // trans_std, part_size, rois_dim + IN_ET, true, 0, 0.5, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 2, 4, 6, + 0, 5, 3, 10, 4}, + std::vector{ + // First ROI + 0, 4, 8, 12, + 16, 20, 24, 28, + 32, 36, 40, 44, + 48, 52, 56, 60, + // Second ROI + 0, 4.1875, 8, 12.1875, + 16, 20.1875, 24, 28.1875, + 32, 36.1875, 40, 44.1875, + 48, 52.1875, 56, 60.1875}, + "offset_0p5"), + DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in + 0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 1, 2, // trans_std, part_size, rois_dim + IN_ET, true, 0, 0, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 10, 10, 20, 20, + 0, 100, 100, 200, 200}, + std::vector{ + // First ROI + 0.375, 4.71875, 9.0625, 13.40625, 16.375, 20.71875, 25.0625, 29.40625, + 32.375, 36.71875, 41.0625, 45.40625, 48.375, 52.71875, 57.0625, 61.40625, + // Second ROI + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0}, + "roi_oversize"), + DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in + 1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 2, 1, // trans_std, part_size, rois_dim + IN_ET, true, 0, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 1, 2, 2}, + std::vector{2.0, 12.0, 23.0, 33.0, 38.0, 48.0, 59.0, 69.0}, + "no_offset_input"), + DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in + 1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 2, 1, // trans_std, part_size, rois_dim, + IN_ET, true, 0, 0, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 1, 2, 2}, + std::vector{2.0, 12.0, 23.0, 33.0, 38.0, 48.0, 59.0, 69.0}, + "offset_zero"), + DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in + 1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 2, 1, // trans_std, part_size, rois_dim, + IN_ET, true, 0, 0.1, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 1, 2, 2}, + std::vector{2.8, 12.8, 23.8, 33.8, 38.8, 48.8, 59.8, 69.8}, + "offset_01"), + DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in + 1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 2, 1, // trans_std, part_size, rois_dim, + IN_ET, true, 0, 0.5, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 1, 2, 2}, + std::vector{6., 15.5, 25.5, 35., 42., 51.5, 61.5, 71.}, + "offset_05"), + DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in + 0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 1, 1, // trans_std, part_size, rois_dim, + IN_ET, false, 0.1, 0.1, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 10, 10, 10, 10}, + std::vector{0.1, 0.1, 0.1, 0.1, + 0.1, 0.1, 0.1, 0.1, + 0.1, 0.1, 0.1, 0.1, + 0.1, 0.1, 0.1, 0.1}, + "single_value"), + DeformablePSROIPoolingParams(1, 1024, 63, 38, // batch_in, channel_in, height_in, width_in + 0.0625, 3, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y + 1, 1, 2, // trans_std, part_size, rois_dim, + IN_ET, false, 0.1, 0.0, //inputType, is_input_generation_iota, inputValue, offsetValue + std::vector{ + // input_batch_id, x1, y1, x2, y2 + 0, 1, 2, 4, 6, + 0, 0, 3, 10, 4}, + std::vector{0.1}, + "single_value_big_shape") + }; + return deformablePSROIPoolingParams; +} + +std::vector generateDeformablePSROIPoolingCombinedParams() { + const std::vector> deformablePSROIPoolingTypeParams { + generateDeformablePSROIPoolingFloatParams(), + generateDeformablePSROIPoolingFloatParams(), + generateDeformablePSROIPoolingFloatParams(), + generateDeformablePSROIPoolingFloatParams() + }; + std::vector combinedParams; + + for (const auto& params : deformablePSROIPoolingTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_DeformablePSROIPooling_With_Hardcoded_Refs, ReferenceDeformablePSROIPoolingLayerTest, + testing::ValuesIn(generateDeformablePSROIPoolingCombinedParams()), ReferenceDeformablePSROIPoolingLayerTest::getTestCaseName); + +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/proposal.cpp b/docs/template_plugin/tests/functional/op_reference/proposal.cpp new file mode 100644 index 00000000000..b18fcd63ab2 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/proposal.cpp @@ -0,0 +1,483 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/op/proposal.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct ProposalV1Params { + template + ProposalV1Params(const float iou_threshold, + const int min_bbox_size, + const int feature_stride, + const int pre_nms_topn, + const int post_nms_topn, + const size_t image_shape_num, + const size_t image_h, + const size_t image_w, + const size_t image_z, + const std::vector& ratios, + const std::vector& scales, + const size_t batch_size, + const size_t anchor_num, + const size_t feat_map_height, + const size_t feat_map_width, + const ov::element::Type& iType, + const std::vector& clsScoreValues, + const std::vector& bboxPredValues, + const std::vector& proposalValues, + const std::string& test_name = "") + : inType(iType), + outType(iType), + clsScoreData(CreateTensor(iType, clsScoreValues)), + bboxPredData(CreateTensor(iType, bboxPredValues)), + refProposalData(CreateTensor(iType, proposalValues)), + testcaseName(test_name) { + clsScoreShape = Shape{batch_size, anchor_num * 2, feat_map_height, feat_map_width}; + bboxPredShape = Shape{batch_size, anchor_num * 4, feat_map_height, feat_map_width}; + imageShapeShape = Shape{image_shape_num}; + + attrs.base_size = min_bbox_size; + attrs.min_size = min_bbox_size; + attrs.pre_nms_topn = pre_nms_topn; + attrs.post_nms_topn = post_nms_topn; + attrs.nms_thresh = iou_threshold; + attrs.feat_stride = feature_stride; + attrs.min_size = min_bbox_size; + attrs.ratio = ratios; + attrs.scale = scales; + attrs.clip_before_nms = true; + attrs.clip_after_nms = false; + attrs.normalize = false; + attrs.box_size_scale = 1.0f; + attrs.box_coordinate_scale = 1.0f; + attrs.framework = ""; + attrs.infer_probs = false; + + std::vector inputShapeValues; + inputShapeValues.push_back(image_h); + inputShapeValues.push_back(image_w); + inputShapeValues.push_back(image_z); + imageShapeData = CreateTensor(iType, inputShapeValues); + } + + ov::op::v0::Proposal::Attributes attrs; + ov::PartialShape clsScoreShape; + ov::PartialShape bboxPredShape; + ov::PartialShape imageShapeShape; + ov::element::Type inType; + ov::element::Type outType; + ov::runtime::Tensor clsScoreData; + ov::runtime::Tensor bboxPredData; + ov::runtime::Tensor imageShapeData; + ov::runtime::Tensor refProposalData; + std::string testcaseName; +}; + +struct ProposalV4Params { + template + ProposalV4Params(const float iou_threshold, + const int min_bbox_size, + const int feature_stride, + const int pre_nms_topn, + const int post_nms_topn, + const size_t image_shape_num, + const size_t image_h, + const size_t image_w, + const size_t image_z, + const std::vector& ratios, + const std::vector& scales, + const size_t batch_size, + const size_t anchor_num, + const size_t feat_map_height, + const size_t feat_map_width, + const ov::element::Type& iType, + const std::vector& clsScoreValues, + const std::vector& bboxPredValues, + const std::vector& proposalValues, + const std::vector& probsValues, + const std::string& test_name = "") + : inType(iType), + outType(iType), + clsScoreData(CreateTensor(iType, clsScoreValues)), + bboxPredData(CreateTensor(iType, bboxPredValues)), + refProposalData(CreateTensor(iType, proposalValues)), + refProbsData(CreateTensor(iType, probsValues)), + testcaseName(test_name) { + clsScoreShape = Shape{batch_size, anchor_num * 2, feat_map_height, feat_map_width}; + bboxPredShape = Shape{batch_size, anchor_num * 4, feat_map_height, feat_map_width}; + imageShapeShape = Shape{image_shape_num}; + + attrs.base_size = min_bbox_size; + attrs.min_size = min_bbox_size; + attrs.pre_nms_topn = pre_nms_topn; + attrs.post_nms_topn = post_nms_topn; + attrs.nms_thresh = iou_threshold; + attrs.feat_stride = feature_stride; + attrs.min_size = min_bbox_size; + attrs.ratio = ratios; + attrs.scale = scales; + attrs.clip_before_nms = true; + attrs.clip_after_nms = false; + attrs.normalize = false; + attrs.box_size_scale = 1.0f; + attrs.box_coordinate_scale = 1.0f; + attrs.framework = ""; + attrs.infer_probs = true; + + std::vector inputShapeValues; + inputShapeValues.push_back(image_h); + inputShapeValues.push_back(image_w); + inputShapeValues.push_back(image_z); + imageShapeData = CreateTensor(iType, inputShapeValues); + } + + ov::op::v4::Proposal::Attributes attrs; + ov::PartialShape clsScoreShape; + ov::PartialShape bboxPredShape; + ov::PartialShape imageShapeShape; + ov::element::Type inType; + ov::element::Type outType; + ov::runtime::Tensor clsScoreData; + ov::runtime::Tensor bboxPredData; + ov::runtime::Tensor imageShapeData; + ov::runtime::Tensor refProposalData; + ov::runtime::Tensor refProbsData; + std::string testcaseName; +}; + +class ReferenceProposalV1LayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.clsScoreData, params.bboxPredData, params.imageShapeData}; + refOutData = {params.refProposalData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "clsScoreShape=" << param.clsScoreShape << "_"; + result << "bboxPredShape=" << param.bboxPredShape << "_"; + result << "imageShapeShape=" << param.imageShapeShape << "_"; + result << "iType=" << param.inType << "_"; + if (param.testcaseName != "") { + result << "oType=" << param.outType << "_"; + result << param.testcaseName; + } else { + result << "oType=" << param.outType << "_"; + } + + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const ProposalV1Params& params) { + const auto class_probs_param = std::make_shared(params.inType, params.clsScoreShape); + const auto bbox_deltas_param = std::make_shared(params.inType, params.bboxPredShape); + const auto image_shape_param = std::make_shared(params.inType, params.imageShapeShape); + const auto Proposal = std::make_shared(class_probs_param, bbox_deltas_param, image_shape_param, params.attrs); + return std::make_shared(NodeVector {Proposal}, ParameterVector {class_probs_param, bbox_deltas_param, image_shape_param}); + } +}; + +class ReferenceProposalV4LayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.clsScoreData, params.bboxPredData, params.imageShapeData}; + refOutData = {params.refProposalData, params.refProbsData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "clsScoreShape=" << param.clsScoreShape << "_"; + result << "bboxPredShape=" << param.bboxPredShape << "_"; + result << "imageShapeShape=" << param.imageShapeShape << "_"; + result << "iType=" << param.inType << "_"; + if (param.testcaseName != "") { + result << "oType=" << param.outType << "_"; + result << param.testcaseName; + } else { + result << "oType=" << param.outType << "_"; + } + + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const ProposalV4Params& params) { + const auto class_probs_param = std::make_shared(params.inType, params.clsScoreShape); + const auto bbox_deltas_param = std::make_shared(params.inType, params.bboxPredShape); + const auto image_shape_param = std::make_shared(params.inType, params.imageShapeShape); + const auto Proposal = std::make_shared(class_probs_param, bbox_deltas_param, image_shape_param, params.attrs); + return std::make_shared(Proposal->outputs(), ParameterVector {class_probs_param, bbox_deltas_param, image_shape_param}); + } +}; + +TEST_P(ReferenceProposalV1LayerTest, CompareWithRefs) { + Exec(); +} + +TEST_P(ReferenceProposalV4LayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateProposalV1Params() { + using T = typename element_type_traits::value_type; + + std::vector proposalV1Params { + ProposalV1Params(0.7f, 16, 16, 6000, 10, // iou_threshold, min_nnox_size, feature_stride,pre_nms_topn, post_nms_topn + 3, 210, 350, 1, // image_shape_num, image_h, image_w, image_z + {0.5f}, // ratios + {32.0f}, //scales + 1, 1, 10, 10, // batch_size, anchor_num, feat_map_height, feat_map_width + IN_ET, + std::vector{ + 0.000240f, 0.003802f, 0.111432f, 0.000503f, 0.007887f, 0.144701f, 0.399074f, 0.004680f, // 0 + 0.139741f, 0.002386f, 0.030003f, 0.276552f, 0.000267f, 0.022971f, 0.287953f, 0.050235f, // 8 + 0.002580f, 0.206311f, 0.000146f, 0.009656f, 0.175462f, 0.000147f, 0.014718f, 0.272348f, // 16 + 0.065199f, 0.003286f, 0.185335f, 0.003720f, 0.025932f, 0.251401f, 0.001465f, 0.090447f, // 24 + 0.488469f, 0.092259f, 0.019306f, 0.379091f, 0.005311f, 0.010369f, 0.087615f, 0.042003f, // 32 + 0.073871f, 0.416763f, 0.044282f, 0.069776f, 0.313032f, 0.000457f, 0.017346f, 0.089762f, // 40 + 0.000820f, 0.103986f, 0.367993f, 0.026315f, 0.035701f, 0.299252f, 0.000135f, 0.017825f, // 48 + 0.150119f, 0.000076f, 0.050511f, 0.269601f, 0.026680f, 0.003541f, 0.189765f, 0.000051f, // 56 + 0.004315f, 0.193150f, 0.000032f, 0.007254f, 0.185557f, 0.051526f, 0.000657f, 0.117579f, // 64 + 0.000115f, 0.010179f, 0.293187f, 0.000025f, 0.006505f, 0.175345f, 0.032587f, 0.000469f, // 72 + 0.098443f, 0.000121f, 0.009600f, 0.322782f, 0.000032f, 0.004543f, 0.166860f, 0.044911f, // 80 + 0.000187f, 0.102691f, 0.000242f, 0.005502f, 0.107865f, 0.000191f, 0.005336f, 0.086893f, // 88 + 0.078422f, 0.000345f, 0.079096f, 0.000281f, 0.016388f, 0.214072f, 0.000107f, 0.012027f, // 96 + 0.192754f, 0.049531f, 0.000386f, 0.149893f, 0.000374f, 0.016965f, 0.204781f, 0.000163f, // 104 + 0.016272f, 0.215277f, 0.032298f, 0.000857f, 0.133426f, 0.000614f, 0.020215f, 0.165789f, // 112 + 0.000225f, 0.036951f, 0.262195f, 0.087675f, 0.004596f, 0.147764f, 0.000219f, 0.010502f, // 120 + 0.163394f, 0.000152f, 0.023116f, 0.241702f, 0.081800f, 0.002197f, 0.146637f, 0.000193f, // 128 + 0.012017f, 0.133497f, 0.000375f, 0.028605f, 0.309179f, 0.065962f, 0.005508f, 0.155530f, // 136 + 0.000186f, 0.004540f, 0.079319f, 0.000799f, 0.031003f, 0.303045f, 0.051473f, 0.017770f, // 144 + 0.206188f, 0.000202f, 0.004291f, 0.061095f, 0.001109f, 0.018094f, 0.156639f, 0.026062f, // 152 + 0.005270f, 0.148651f, 0.000026f, 0.007300f, 0.096013f, 0.000383f, 0.022134f, 0.129511f, // 160 + 0.080882f, 0.003416f, 0.129922f, 0.000037f, 0.010040f, 0.130007f, 0.000116f, 0.014904f, // 168 + 0.171423f, 0.082893f, 0.000921f, 0.154976f, 0.000142f, 0.016552f, 0.209696f, 0.000227f, // 176 + 0.022418f, 0.228501f, 0.111712f, 0.001987f, 0.158164f, 0.001200f, 0.027049f, 0.308222f, // 184 + 0.001366f, 0.038146f, 0.287945f, 0.072526f, 0.016064f, 0.257895f, 0.000595f, 0.016962f, // 192 + }, + std::vector{ + 0.006756f, -0.055635f, 0.030843f, 0.007482f, 0.009056f, -0.041824f, 0.119722f, 0.168988f, 0.002822f, + 0.039733f, 0.109005f, 0.245152f, -0.013196f, -0.018222f, -0.170122f, -0.374904f, -0.005455f, -0.034059f, + -0.006787f, 0.072005f, -0.017933f, -0.007358f, 0.034149f, 0.123846f, 0.128319f, 0.016107f, -0.615487f, + -1.235094f, -0.024253f, -0.019406f, 0.134142f, 0.157853f, -0.021119f, 0.007383f, 0.089365f, 0.092854f, + 0.062491f, 0.002366f, 0.122464f, -0.003326f, 0.015468f, -0.034088f, 0.079009f, 0.075483f, 0.011972f, + 0.042427f, 0.106865f, 0.158754f, 0.071211f, -0.034009f, 0.007985f, -0.441477f, 0.009046f, -0.028515f, + 0.095372f, 0.119598f, -0.007553f, -0.0072f, 0.105072f, 0.084314f, 0.23268f, -0.02906f, -0.408454f, + -1.13439f, 0.016202f, -0.037859f, 0.130873f, 0.129652f, 0.002064f, -0.011969f, 0.171623f, 0.050218f, + 0.113831f, 0.028922f, 0.017785f, 0.059708f, 0.037658f, -0.011245f, 0.097197f, 0.137491f, 0.024218f, + 0.04739f, 0.091978f, 0.217333f, 0.088418f, -0.004662f, -0.095168f, -0.397928f, 0.02639f, -0.008501f, + 0.068487f, 0.108465f, 0.020069f, 0.018829f, 0.040206f, 0.068473f, 0.226458f, -0.072871f, -0.672384f, + -1.447558f, 0.039598f, 0.017471f, 0.187288f, 0.08409f, 0.017152f, -0.00516f, 0.183419f, 0.068469f, + 0.063944f, 0.160725f, -0.022493f, -0.132291f, 0.010542f, 0.036318f, 0.074042f, -0.013323f, 0.00808f, + 0.060365f, 0.120566f, 0.21866f, 0.046324f, 0.088741f, 0.029469f, -0.517183f, 0.00917f, 0.011915f, + 0.053674f, 0.140168f, 0.0033f, 0.022759f, -0.006196f, 0.063839f, 0.083726f, -0.088385f, -0.57208f, + -1.454211f, 0.020655f, 0.010788f, 0.134951f, 0.109709f, 0.015445f, -0.015363f, 0.109153f, 0.051209f, + 0.024297f, 0.139126f, -0.12358f, -0.127979f, 0.004587f, 0.004751f, 0.047292f, 0.027066f, 0.011003f, + 0.069887f, 0.117052f, 0.267419f, 0.039306f, 0.077584f, 0.02579f, -0.496149f, -0.005569f, 0.015494f, + -0.011662f, 0.105549f, -0.007015f, 0.031984f, -0.075742f, 0.0852f, 0.023886f, -0.053107f, -0.325533f, + -1.329066f, 0.004688f, 0.034501f, 0.089317f, 0.042463f, 0.004212f, -0.015128f, 0.00892f, 0.028266f, + 0.009997f, 0.157822f, 0.020116f, -0.142337f, 0.008199f, 0.046564f, 0.083014f, 0.046307f, 0.006771f, + 0.084997f, 0.141935f, 0.228339f, -0.020308f, 0.077745f, -0.018319f, -0.522311f, 0.010432f, 0.024641f, + 0.020571f, 0.097148f, 0.002064f, 0.035053f, -0.121995f, 0.012222f, -0.030779f, 0.100481f, -0.331737f, + -1.257669f, -0.013079f, 0.021227f, 0.159949f, 0.120097f, 0.005765f, -0.012335f, -0.005268f, 0.042067f, + -0.043972f, 0.102556f, 0.180494f, -0.084721f, -0.011962f, 0.031302f, 0.112511f, 0.027557f, -0.002085f, + 0.082978f, 0.149409f, 0.195091f, -0.033731f, 0.019861f, -0.064047f, -0.471328f, -0.004093f, 0.016803f, + 0.044635f, 0.058912f, -0.018735f, 0.035536f, -0.050373f, -0.002794f, -0.086705f, 0.038435f, -0.301466f, + -1.071246f, -0.028247f, 0.018984f, 0.254702f, 0.141142f, -0.017522f, 0.014843f, 0.079391f, 0.079662f, + -0.051204f, 0.048419f, 0.235604f, -0.185797f, -0.019569f, 0.02678f, 0.162507f, 0.046435f, -0.004606f, + 0.08806f, 0.18634f, 0.193957f, -0.024333f, -0.01298f, -0.17977f, -0.65881f, -0.003778f, 0.007418f, + 0.065439f, 0.104549f, -0.027706f, 0.03301f, 0.057492f, 0.032019f, -0.135337f, 0.000269f, -0.250203f, + -1.181688f, -0.027022f, -0.006755f, 0.206848f, 0.129268f, -0.003529f, 0.013445f, 0.181484f, 0.139955f, + -0.036587f, 0.065824f, 0.288751f, -0.110813f, -0.015578f, 0.044818f, 0.17756f, 0.006914f, 0.002329f, + 0.068982f, 0.189079f, 0.184253f, 0.00301f, -0.039168f, -0.010855f, -0.393254f, 0.000028f, 0.001906f, + 0.07217f, 0.063305f, -0.026144f, 0.028842f, 0.139149f, 0.023377f, 0.023362f, 0.023559f, -0.145386f, + -0.863572f, -0.015749f, -0.021364f, 0.172571f, 0.078393f, -0.037253f, 0.014978f, 0.221502f, 0.189111f, + -0.048956f, 0.085409f, 0.325399f, -0.058294f, -0.028495f, 0.021663f, 0.19392f, 0.02706f, 0.006908f, + 0.065751f, 0.176395f, 0.138375f, 0.012418f, -0.031228f, -0.008762f, -0.427345f, -0.013677f, -0.002429f, + 0.069655f, 0.019505f, -0.036763f, 0.022528f, 0.201062f, 0.022205f, 0.024528f, 0.06241f, -0.076237f, + -0.840695f, -0.007268f, -0.027865f, 0.211056f, 0.074744f, -0.053563f, 0.006863f, 0.301432f, 0.192879f, + -0.021944f, 0.100535f, 0.19031f, -0.133746f, -0.006151f, 0.023944f, 0.13561f, -0.03259f, 0.000618f, + 0.063736f, 0.180904f, 0.12393f, 0.001275f, -0.0306f, -0.032822f, -0.496515f, 0.009757f, 0.014602f, + 0.004532f, -0.039969f, -0.015984f, 0.047726f, 0.099865f, 0.003163f, 0.026623f, 0.117951f, -0.076234f, + -0.811997f, 0.01301f, 0.020042f, 0.173756f, -0.036191f, -0.068887f, 0.0229f, 0.245465f, 0.214282f, + -0.011054f, 0.132813f, 0.241014f, -0.148763f, + }, + std::vector{ + 0.000000f, 0.000000f, 0.000000f, 349.000000f, 209.000000f, // 0 + 0.000000f, 0.000000f, 0.000000f, 237.625443f, 209.000000f, // 5 + 0.000000f, 140.305511f, 0.000000f, 349.000000f, 209.000000f, // 10 + 0.000000f, 0.000000f, 0.000000f, 349.000000f, 65.359818f, // 15 + 0.000000f, 0.000000f, 0.000000f, 349.000000f, 130.324097f, // 20 + 0.000000f, 0.000000f, 15.562508f, 97.587891f, 181.224182f, // 25 + 0.000000f, 0.000000f, 68.539543f, 250.406708f, 209.000000f, // 30 + 0.000000f, 0.000000f, 0.000000f, 195.881531f, 99.841385f, // 35 + 0.000000f, 0.000000f, 0.000000f, 78.303986f, 209.000000f, // 40 + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 209.000000f, // 45 + }), + }; + return proposalV1Params; +} + +template +std::vector generateProposalV4Params() { + using T = typename element_type_traits::value_type; + + std::vector proposalV4Params { + ProposalV4Params(0.7f, 16, 16, 6000, 10, // iou_threshold, min_nnox_size, feature_stride,pre_nms_topn, post_nms_topn + 3, 210, 350, 1, // image_shape_num, image_h, image_w, image_z + {0.5f}, // ratios + {32.0f}, //scales + 1, 1, 10, 10, // batch_size, anchor_num, feat_map_height, feat_map_width + IN_ET, + std::vector{ + 0.000240f, 0.003802f, 0.111432f, 0.000503f, 0.007887f, 0.144701f, 0.399074f, 0.004680f, // 0 + 0.139741f, 0.002386f, 0.030003f, 0.276552f, 0.000267f, 0.022971f, 0.287953f, 0.050235f, // 8 + 0.002580f, 0.206311f, 0.000146f, 0.009656f, 0.175462f, 0.000147f, 0.014718f, 0.272348f, // 16 + 0.065199f, 0.003286f, 0.185335f, 0.003720f, 0.025932f, 0.251401f, 0.001465f, 0.090447f, // 24 + 0.488469f, 0.092259f, 0.019306f, 0.379091f, 0.005311f, 0.010369f, 0.087615f, 0.042003f, // 32 + 0.073871f, 0.416763f, 0.044282f, 0.069776f, 0.313032f, 0.000457f, 0.017346f, 0.089762f, // 40 + 0.000820f, 0.103986f, 0.367993f, 0.026315f, 0.035701f, 0.299252f, 0.000135f, 0.017825f, // 48 + 0.150119f, 0.000076f, 0.050511f, 0.269601f, 0.026680f, 0.003541f, 0.189765f, 0.000051f, // 56 + 0.004315f, 0.193150f, 0.000032f, 0.007254f, 0.185557f, 0.051526f, 0.000657f, 0.117579f, // 64 + 0.000115f, 0.010179f, 0.293187f, 0.000025f, 0.006505f, 0.175345f, 0.032587f, 0.000469f, // 72 + 0.098443f, 0.000121f, 0.009600f, 0.322782f, 0.000032f, 0.004543f, 0.166860f, 0.044911f, // 80 + 0.000187f, 0.102691f, 0.000242f, 0.005502f, 0.107865f, 0.000191f, 0.005336f, 0.086893f, // 88 + 0.078422f, 0.000345f, 0.079096f, 0.000281f, 0.016388f, 0.214072f, 0.000107f, 0.012027f, // 96 + 0.192754f, 0.049531f, 0.000386f, 0.149893f, 0.000374f, 0.016965f, 0.204781f, 0.000163f, // 104 + 0.016272f, 0.215277f, 0.032298f, 0.000857f, 0.133426f, 0.000614f, 0.020215f, 0.165789f, // 112 + 0.000225f, 0.036951f, 0.262195f, 0.087675f, 0.004596f, 0.147764f, 0.000219f, 0.010502f, // 120 + 0.163394f, 0.000152f, 0.023116f, 0.241702f, 0.081800f, 0.002197f, 0.146637f, 0.000193f, // 128 + 0.012017f, 0.133497f, 0.000375f, 0.028605f, 0.309179f, 0.065962f, 0.005508f, 0.155530f, // 136 + 0.000186f, 0.004540f, 0.079319f, 0.000799f, 0.031003f, 0.303045f, 0.051473f, 0.017770f, // 144 + 0.206188f, 0.000202f, 0.004291f, 0.061095f, 0.001109f, 0.018094f, 0.156639f, 0.026062f, // 152 + 0.005270f, 0.148651f, 0.000026f, 0.007300f, 0.096013f, 0.000383f, 0.022134f, 0.129511f, // 160 + 0.080882f, 0.003416f, 0.129922f, 0.000037f, 0.010040f, 0.130007f, 0.000116f, 0.014904f, // 168 + 0.171423f, 0.082893f, 0.000921f, 0.154976f, 0.000142f, 0.016552f, 0.209696f, 0.000227f, // 176 + 0.022418f, 0.228501f, 0.111712f, 0.001987f, 0.158164f, 0.001200f, 0.027049f, 0.308222f, // 184 + 0.001366f, 0.038146f, 0.287945f, 0.072526f, 0.016064f, 0.257895f, 0.000595f, 0.016962f, // 192 + }, + std::vector{ + 0.006756f, -0.055635f, 0.030843f, 0.007482f, 0.009056f, -0.041824f, 0.119722f, 0.168988f, 0.002822f, + 0.039733f, 0.109005f, 0.245152f, -0.013196f, -0.018222f, -0.170122f, -0.374904f, -0.005455f, -0.034059f, + -0.006787f, 0.072005f, -0.017933f, -0.007358f, 0.034149f, 0.123846f, 0.128319f, 0.016107f, -0.615487f, + -1.235094f, -0.024253f, -0.019406f, 0.134142f, 0.157853f, -0.021119f, 0.007383f, 0.089365f, 0.092854f, + 0.062491f, 0.002366f, 0.122464f, -0.003326f, 0.015468f, -0.034088f, 0.079009f, 0.075483f, 0.011972f, + 0.042427f, 0.106865f, 0.158754f, 0.071211f, -0.034009f, 0.007985f, -0.441477f, 0.009046f, -0.028515f, + 0.095372f, 0.119598f, -0.007553f, -0.0072f, 0.105072f, 0.084314f, 0.23268f, -0.02906f, -0.408454f, + -1.13439f, 0.016202f, -0.037859f, 0.130873f, 0.129652f, 0.002064f, -0.011969f, 0.171623f, 0.050218f, + 0.113831f, 0.028922f, 0.017785f, 0.059708f, 0.037658f, -0.011245f, 0.097197f, 0.137491f, 0.024218f, + 0.04739f, 0.091978f, 0.217333f, 0.088418f, -0.004662f, -0.095168f, -0.397928f, 0.02639f, -0.008501f, + 0.068487f, 0.108465f, 0.020069f, 0.018829f, 0.040206f, 0.068473f, 0.226458f, -0.072871f, -0.672384f, + -1.447558f, 0.039598f, 0.017471f, 0.187288f, 0.08409f, 0.017152f, -0.00516f, 0.183419f, 0.068469f, + 0.063944f, 0.160725f, -0.022493f, -0.132291f, 0.010542f, 0.036318f, 0.074042f, -0.013323f, 0.00808f, + 0.060365f, 0.120566f, 0.21866f, 0.046324f, 0.088741f, 0.029469f, -0.517183f, 0.00917f, 0.011915f, + 0.053674f, 0.140168f, 0.0033f, 0.022759f, -0.006196f, 0.063839f, 0.083726f, -0.088385f, -0.57208f, + -1.454211f, 0.020655f, 0.010788f, 0.134951f, 0.109709f, 0.015445f, -0.015363f, 0.109153f, 0.051209f, + 0.024297f, 0.139126f, -0.12358f, -0.127979f, 0.004587f, 0.004751f, 0.047292f, 0.027066f, 0.011003f, + 0.069887f, 0.117052f, 0.267419f, 0.039306f, 0.077584f, 0.02579f, -0.496149f, -0.005569f, 0.015494f, + -0.011662f, 0.105549f, -0.007015f, 0.031984f, -0.075742f, 0.0852f, 0.023886f, -0.053107f, -0.325533f, + -1.329066f, 0.004688f, 0.034501f, 0.089317f, 0.042463f, 0.004212f, -0.015128f, 0.00892f, 0.028266f, + 0.009997f, 0.157822f, 0.020116f, -0.142337f, 0.008199f, 0.046564f, 0.083014f, 0.046307f, 0.006771f, + 0.084997f, 0.141935f, 0.228339f, -0.020308f, 0.077745f, -0.018319f, -0.522311f, 0.010432f, 0.024641f, + 0.020571f, 0.097148f, 0.002064f, 0.035053f, -0.121995f, 0.012222f, -0.030779f, 0.100481f, -0.331737f, + -1.257669f, -0.013079f, 0.021227f, 0.159949f, 0.120097f, 0.005765f, -0.012335f, -0.005268f, 0.042067f, + -0.043972f, 0.102556f, 0.180494f, -0.084721f, -0.011962f, 0.031302f, 0.112511f, 0.027557f, -0.002085f, + 0.082978f, 0.149409f, 0.195091f, -0.033731f, 0.019861f, -0.064047f, -0.471328f, -0.004093f, 0.016803f, + 0.044635f, 0.058912f, -0.018735f, 0.035536f, -0.050373f, -0.002794f, -0.086705f, 0.038435f, -0.301466f, + -1.071246f, -0.028247f, 0.018984f, 0.254702f, 0.141142f, -0.017522f, 0.014843f, 0.079391f, 0.079662f, + -0.051204f, 0.048419f, 0.235604f, -0.185797f, -0.019569f, 0.02678f, 0.162507f, 0.046435f, -0.004606f, + 0.08806f, 0.18634f, 0.193957f, -0.024333f, -0.01298f, -0.17977f, -0.65881f, -0.003778f, 0.007418f, + 0.065439f, 0.104549f, -0.027706f, 0.03301f, 0.057492f, 0.032019f, -0.135337f, 0.000269f, -0.250203f, + -1.181688f, -0.027022f, -0.006755f, 0.206848f, 0.129268f, -0.003529f, 0.013445f, 0.181484f, 0.139955f, + -0.036587f, 0.065824f, 0.288751f, -0.110813f, -0.015578f, 0.044818f, 0.17756f, 0.006914f, 0.002329f, + 0.068982f, 0.189079f, 0.184253f, 0.00301f, -0.039168f, -0.010855f, -0.393254f, 0.000028f, 0.001906f, + 0.07217f, 0.063305f, -0.026144f, 0.028842f, 0.139149f, 0.023377f, 0.023362f, 0.023559f, -0.145386f, + -0.863572f, -0.015749f, -0.021364f, 0.172571f, 0.078393f, -0.037253f, 0.014978f, 0.221502f, 0.189111f, + -0.048956f, 0.085409f, 0.325399f, -0.058294f, -0.028495f, 0.021663f, 0.19392f, 0.02706f, 0.006908f, + 0.065751f, 0.176395f, 0.138375f, 0.012418f, -0.031228f, -0.008762f, -0.427345f, -0.013677f, -0.002429f, + 0.069655f, 0.019505f, -0.036763f, 0.022528f, 0.201062f, 0.022205f, 0.024528f, 0.06241f, -0.076237f, + -0.840695f, -0.007268f, -0.027865f, 0.211056f, 0.074744f, -0.053563f, 0.006863f, 0.301432f, 0.192879f, + -0.021944f, 0.100535f, 0.19031f, -0.133746f, -0.006151f, 0.023944f, 0.13561f, -0.03259f, 0.000618f, + 0.063736f, 0.180904f, 0.12393f, 0.001275f, -0.0306f, -0.032822f, -0.496515f, 0.009757f, 0.014602f, + 0.004532f, -0.039969f, -0.015984f, 0.047726f, 0.099865f, 0.003163f, 0.026623f, 0.117951f, -0.076234f, + -0.811997f, 0.01301f, 0.020042f, 0.173756f, -0.036191f, -0.068887f, 0.0229f, 0.245465f, 0.214282f, + -0.011054f, 0.132813f, 0.241014f, -0.148763f, + }, + std::vector{ + 0.000000f, 0.000000f, 0.000000f, 349.000000f, 209.000000f, // 0 + 0.000000f, 0.000000f, 0.000000f, 237.625443f, 209.000000f, // 5 + 0.000000f, 140.305511f, 0.000000f, 349.000000f, 209.000000f, // 10 + 0.000000f, 0.000000f, 0.000000f, 349.000000f, 65.359818f, // 15 + 0.000000f, 0.000000f, 0.000000f, 349.000000f, 130.324097f, // 20 + 0.000000f, 0.000000f, 15.562508f, 97.587891f, 181.224182f, // 25 + 0.000000f, 0.000000f, 68.539543f, 250.406708f, 209.000000f, // 30 + 0.000000f, 0.000000f, 0.000000f, 195.881531f, 99.841385f, // 35 + 0.000000f, 0.000000f, 0.000000f, 78.303986f, 209.000000f, // 40 + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 209.000000f, // 45 + }, + std::vector{ + 0.3091790f, + 0.1555300f, + 0.1549760f, + 0.1466370f, + 0.0260620f, + 0.0177700f, + 0.0019870f, + 0.0008570f, + 0.0002190f, + 0.0000000f, + }), + }; + return proposalV4Params; +} + +std::vector generateProposalV1CombinedParams() { + const std::vector> proposalTypeParams { + generateProposalV1Params(), + generateProposalV1Params(), + generateProposalV1Params(), + generateProposalV1Params() + }; + std::vector combinedParams; + + for (const auto& params : proposalTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +std::vector generateProposalV4CombinedParams() { + const std::vector> proposalTypeParams { + generateProposalV4Params(), + generateProposalV4Params(), + generateProposalV4Params(), + generateProposalV4Params() + }; + std::vector combinedParams; + + for (const auto& params : proposalTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_Proposal_With_Hardcoded_Refs, ReferenceProposalV1LayerTest, + testing::ValuesIn(generateProposalV1CombinedParams()), ReferenceProposalV1LayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Proposal_With_Hardcoded_Refs, ReferenceProposalV4LayerTest, + testing::ValuesIn(generateProposalV4CombinedParams()), ReferenceProposalV4LayerTest::getTestCaseName); + +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/psroi_pooling.cpp b/docs/template_plugin/tests/functional/op_reference/psroi_pooling.cpp new file mode 100644 index 00000000000..9fca87d6efa --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/psroi_pooling.cpp @@ -0,0 +1,221 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include "openvino/op/psroi_pooling.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct PSROIPoolingParams { + template + PSROIPoolingParams(const size_t num_channels, const size_t group_size, + const size_t spatial_bins_x, const size_t spatial_bins_y, + const size_t num_boxes, const float spatial_scale, const std::string& mode, + const ov::element::Type& iType, + const std::vector& coordsValues, const std::vector& oValues, + const std::string& test_name = "") + : groupSize(group_size), + spatialBinsX(spatial_bins_x), + spatialBinsY(spatial_bins_y), + spatialScale(spatial_scale), + mode(mode), + imageInputType(iType), + coordsInputType(iType), + outType(iType), + coordsData(CreateTensor(iType, coordsValues)), + refData(CreateTensor(iType, oValues)), + testcaseName(test_name) { + if (mode == "bilinear") + outputDim = num_channels / (spatial_bins_x * spatial_bins_y); + else + outputDim = num_channels / (group_size * group_size); + imageShape = Shape{2, num_channels, 20, 20}; + coordsShape = Shape{num_boxes, 5}; + std::vector imageValues(shape_size(imageShape.get_shape())); + float val = 0; + std::generate(imageValues.begin(), imageValues.end(), [val]() mutable -> float { + return val += 0.1; + }); + imageData = CreateTensor(iType, imageValues); + } + + size_t groupSize; + size_t spatialBinsX; + size_t spatialBinsY; + size_t outputDim; + float spatialScale; + std::string mode; + ov::PartialShape imageShape; + ov::PartialShape coordsShape; + ov::element::Type imageInputType; + ov::element::Type coordsInputType; + ov::element::Type outType; + ov::runtime::Tensor imageData; + ov::runtime::Tensor coordsData; + ov::runtime::Tensor refData; + std::string testcaseName; +}; + +class ReferencePSROIPoolingLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.imageData, params.coordsData}; + refOutData = {params.refData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "imageInputShape=" << param.imageShape << "_"; + result << "coordsInputShape=" << param.coordsShape << "_"; + result << "outputDim=" << param.outputDim << "_"; + result << "iType=" << param.imageInputType << "_"; + if (param.testcaseName != "") { + result << "mode=" << param.mode << "_"; + result << param.testcaseName; + } else { + result << "mode=" << param.mode; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const PSROIPoolingParams& params) { + const auto image = std::make_shared(params.imageInputType, params.imageShape); + const auto coords = std::make_shared(params.coordsInputType, params.coordsShape); + const auto PSROIPooling = std::make_shared(image, + coords, + params.outputDim, + params.groupSize, + params.spatialScale, + params.spatialBinsX, + params.spatialBinsY, + params.mode); + return std::make_shared(NodeVector {PSROIPooling}, ParameterVector {image, coords}); + } +}; + +TEST_P(ReferencePSROIPoolingLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generatePSROIPoolingFloatParams() { + using T = typename element_type_traits::value_type; + + std::vector pSROIPoolingParams { + PSROIPoolingParams(8, + 2, + 1, + 1, + 3, + 1, + "average", + IN_ET, + std::vector{ + // batch_id, x1, y1, x2, y2 + 0, 1, 2, 4, 6, 1, 0, 3, 10, 4, 0, 10, 7, 11, 13}, + std::vector{ + 6.2499962, 46.44986, 90.249184, 130.44876, 166.25095, 206.45341, 250.25606, 290.45853, + 326.36069, 366.86316, 408.36572, 448.86816, 486.37045, 526.86841, 568.35828, 608.84839, + 18.100033, 58.199684, 104.09898, 144.1996, 178.10167, 218.20412, 264.1069, 304.20935}), + PSROIPoolingParams(8, + 2, + 1, + 1, + 4, + 0.2, + "average", + IN_ET, + std::vector{ + // batch_id, x1, y1, x2, y2 + 0, 5, 10, 20, 30, 0, 0, 15, 50, 20, 1, 50, 35, 55, 65, 1, 0, 60, 5, 70}, + std::vector{ + 6.24999619, 46.399868, 90.2491837, 130.398758, 166.250946, 206.403397, 250.256058, 290.408508, + 6.34999657, 46.8498573, 87.3492432, 127.848656, 166.350952, 206.853409, 247.355896, 287.858368, + 338.11142, 378.163879, 424.116669, 464.169128, 498.121185, 538.165649, 584.104431, 624.144653, + 345.111847, 385.164307, 427.116852, 467.169312, 505.121613, 545.16394, 587.103699, 627.143921}), + PSROIPoolingParams(12, + 3, + 2, + 3, + 5, + 1, + "bilinear", + IN_ET, + std::vector{ + 0, 0.1, 0.2, 0.7, 0.4, 1, 0.4, 0.1, 0.9, 0.3, 0, 0.5, 0.7, + 0.7, 0.9, 1, 0.15, 0.3, 0.65, 0.35, 0, 0.0, 0.2, 0.7, 0.8}, + std::vector{ + 210.71394, 210.99896, 211.28398, 211.98065, 212.26567, 212.55066, 213.24738, 213.53239, 213.8174, 250.71545, + 251.00047, 251.28548, 251.98218, 252.2672, 252.5522, 253.2489, 253.53392, 253.81892, 687.40869, 687.64606, + 687.88354, 688.67511, 688.91254, 689.14996, 689.94147, 690.17896, 690.41644, 727.40021, 727.6377, 727.87518, + 728.66669, 728.90405, 729.14154, 729.93292, 730.17041, 730.4079, 230.28471, 230.3797, 230.47472, 231.55144, + 231.64642, 231.74141, 232.81813, 232.91313, 233.00813, 270.28638, 270.38141, 270.47641, 271.5531, 271.64813, + 271.74313, 272.81985, 272.91486, 273.00986, 692.63281, 692.87018, 693.1076, 692.94928, 693.18683, 693.42426, + 693.26593, 693.50342, 693.74078, 732.62402, 732.86139, 733.09888, 732.94049, 733.17804, 733.41547, 733.25714, + 733.49463, 733.73199, 215.63843, 215.97093, 216.30345, 219.43855, 219.77106, 220.10358, 223.23871, 223.57123, + 223.90375, 255.63994, 255.97246, 256.30496, 259.44009, 259.77261, 260.10513, 263.2403, 263.57281, 263.9053}), + PSROIPoolingParams(12, + 4, + 2, + 3, + 6, + 0.5, + "bilinear", + IN_ET, + std::vector{ + // batch_id, x1, y1, x2, y2 + 0, 0.1, 0.2, 0.7, 0.4, 0, 0.5, 0.7, 1.2, 1.3, 0, 1.0, 1.3, 1.2, 1.8, + 1, 0.5, 1.1, 0.7, 1.44, 1, 0.2, 1.1, 0.5, 1.2, 1, 0.34, 1.3, 1.15, 1.35}, + std::vector{ + 205.40955, 205.50456, 205.59955, 205.69453, 205.83179, 205.9268, 206.0218, 206.11681, 206.25403, 206.34901, + 206.44403, 206.53905, 206.67627, 206.77126, 206.86627, 206.96129, 245.41107, 245.50606, 245.60106, 245.69604, + 245.8333, 245.9283, 246.02327, 246.1183, 246.25554, 246.35052, 246.44556, 246.54054, 246.67778, 246.77277, + 246.86775, 246.96278, 217.84717, 217.95801, 218.06885, 218.17969, 219.11389, 219.22473, 219.33557, 219.44641, + 220.3806, 220.49144, 220.60228, 220.71312, 221.64732, 221.75816, 221.86897, 221.97981, 257.84872, 257.95956, + 258.0704, 258.18124, 259.11545, 259.22629, 259.33713, 259.44797, 260.38217, 260.49301, 260.60385, 260.71469, + 261.6489, 261.75974, 261.87057, 261.98141, 228.9705, 229.00215, 229.03383, 229.06549, 230.02608, 230.05774, + 230.08943, 230.12109, 231.08168, 231.11334, 231.14502, 231.1767, 232.13728, 232.16895, 232.20062, 232.23228, + 268.97217, 269.00385, 269.03549, 269.06717, 270.02777, 270.05945, 270.09109, 270.12277, 271.08337, 271.11502, + 271.1467, 271.17838, 272.13901, 272.17065, 272.2023, 272.23398, 703.65057, 703.68219, 703.71387, 703.74554, + 704.36816, 704.39984, 704.43146, 704.4632, 705.08575, 705.11749, 705.14911, 705.18085, 705.80347, 705.83514, + 705.86676, 705.89844, 743.64136, 743.67291, 743.70459, 743.73633, 744.35889, 744.39056, 744.42218, 744.45392, + 745.07648, 745.10815, 745.13983, 745.17157, 745.79413, 745.82574, 745.85742, 745.8891, 701.86963, 701.91724, + 701.9646, 702.01221, 702.08081, 702.12823, 702.17578, 702.22321, 702.29181, 702.33936, 702.38678, 702.43433, + 702.50293, 702.55035, 702.5979, 702.64545, 741.86041, 741.90796, 741.95538, 742.00293, 742.07153, 742.11896, + 742.1665, 742.21405, 742.28253, 742.33008, 742.3775, 742.42505, 742.49365, 742.54108, 742.58862, 742.63617, + 705.60645, 705.73468, 705.86298, 705.99115, 705.71198, 705.84027, 705.96844, 706.09668, 705.81757, 705.94574, + 706.07397, 706.20215, 705.9231, 706.05127, 706.1795, 706.3078, 745.59698, 745.72534, 745.85352, 745.98169, + 745.70264, 745.83081, 745.95898, 746.08722, 745.80811, 745.93628, 746.06451, 746.19269, 745.91364, 746.04181, + 746.1701, 746.29834}), + }; + return pSROIPoolingParams; +} + +std::vector generatePSROIPoolingCombinedParams() { + const std::vector> pSROIPoolingTypeParams { + generatePSROIPoolingFloatParams(), + generatePSROIPoolingFloatParams(), + generatePSROIPoolingFloatParams(), + generatePSROIPoolingFloatParams() + }; + std::vector combinedParams; + + for (const auto& params : pSROIPoolingTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_PSROIPooling_With_Hardcoded_Refs, ReferencePSROIPoolingLayerTest, + testing::ValuesIn(generatePSROIPoolingCombinedParams()), ReferencePSROIPoolingLayerTest::getTestCaseName); + +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/skip_tests_config.cpp b/docs/template_plugin/tests/functional/skip_tests_config.cpp index 10efdb96a29..09f1b06630c 100644 --- a/docs/template_plugin/tests/functional/skip_tests_config.cpp +++ b/docs/template_plugin/tests/functional/skip_tests_config.cpp @@ -49,6 +49,12 @@ std::vector disabledTestPatterns() { R"(.*ReferenceDeformableConvolutionV8LayerTest.*f16.*real_offset_padding_stride_dialation.*)", R"(.*ReferenceDeformableConvolutionV8LayerTest.*bf16.*)", R"(.*ReferenceDeformableConvolutionV8LayerTest.*f64.*mask.*)", + //CVS-63973 + R"(.*ReferencePSROIPoolingLayerTest.*bf16.*)", + //CVS-63977 + R"(.*ReferenceProposalV1LayerTest.*f16.*)", + //CVS-64082 + R"(.*ReferenceProposalV4LayerTest.*f16.*)", }; #ifdef _WIN32 diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 0ccef3ac2de..debbb81e6c1 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -466,7 +466,6 @@ set(MULTI_TEST_SRC backend/constant.in.cpp backend/ctc_greedy_decoder.in.cpp backend/ctc_greedy_decoder_seq_len.in.cpp - backend/deformable_psroi_pooling.in.cpp backend/detection_output.in.cpp backend/depth_to_space.in.cpp backend/dyn_reshape.in.cpp @@ -491,8 +490,6 @@ set(MULTI_TEST_SRC backend/pad.in.cpp backend/prior_box_clustered.in.cpp backend/prior_box.in.cpp - backend/proposal.in.cpp - backend/psroi_pooling.in.cpp backend/recurrent_cells.in.cpp backend/region_yolo.in.cpp backend/reorg_yolo.in.cpp diff --git a/ngraph/test/backend/deformable_psroi_pooling.in.cpp b/ngraph/test/backend/deformable_psroi_pooling.in.cpp deleted file mode 100644 index fa7abe5210c..00000000000 --- a/ngraph/test/backend/deformable_psroi_pooling.in.cpp +++ /dev/null @@ -1,762 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/op/deformable_psroi_pooling.hpp" -#include "util/test_control.hpp" - -using namespace ngraph; - -static std::string s_manifest = "${MANIFEST}"; -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_offset_00) { - const float spatial_scale = 0.0625; - const int64_t group_size = 2; - const size_t channels_in = 16; - size_t output_dim = channels_in / (group_size * group_size); // 4 - - size_t rois_count = 2; - - auto data_shape = Shape{1, channels_in, 2, 2}; - auto rois_shape = Shape{rois_count, 5}; - auto offsets_shape = Shape{rois_count, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size); - - Shape output_shape{rois_count, output_dim, group_size, group_size}; - // ASSERT_EQ(def_psroi_pool->get_output_shape(0), (output_shape)); - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - // std::fill(data_values.begin(), data_values.end(), 0.1); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 2, - 4, - 6, - - 0, - 0, - 3, - 10, - 4, - }; - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.0); - - std::vector expected_output_values{// First ROI - 0, - 4, - 8, - 12, - - 16, - 20, - 24, - 28, - - 32, - 36, - 40, - 44, - - 48, - 52, - 56, - 60, - - // Second ROI - 0, - 4, - 8, - 12, - - 16, - 20, - 24, - 28, - - 32, - 36, - 40, - 44, - - 48, - 52, - 56, - 60}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_offset_0p2) { - const float spatial_scale = 0.0625; - const int64_t group_size = 2; - const size_t channels_in = 16; - size_t output_dim = channels_in / (group_size * group_size); // 4 - - size_t rois_count = 2; - - auto data_shape = Shape{1, channels_in, 2, 2}; - auto rois_shape = Shape{rois_count, 5}; - auto offsets_shape = Shape{rois_count, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size); - - Shape output_shape{rois_count, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 2, - 4, - 6, - - 0, - 0, - 3, - 10, - 4, - }; - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.2); - - std::vector expected_output_values{// First ROI - 0, - 4, - 8, - 12, - - 16, - 20, - 24, - 28, - - 32, - 36, - 40, - 44, - - 48, - 52, - 56, - 60, - - // Second ROI - 0, - 4, - 8, - 12, - - 16, - 20, - 24, - 28, - - 32, - 36, - 40, - 44, - - 48, - 52, - 56, - 60}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_offset_0p5) { - const float spatial_scale = 0.0625; - const int64_t group_size = 2; - const size_t channels_in = 16; - size_t output_dim = channels_in / (group_size * group_size); // 4 - - size_t rois_count = 2; - - auto data_shape = Shape{1, channels_in, 2, 2}; - auto rois_shape = Shape{rois_count, 5}; - auto offsets_shape = Shape{rois_count, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size); - - Shape output_shape{rois_count, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 2, - 4, - 6, - - 0, - 5, - 3, - 10, - 4, - }; - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.5); - - std::vector expected_output_values{// First ROI - 0, - 4, - 8, - 12, - - 16, - 20, - 24, - 28, - - 32, - 36, - 40, - 44, - - 48, - 52, - 56, - 60, - - // Second ROI - 0, - 4.1875, - 8, - 12.1875, - - 16, - 20.1875, - 24, - 28.1875, - - 32, - 36.1875, - 40, - 44.1875, - - 48, - 52.1875, - 56, - 60.1875}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_roi_oversize) { - const float spatial_scale = 0.0625; - const int64_t group_size = 2; - const size_t channels_in = 16; - size_t output_dim = channels_in / (group_size * group_size); // 4 - - size_t rois_count = 2; - - auto data_shape = Shape{1, channels_in, 2, 2}; - auto rois_shape = Shape{rois_count, 5}; - auto offsets_shape = Shape{rois_count, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size); - - Shape output_shape{rois_count, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 10, - 10, - 20, - 20, - - 0, - 100, - 100, - 200, - 200, - }; - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.0); - - std::vector expected_output_values{0.375, 4.71875, 9.0625, 13.40625, 16.375, 20.71875, 25.0625, 29.40625, - 32.375, 36.71875, 41.0625, 45.40625, 48.375, 52.71875, 57.0625, 61.40625, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_no_offset_input) { - const float spatial_scale = 1; - const int64_t group_size = 2; - const size_t spatial_bins_x = 1; - const size_t spatial_bins_y = 1; - const float trans_std = 1.0; - const int64_t part_size = group_size; - - const size_t batch_in = 1; - const size_t channels_in = 8; - const size_t width_in = 3; - const size_t height_in = 3; - - size_t output_dim = channels_in / (group_size * group_size); // 2 - - const auto rois_dim = 1; - - auto data_shape = Shape{batch_in, channels_in, height_in, width_in}; - auto rois_shape = Shape{rois_dim, 5}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - output_dim, - spatial_scale, - group_size, - "bilinear_deformable", - spatial_bins_x, - spatial_bins_y, - trans_std, - part_size); - - Shape output_shape{rois_dim, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 1, - 2, - 2, - }; - - std::vector expected_output_values{2.0, 12.0, 23.0, 33.0, 38.0, 48.0, 59.0, 69.0}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_offset_zero) { - const float spatial_scale = 1; - const int64_t group_size = 2; - const size_t spatial_bins_x = 1; - const size_t spatial_bins_y = 1; - const float trans_std = 1.0; - const int64_t part_size = group_size; - - const size_t batch_in = 1; - const size_t channels_in = 8; - const size_t width_in = 3; - const size_t height_in = 3; - - size_t output_dim = channels_in / (group_size * group_size); // 2 - - const auto rois_dim = 1; - - auto data_shape = Shape{batch_in, channels_in, height_in, width_in}; - auto rois_shape = Shape{rois_dim, 5}; - auto offsets_shape = Shape{rois_dim, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size, - "bilinear_deformable", - spatial_bins_x, - spatial_bins_y, - trans_std, - part_size); - - Shape output_shape{rois_dim, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 1, - 2, - 2, - }; - - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.0); - - std::vector expected_output_values{2.0, 12.0, 23.0, 33.0, 38.0, 48.0, 59.0, 69.0}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_offset_01) { - const float spatial_scale = 1; - const int64_t group_size = 2; - const size_t spatial_bins_x = 1; - const size_t spatial_bins_y = 1; - const float trans_std = 1.0; - const int64_t part_size = group_size; - - const size_t batch_in = 1; - const size_t channels_in = 8; - const size_t width_in = 3; - const size_t height_in = 3; - - size_t output_dim = channels_in / (group_size * group_size); // 2 - - const auto rois_dim = 1; - - auto data_shape = Shape{batch_in, channels_in, height_in, width_in}; - auto rois_shape = Shape{rois_dim, 5}; - auto offsets_shape = Shape{rois_dim, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size, - "bilinear_deformable", - spatial_bins_x, - spatial_bins_y, - trans_std, - part_size); - - Shape output_shape{rois_dim, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 1, - 2, - 2, - }; - - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.1); - - std::vector expected_output_values{2.8, 12.8, 23.8, 33.8, 38.8, 48.8, 59.8, 69.8}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_offset_05) { - const float spatial_scale = 1; - const int64_t group_size = 2; - const size_t spatial_bins_x = 1; - const size_t spatial_bins_y = 1; - const float trans_std = 1.0; - const int64_t part_size = group_size; - - const size_t batch_in = 1; - const size_t channels_in = 8; - const size_t width_in = 3; - const size_t height_in = 3; - - size_t output_dim = channels_in / (group_size * group_size); // 2 - - const auto rois_dim = 1; - - auto data_shape = Shape{batch_in, channels_in, height_in, width_in}; - auto rois_shape = Shape{rois_dim, 5}; - auto offsets_shape = Shape{rois_dim, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size, - "bilinear_deformable", - spatial_bins_x, - spatial_bins_y, - trans_std, - part_size); - - Shape output_shape{rois_dim, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::iota(data_values.begin(), data_values.end(), 0); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 1, - 2, - 2, - }; - - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.5); - - std::vector expected_output_values{6., 15.5, 25.5, 35., 42., 51.5, 61.5, 71.}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_single_value) { - const float spatial_scale = 0.0625; - const int64_t group_size = 2; - const size_t channels_in = 16; - size_t output_dim = channels_in / (group_size * group_size); // 4 - - size_t rois_count = 1; - - auto data_shape = Shape{1, channels_in, 2, 2}; - auto rois_shape = Shape{rois_count, 5}; - auto offsets_shape = Shape{rois_count, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size); - - Shape output_shape{rois_count, output_dim, group_size, group_size}; - - std::vector data_values(shape_size(data_shape)); - std::fill(data_values.begin(), data_values.end(), 0.1); - - std::vector rois_data{ - // input_batch_id, x1, y1, x2, y2 - 0, - 10, - 10, - 10, - 10, - }; - - std::vector offsets_values(shape_size(offsets_shape)); - std::fill(offsets_values.begin(), offsets_values.end(), 0.1); - - std::vector expected_output_values{0.1, - 0.1, - 0.1, - 0.1, - - 0.1, - 0.1, - 0.1, - 0.1, - - 0.1, - 0.1, - 0.1, - 0.1, - - 0.1, - 0.1, - 0.1, - 0.1}; - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(data_values); - test.add_input(rois_data); - test.add_input(offsets_values); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, deformable_psroi_pooling_single_value_big_shape) { - const int64_t output_dim = 112; - const float spatial_scale = 0.0625; - const int64_t group_size = 3; - - size_t rois_count = 2; - - auto data_shape = Shape{1, 1024, 63, 38}; - auto rois_shape = Shape{rois_count, 5}; - auto offsets_shape = Shape{rois_count, 2, group_size, group_size}; - - auto data_param = std::make_shared(element::f32, data_shape); - auto rois_param = std::make_shared(element::f32, rois_shape); - auto offsets_param = std::make_shared(element::f32, offsets_shape); - - auto def_psroi_pool = std::make_shared(data_param, - rois_param, - offsets_param, - output_dim, - spatial_scale, - group_size); - - Shape output_shape{rois_count, output_dim, group_size, group_size}; - - std::vector input_data(shape_size(data_shape)); - std::fill(input_data.begin(), input_data.end(), 0.1); - - std::vector input_rois{ - // input_batch_id, x1, y1, x2, y2 - 0, - 1, - 2, - 4, - 6, - - 0, - 0, - 3, - 10, - 4, - }; - - std::vector input_offsets(shape_size(offsets_shape)); - std::fill(input_offsets.begin(), input_offsets.end(), 0.0); - - std::vector expected_output_values(shape_size(output_shape)); - std::fill(expected_output_values.begin(), expected_output_values.end(), 0.1); - - auto f = std::make_shared(def_psroi_pool, ParameterVector{data_param, rois_param, offsets_param}); - - auto test = test::TestCase(f); - test.add_input(input_data); - test.add_input(input_rois); - test.add_input(input_offsets); - - test.add_expected_output(output_shape, expected_output_values); - test.run(); -} diff --git a/ngraph/test/backend/proposal.in.cpp b/ngraph/test/backend/proposal.in.cpp deleted file mode 100644 index 9647c95cef5..00000000000 --- a/ngraph/test/backend/proposal.in.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include -#include -#include - -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/op/proposal.hpp" -#include "util/test_control.hpp" -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -constexpr float cls_scores_data[] = { - 0.000240f, 0.003802f, 0.111432f, 0.000503f, 0.007887f, 0.144701f, 0.399074f, 0.004680f, // 0 - 0.139741f, 0.002386f, 0.030003f, 0.276552f, 0.000267f, 0.022971f, 0.287953f, 0.050235f, // 8 - 0.002580f, 0.206311f, 0.000146f, 0.009656f, 0.175462f, 0.000147f, 0.014718f, 0.272348f, // 16 - 0.065199f, 0.003286f, 0.185335f, 0.003720f, 0.025932f, 0.251401f, 0.001465f, 0.090447f, // 24 - 0.488469f, 0.092259f, 0.019306f, 0.379091f, 0.005311f, 0.010369f, 0.087615f, 0.042003f, // 32 - 0.073871f, 0.416763f, 0.044282f, 0.069776f, 0.313032f, 0.000457f, 0.017346f, 0.089762f, // 40 - 0.000820f, 0.103986f, 0.367993f, 0.026315f, 0.035701f, 0.299252f, 0.000135f, 0.017825f, // 48 - 0.150119f, 0.000076f, 0.050511f, 0.269601f, 0.026680f, 0.003541f, 0.189765f, 0.000051f, // 56 - 0.004315f, 0.193150f, 0.000032f, 0.007254f, 0.185557f, 0.051526f, 0.000657f, 0.117579f, // 64 - 0.000115f, 0.010179f, 0.293187f, 0.000025f, 0.006505f, 0.175345f, 0.032587f, 0.000469f, // 72 - 0.098443f, 0.000121f, 0.009600f, 0.322782f, 0.000032f, 0.004543f, 0.166860f, 0.044911f, // 80 - 0.000187f, 0.102691f, 0.000242f, 0.005502f, 0.107865f, 0.000191f, 0.005336f, 0.086893f, // 88 - 0.078422f, 0.000345f, 0.079096f, 0.000281f, 0.016388f, 0.214072f, 0.000107f, 0.012027f, // 96 - 0.192754f, 0.049531f, 0.000386f, 0.149893f, 0.000374f, 0.016965f, 0.204781f, 0.000163f, // 104 - 0.016272f, 0.215277f, 0.032298f, 0.000857f, 0.133426f, 0.000614f, 0.020215f, 0.165789f, // 112 - 0.000225f, 0.036951f, 0.262195f, 0.087675f, 0.004596f, 0.147764f, 0.000219f, 0.010502f, // 120 - 0.163394f, 0.000152f, 0.023116f, 0.241702f, 0.081800f, 0.002197f, 0.146637f, 0.000193f, // 128 - 0.012017f, 0.133497f, 0.000375f, 0.028605f, 0.309179f, 0.065962f, 0.005508f, 0.155530f, // 136 - 0.000186f, 0.004540f, 0.079319f, 0.000799f, 0.031003f, 0.303045f, 0.051473f, 0.017770f, // 144 - 0.206188f, 0.000202f, 0.004291f, 0.061095f, 0.001109f, 0.018094f, 0.156639f, 0.026062f, // 152 - 0.005270f, 0.148651f, 0.000026f, 0.007300f, 0.096013f, 0.000383f, 0.022134f, 0.129511f, // 160 - 0.080882f, 0.003416f, 0.129922f, 0.000037f, 0.010040f, 0.130007f, 0.000116f, 0.014904f, // 168 - 0.171423f, 0.082893f, 0.000921f, 0.154976f, 0.000142f, 0.016552f, 0.209696f, 0.000227f, // 176 - 0.022418f, 0.228501f, 0.111712f, 0.001987f, 0.158164f, 0.001200f, 0.027049f, 0.308222f, // 184 - 0.001366f, 0.038146f, 0.287945f, 0.072526f, 0.016064f, 0.257895f, 0.000595f, 0.016962f, // 192 -}; -constexpr float bbox_pred_data[] = { - 0.006756f, -0.055635f, 0.030843f, 0.007482f, 0.009056f, -0.041824f, 0.119722f, 0.168988f, 0.002822f, - 0.039733f, 0.109005f, 0.245152f, -0.013196f, -0.018222f, -0.170122f, -0.374904f, -0.005455f, -0.034059f, - -0.006787f, 0.072005f, -0.017933f, -0.007358f, 0.034149f, 0.123846f, 0.128319f, 0.016107f, -0.615487f, - -1.235094f, -0.024253f, -0.019406f, 0.134142f, 0.157853f, -0.021119f, 0.007383f, 0.089365f, 0.092854f, - 0.062491f, 0.002366f, 0.122464f, -0.003326f, 0.015468f, -0.034088f, 0.079009f, 0.075483f, 0.011972f, - 0.042427f, 0.106865f, 0.158754f, 0.071211f, -0.034009f, 0.007985f, -0.441477f, 0.009046f, -0.028515f, - 0.095372f, 0.119598f, -0.007553f, -0.0072f, 0.105072f, 0.084314f, 0.23268f, -0.02906f, -0.408454f, - -1.13439f, 0.016202f, -0.037859f, 0.130873f, 0.129652f, 0.002064f, -0.011969f, 0.171623f, 0.050218f, - 0.113831f, 0.028922f, 0.017785f, 0.059708f, 0.037658f, -0.011245f, 0.097197f, 0.137491f, 0.024218f, - 0.04739f, 0.091978f, 0.217333f, 0.088418f, -0.004662f, -0.095168f, -0.397928f, 0.02639f, -0.008501f, - 0.068487f, 0.108465f, 0.020069f, 0.018829f, 0.040206f, 0.068473f, 0.226458f, -0.072871f, -0.672384f, - -1.447558f, 0.039598f, 0.017471f, 0.187288f, 0.08409f, 0.017152f, -0.00516f, 0.183419f, 0.068469f, - 0.063944f, 0.160725f, -0.022493f, -0.132291f, 0.010542f, 0.036318f, 0.074042f, -0.013323f, 0.00808f, - 0.060365f, 0.120566f, 0.21866f, 0.046324f, 0.088741f, 0.029469f, -0.517183f, 0.00917f, 0.011915f, - 0.053674f, 0.140168f, 0.0033f, 0.022759f, -0.006196f, 0.063839f, 0.083726f, -0.088385f, -0.57208f, - -1.454211f, 0.020655f, 0.010788f, 0.134951f, 0.109709f, 0.015445f, -0.015363f, 0.109153f, 0.051209f, - 0.024297f, 0.139126f, -0.12358f, -0.127979f, 0.004587f, 0.004751f, 0.047292f, 0.027066f, 0.011003f, - 0.069887f, 0.117052f, 0.267419f, 0.039306f, 0.077584f, 0.02579f, -0.496149f, -0.005569f, 0.015494f, - -0.011662f, 0.105549f, -0.007015f, 0.031984f, -0.075742f, 0.0852f, 0.023886f, -0.053107f, -0.325533f, - -1.329066f, 0.004688f, 0.034501f, 0.089317f, 0.042463f, 0.004212f, -0.015128f, 0.00892f, 0.028266f, - 0.009997f, 0.157822f, 0.020116f, -0.142337f, 0.008199f, 0.046564f, 0.083014f, 0.046307f, 0.006771f, - 0.084997f, 0.141935f, 0.228339f, -0.020308f, 0.077745f, -0.018319f, -0.522311f, 0.010432f, 0.024641f, - 0.020571f, 0.097148f, 0.002064f, 0.035053f, -0.121995f, 0.012222f, -0.030779f, 0.100481f, -0.331737f, - -1.257669f, -0.013079f, 0.021227f, 0.159949f, 0.120097f, 0.005765f, -0.012335f, -0.005268f, 0.042067f, - -0.043972f, 0.102556f, 0.180494f, -0.084721f, -0.011962f, 0.031302f, 0.112511f, 0.027557f, -0.002085f, - 0.082978f, 0.149409f, 0.195091f, -0.033731f, 0.019861f, -0.064047f, -0.471328f, -0.004093f, 0.016803f, - 0.044635f, 0.058912f, -0.018735f, 0.035536f, -0.050373f, -0.002794f, -0.086705f, 0.038435f, -0.301466f, - -1.071246f, -0.028247f, 0.018984f, 0.254702f, 0.141142f, -0.017522f, 0.014843f, 0.079391f, 0.079662f, - -0.051204f, 0.048419f, 0.235604f, -0.185797f, -0.019569f, 0.02678f, 0.162507f, 0.046435f, -0.004606f, - 0.08806f, 0.18634f, 0.193957f, -0.024333f, -0.01298f, -0.17977f, -0.65881f, -0.003778f, 0.007418f, - 0.065439f, 0.104549f, -0.027706f, 0.03301f, 0.057492f, 0.032019f, -0.135337f, 0.000269f, -0.250203f, - -1.181688f, -0.027022f, -0.006755f, 0.206848f, 0.129268f, -0.003529f, 0.013445f, 0.181484f, 0.139955f, - -0.036587f, 0.065824f, 0.288751f, -0.110813f, -0.015578f, 0.044818f, 0.17756f, 0.006914f, 0.002329f, - 0.068982f, 0.189079f, 0.184253f, 0.00301f, -0.039168f, -0.010855f, -0.393254f, 0.000028f, 0.001906f, - 0.07217f, 0.063305f, -0.026144f, 0.028842f, 0.139149f, 0.023377f, 0.023362f, 0.023559f, -0.145386f, - -0.863572f, -0.015749f, -0.021364f, 0.172571f, 0.078393f, -0.037253f, 0.014978f, 0.221502f, 0.189111f, - -0.048956f, 0.085409f, 0.325399f, -0.058294f, -0.028495f, 0.021663f, 0.19392f, 0.02706f, 0.006908f, - 0.065751f, 0.176395f, 0.138375f, 0.012418f, -0.031228f, -0.008762f, -0.427345f, -0.013677f, -0.002429f, - 0.069655f, 0.019505f, -0.036763f, 0.022528f, 0.201062f, 0.022205f, 0.024528f, 0.06241f, -0.076237f, - -0.840695f, -0.007268f, -0.027865f, 0.211056f, 0.074744f, -0.053563f, 0.006863f, 0.301432f, 0.192879f, - -0.021944f, 0.100535f, 0.19031f, -0.133746f, -0.006151f, 0.023944f, 0.13561f, -0.03259f, 0.000618f, - 0.063736f, 0.180904f, 0.12393f, 0.001275f, -0.0306f, -0.032822f, -0.496515f, 0.009757f, 0.014602f, - 0.004532f, -0.039969f, -0.015984f, 0.047726f, 0.099865f, 0.003163f, 0.026623f, 0.117951f, -0.076234f, - -0.811997f, 0.01301f, 0.020042f, 0.173756f, -0.036191f, -0.068887f, 0.0229f, 0.245465f, 0.214282f, - -0.011054f, 0.132813f, 0.241014f, -0.148763f, -}; -constexpr float proposal_ref[] = { - 0.000000f, 0.000000f, 0.000000f, 349.000000f, 209.000000f, // 0 - 0.000000f, 0.000000f, 0.000000f, 237.625443f, 209.000000f, // 5 - 0.000000f, 140.305511f, 0.000000f, 349.000000f, 209.000000f, // 10 - 0.000000f, 0.000000f, 0.000000f, 349.000000f, 65.359818f, // 15 - 0.000000f, 0.000000f, 0.000000f, 349.000000f, 130.324097f, // 20 - 0.000000f, 0.000000f, 15.562508f, 97.587891f, 181.224182f, // 25 - 0.000000f, 0.000000f, 68.539543f, 250.406708f, 209.000000f, // 30 - 0.000000f, 0.000000f, 0.000000f, 195.881531f, 99.841385f, // 35 - 0.000000f, 0.000000f, 0.000000f, 78.303986f, 209.000000f, // 40 - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 209.000000f, // 45 -}; - -constexpr float probs_ref[] = { - 0.3091790f, - 0.1555300f, - 0.1549760f, - 0.1466370f, - 0.0260620f, - 0.0177700f, - 0.0019870f, - 0.0008570f, - 0.0002190f, - 0.0000000f, -}; - -NGRAPH_TEST(${BACKEND_NAME}, proposal_v0_basic) { - const float iou_threshold = 0.7f; - const int min_bbox_size = 16; - const int feature_stride = 16; - const int pre_nms_topn = 6000; - const int post_nms_topn = 10; - const int image_w = 350; - const int image_h = 210; - const int image_z = 1; - const std::vector ratios = {0.5f}; - const std::vector scales = {32.0f}; - const int batch_size = 1; - - Shape class_probs_shape{batch_size, 2, 10, 10}; - Shape bbox_deltas_shape{batch_size, 4, 10, 10}; - Shape image_shape_shape{3}; - Shape output_shape = {batch_size * post_nms_topn, 5}; - - op::ProposalAttrs attrs; - attrs.base_size = min_bbox_size; - attrs.min_size = min_bbox_size; - attrs.pre_nms_topn = pre_nms_topn; - attrs.post_nms_topn = post_nms_topn; - attrs.nms_thresh = iou_threshold; - attrs.feat_stride = feature_stride; - attrs.min_size = min_bbox_size; - attrs.ratio = ratios; - attrs.scale = scales; - attrs.clip_before_nms = true; - attrs.clip_after_nms = false; - attrs.normalize = false; - attrs.box_size_scale = 1.0f; - attrs.box_coordinate_scale = 1.0f; - attrs.framework = ""; - attrs.infer_probs = false; - - auto class_probs_param = make_shared(element::f32, class_probs_shape); - auto bbox_deltas_param = make_shared(element::f32, bbox_deltas_shape); - auto image_shape_param = make_shared(element::f32, image_shape_shape); - - auto proposal = make_shared(class_probs_param, bbox_deltas_param, image_shape_param, attrs); - auto f = make_shared(proposal, ParameterVector{class_probs_param, bbox_deltas_param, image_shape_param}); - - std::vector c{std::begin(cls_scores_data), std::end(cls_scores_data)}; - std::vector b{std::begin(bbox_pred_data), std::end(bbox_pred_data)}; - std::vector i{image_h, image_w, image_z}; - - auto test_case = test::TestCase(f); - test_case.add_input(class_probs_shape, c); - test_case.add_input(bbox_deltas_shape, b); - test_case.add_input(image_shape_shape, i); - - std::vector o{std::begin(proposal_ref), std::end(proposal_ref)}; - test_case.add_expected_output(output_shape, o); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, proposal_v4_basic) { - const float iou_threshold = 0.7f; - const int min_bbox_size = 16; - const int feature_stride = 16; - const int pre_nms_topn = 6000; - const int post_nms_topn = 10; - const int image_w = 350; - const int image_h = 210; - const int image_z = 1; - const std::vector ratios = {0.5f}; - const std::vector scales = {32.0f}; - const int batch_size = 1; - - Shape class_probs_shape{batch_size, 2, 10, 10}; - Shape bbox_deltas_shape{batch_size, 4, 10, 10}; - Shape image_shape_shape{3}; - Shape output_shape = {batch_size * post_nms_topn, 5}; - Shape probs_shape = {batch_size * post_nms_topn}; - - op::ProposalAttrs attrs; - attrs.base_size = min_bbox_size; - attrs.min_size = min_bbox_size; - attrs.pre_nms_topn = pre_nms_topn; - attrs.post_nms_topn = post_nms_topn; - attrs.nms_thresh = iou_threshold; - attrs.feat_stride = feature_stride; - attrs.min_size = min_bbox_size; - attrs.ratio = ratios; - attrs.scale = scales; - attrs.clip_before_nms = true; - attrs.clip_after_nms = false; - attrs.normalize = false; - attrs.box_size_scale = 1.0f; - attrs.box_coordinate_scale = 1.0f; - attrs.framework = ""; - attrs.infer_probs = true; - - auto class_probs_param = make_shared(element::f32, class_probs_shape); - auto bbox_deltas_param = make_shared(element::f32, bbox_deltas_shape); - auto image_shape_param = make_shared(element::f32, image_shape_shape); - - auto proposal = make_shared(class_probs_param, bbox_deltas_param, image_shape_param, attrs); - auto f = make_shared(proposal, ParameterVector{class_probs_param, bbox_deltas_param, image_shape_param}); - - std::vector c{std::begin(cls_scores_data), std::end(cls_scores_data)}; - std::vector b{std::begin(bbox_pred_data), std::end(bbox_pred_data)}; - std::vector i{image_h, image_w, image_z}; - - auto test_case = test::TestCase(f); - test_case.add_input(class_probs_shape, c); - test_case.add_input(bbox_deltas_shape, b); - test_case.add_input(image_shape_shape, i); - - std::vector o{std::begin(proposal_ref), std::end(proposal_ref)}; - std::vector p{std::begin(probs_ref), std::end(probs_ref)}; - - test_case.add_expected_output(output_shape, o); - test_case.add_expected_output(probs_shape, p); - test_case.run(); -} diff --git a/ngraph/test/backend/psroi_pooling.in.cpp b/ngraph/test/backend/psroi_pooling.in.cpp deleted file mode 100644 index a24c8d34932..00000000000 --- a/ngraph/test/backend/psroi_pooling.in.cpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/op/psroi_pooling.hpp" -#include "util/test_control.hpp" - -using namespace ngraph; - -static std::string s_manifest = "${MANIFEST}"; -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -NGRAPH_TEST(${BACKEND_NAME}, psroi_pooling_average) { - size_t num_channels = 8; - size_t group_size = 2; - size_t output_dim = num_channels / (group_size * group_size); - size_t num_boxes = 3; - Shape image_shape{2, num_channels, 20, 20}; - Shape coords_shape{num_boxes, 5}; - auto image = std::make_shared(element::Type_t::f32, image_shape); - auto coords = std::make_shared(element::Type_t::f32, coords_shape); - auto f = std::make_shared( - std::make_shared(image, coords, output_dim, group_size, 1, 1, 1, "average"), - ParameterVector{image, coords}); - Shape output_shape{num_boxes, output_dim, group_size, group_size}; - - std::vector image_input(shape_size(image_shape)); - float val = 0; - std::generate(image_input.begin(), image_input.end(), [val]() mutable -> float { - return val += 0.1; - }); - std::vector coords_input{ - // batch_id, x1, y1, x2, y2 - 0, - 1, - 2, - 4, - 6, - 1, - 0, - 3, - 10, - 4, - 0, - 10, - 7, - 11, - 13, - }; - std::vector output{ - 6.2499962, 46.44986, 90.249184, 130.44876, 166.25095, 206.45341, 250.25606, 290.45853, - 326.36069, 366.86316, 408.36572, 448.86816, 486.37045, 526.86841, 568.35828, 608.84839, - 18.100033, 58.199684, 104.09898, 144.1996, 178.10167, 218.20412, 264.1069, 304.20935, - - }; - - auto tc = test::TestCase(f); - tc.add_input(image_input); - tc.add_input(coords_input); - tc.add_expected_output(output_shape, output); - tc.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, psroi_pooling_average_spatial_scale) { - size_t num_channels = 8; - size_t group_size = 2; - size_t output_dim = num_channels / (group_size * group_size); - size_t num_boxes = 4; - float spatial_scale = 0.2; - Shape image_shape{2, num_channels, 20, 20}; - Shape coords_shape{num_boxes, 5}; - auto image = std::make_shared(element::Type_t::f32, image_shape); - auto coords = std::make_shared(element::Type_t::f32, coords_shape); - auto f = std::make_shared( - std::make_shared(image, coords, output_dim, group_size, spatial_scale, 1, 1, "average"), - ParameterVector{image, coords}); - Shape output_shape{num_boxes, output_dim, group_size, group_size}; - - std::vector image_input(shape_size(image_shape)); - float val = 0; - std::generate(image_input.begin(), image_input.end(), [val]() mutable -> float { - return val += 0.1; - }); - std::vector coords_input{ - // batch_id, x1, y1, x2, y2 - 0, 5, 10, 20, 30, 0, 0, 15, 50, 20, 1, 50, 35, 55, 65, 1, 0, 60, 5, 70, - }; - std::vector output{ - 6.24999619, 46.399868, 90.2491837, 130.398758, 166.250946, 206.403397, 250.256058, 290.408508, - 6.34999657, 46.8498573, 87.3492432, 127.848656, 166.350952, 206.853409, 247.355896, 287.858368, - 338.11142, 378.163879, 424.116669, 464.169128, 498.121185, 538.165649, 584.104431, 624.144653, - 345.111847, 385.164307, 427.116852, 467.169312, 505.121613, 545.16394, 587.103699, 627.143921, - }; - - auto tc = test::TestCase(f); - tc.add_input(image_input); - tc.add_input(coords_input); - tc.add_expected_output(output_shape, output); - tc.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, psroi_pooling_bilinear) { - size_t num_channels = 12; - size_t group_size = 3; - size_t spatial_bins_x = 2; - size_t spatial_bins_y = 3; - size_t output_dim = num_channels / (spatial_bins_x * spatial_bins_y); - size_t num_boxes = 5; - Shape image_shape{2, num_channels, 20, 20}; - Shape coords_shape{num_boxes, 5}; - auto image = std::make_shared(element::Type_t::f32, image_shape); - auto coords = std::make_shared(element::Type_t::f32, coords_shape); - auto f = std::make_shared(std::make_shared(image, - coords, - output_dim, - group_size, - 1, - spatial_bins_x, - spatial_bins_y, - "bilinear"), - ParameterVector{image, coords}); - Shape output_shape{num_boxes, output_dim, group_size, group_size}; - - std::vector image_input(shape_size(image_shape)); - float val = 0; - std::generate(image_input.begin(), image_input.end(), [val]() mutable -> float { - return val += 0.1; - }); - std::vector coords_input{ - 0, 0.1, 0.2, 0.7, 0.4, 1, 0.4, 0.1, 0.9, 0.3, 0, 0.5, 0.7, - 0.7, 0.9, 1, 0.15, 0.3, 0.65, 0.35, 0, 0.0, 0.2, 0.7, 0.8, - }; - std::vector output{ - 210.71394, 210.99896, 211.28398, 211.98065, 212.26567, 212.55066, 213.24738, 213.53239, 213.8174, 250.71545, - 251.00047, 251.28548, 251.98218, 252.2672, 252.5522, 253.2489, 253.53392, 253.81892, 687.40869, 687.64606, - 687.88354, 688.67511, 688.91254, 689.14996, 689.94147, 690.17896, 690.41644, 727.40021, 727.6377, 727.87518, - 728.66669, 728.90405, 729.14154, 729.93292, 730.17041, 730.4079, 230.28471, 230.3797, 230.47472, 231.55144, - 231.64642, 231.74141, 232.81813, 232.91313, 233.00813, 270.28638, 270.38141, 270.47641, 271.5531, 271.64813, - 271.74313, 272.81985, 272.91486, 273.00986, 692.63281, 692.87018, 693.1076, 692.94928, 693.18683, 693.42426, - 693.26593, 693.50342, 693.74078, 732.62402, 732.86139, 733.09888, 732.94049, 733.17804, 733.41547, 733.25714, - 733.49463, 733.73199, 215.63843, 215.97093, 216.30345, 219.43855, 219.77106, 220.10358, 223.23871, 223.57123, - 223.90375, 255.63994, 255.97246, 256.30496, 259.44009, 259.77261, 260.10513, 263.2403, 263.57281, 263.9053, - - }; - - auto tc = test::TestCase(f); - tc.add_input(image_input); - tc.add_input(coords_input); - tc.add_expected_output(output_shape, output); - tc.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, psroi_pooling_bilinear_spatial_scale) { - size_t num_channels = 12; - size_t group_size = 4; - size_t spatial_bins_x = 2; - size_t spatial_bins_y = 3; - size_t output_dim = num_channels / (spatial_bins_x * spatial_bins_y); - size_t num_boxes = 6; - float spatial_scale = 0.5; - Shape image_shape{2, num_channels, 20, 20}; - Shape coords_shape{num_boxes, 5}; - auto image = std::make_shared(element::Type_t::f32, image_shape); - auto coords = std::make_shared(element::Type_t::f32, coords_shape); - auto f = std::make_shared(std::make_shared(image, - coords, - output_dim, - group_size, - spatial_scale, - spatial_bins_x, - spatial_bins_y, - "bilinear"), - ParameterVector{image, coords}); - Shape output_shape{num_boxes, output_dim, group_size, group_size}; - - std::vector image_input(shape_size(image_shape)); - float val = 0; - std::generate(image_input.begin(), image_input.end(), [val]() mutable -> float { - return val += 0.1; - }); - std::vector coords_input{ - 0, 0.1, 0.2, 0.7, 0.4, 0, 0.5, 0.7, 1.2, 1.3, 0, 1.0, 1.3, 1.2, 1.8, - 1, 0.5, 1.1, 0.7, 1.44, 1, 0.2, 1.1, 0.5, 1.2, 1, 0.34, 1.3, 1.15, 1.35, - }; - std::vector output{ - 205.40955, 205.50456, 205.59955, 205.69453, 205.83179, 205.9268, 206.0218, 206.11681, 206.25403, 206.34901, - 206.44403, 206.53905, 206.67627, 206.77126, 206.86627, 206.96129, 245.41107, 245.50606, 245.60106, 245.69604, - 245.8333, 245.9283, 246.02327, 246.1183, 246.25554, 246.35052, 246.44556, 246.54054, 246.67778, 246.77277, - 246.86775, 246.96278, 217.84717, 217.95801, 218.06885, 218.17969, 219.11389, 219.22473, 219.33557, 219.44641, - 220.3806, 220.49144, 220.60228, 220.71312, 221.64732, 221.75816, 221.86897, 221.97981, 257.84872, 257.95956, - 258.0704, 258.18124, 259.11545, 259.22629, 259.33713, 259.44797, 260.38217, 260.49301, 260.60385, 260.71469, - 261.6489, 261.75974, 261.87057, 261.98141, 228.9705, 229.00215, 229.03383, 229.06549, 230.02608, 230.05774, - 230.08943, 230.12109, 231.08168, 231.11334, 231.14502, 231.1767, 232.13728, 232.16895, 232.20062, 232.23228, - 268.97217, 269.00385, 269.03549, 269.06717, 270.02777, 270.05945, 270.09109, 270.12277, 271.08337, 271.11502, - 271.1467, 271.17838, 272.13901, 272.17065, 272.2023, 272.23398, 703.65057, 703.68219, 703.71387, 703.74554, - 704.36816, 704.39984, 704.43146, 704.4632, 705.08575, 705.11749, 705.14911, 705.18085, 705.80347, 705.83514, - 705.86676, 705.89844, 743.64136, 743.67291, 743.70459, 743.73633, 744.35889, 744.39056, 744.42218, 744.45392, - 745.07648, 745.10815, 745.13983, 745.17157, 745.79413, 745.82574, 745.85742, 745.8891, 701.86963, 701.91724, - 701.9646, 702.01221, 702.08081, 702.12823, 702.17578, 702.22321, 702.29181, 702.33936, 702.38678, 702.43433, - 702.50293, 702.55035, 702.5979, 702.64545, 741.86041, 741.90796, 741.95538, 742.00293, 742.07153, 742.11896, - 742.1665, 742.21405, 742.28253, 742.33008, 742.3775, 742.42505, 742.49365, 742.54108, 742.58862, 742.63617, - 705.60645, 705.73468, 705.86298, 705.99115, 705.71198, 705.84027, 705.96844, 706.09668, 705.81757, 705.94574, - 706.07397, 706.20215, 705.9231, 706.05127, 706.1795, 706.3078, 745.59698, 745.72534, 745.85352, 745.98169, - 745.70264, 745.83081, 745.95898, 746.08722, 745.80811, 745.93628, 746.06451, 746.19269, 745.91364, 746.04181, - 746.1701, 746.29834, - }; - - auto tc = test::TestCase(f); - tc.add_input(image_input); - tc.add_input(coords_input); - tc.add_expected_output(output_shape, output); - tc.run(); -}