Skip to content

Commit

Permalink
Revert "Fix experimental detectron do ref impl (#10621)" (#12683) (#1…
Browse files Browse the repository at this point in the history
…3009)

* Revert "Fix experimental detectron do ref impl (#10621)"

This reverts commit d872338.

* Disabled Experimental Detectron per agreement with GPU team. Ticket to fix it: 90209
  • Loading branch information
jane-intel authored Sep 12, 2022
1 parent dcc8f92 commit af16ea1
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 265 deletions.
10 changes: 4 additions & 6 deletions docs/template_plugin/backend/evaluates_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,19 +2112,18 @@ bool evaluate(const shared_ptr<op::v6::ExperimentalDetectronDetectionOutput>& op
const HostTensorVector& outputs,
const HostTensorVector& inputs) {
const auto attrs = op->get_attrs();
const size_t output_roi_count = attrs.max_detections_per_image;
size_t rois_num = attrs.max_detections_per_image;

const Shape output_boxes_shape = Shape{output_roi_count, 4};
const Shape output_classes_shape = Shape{output_roi_count};
const Shape output_scores_shape = Shape{output_roi_count};
const Shape output_boxes_shape = Shape{rois_num, 4};
const Shape output_classes_shape = Shape{rois_num};
const Shape output_scores_shape = Shape{rois_num};

const auto output_type = op->get_input_element_type(0);

const auto boxes_data = get_floats(inputs[0], inputs[0]->get_shape());
const auto input_deltas_data = get_floats(inputs[1], inputs[1]->get_shape());
const auto input_scores_data = get_floats(inputs[2], inputs[2]->get_shape());
const auto input_im_info_data = get_floats(inputs[3], inputs[3]->get_shape());
const auto input_roi_count = inputs[0]->get_shape()[0];

std::vector<float> output_boxes(shape_size(output_boxes_shape));
std::vector<int32_t> output_classes(shape_size(output_classes_shape));
Expand All @@ -2141,7 +2140,6 @@ bool evaluate(const shared_ptr<op::v6::ExperimentalDetectronDetectionOutput>& op
input_deltas_data.data(),
input_scores_data.data(),
input_im_info_data.data(),
input_roi_count,
attrs,
output_boxes.data(),
output_scores.data(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/op/experimental_detectron_detection_output.hpp"

#include <gtest/gtest.h>

#include "openvino/op/experimental_detectron_detection_output.hpp"
#include "base_reference_test.hpp"

using namespace reference_tests;
Expand All @@ -19,13 +18,9 @@ struct ExperimentalDOParams {
ExperimentalDOParams(const Attrs& attrs,
const size_t num_rois,
const element::Type& iType,
const std::vector<IT>& roisValues,
const std::vector<IT>& deltasValues,
const std::vector<IT>& scoresValues,
const std::vector<IT>& imageSizeInfoValues,
const std::vector<IT>& refBoxesValues,
const std::vector<int32_t>& refClassesValues,
const std::vector<IT>& refScoresValues,
const std::vector<IT>& roisValues, const std::vector<IT>& deltasValues,
const std::vector<IT>& scoresValues, const std::vector<IT>& imageSizeInfoValues,
const std::vector<IT>& refBoxesValues, const std::vector<int32_t>& refClassesValues, const std::vector<IT>& refScoresValues,
const std::string& testcaseName = "")
: attrs(attrs),
inType(iType),
Expand All @@ -38,11 +33,11 @@ struct ExperimentalDOParams {
refClassesData(CreateTensor(ov::element::i32, refClassesValues)),
refScoresData(CreateTensor(iType, refScoresValues)),
testcaseName(testcaseName) {
roisShape = Shape{num_rois, 4};
deltasShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes * 4)};
scoresShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes)};
imageSizeInfoShape = Shape{1, 3};
}
roisShape = Shape{num_rois, 4};
deltasShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes * 4)};
scoresShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes)};
imageSizeInfoShape = Shape{1, 3};
}

Attrs attrs;
PartialShape roisShape;
Expand All @@ -61,8 +56,7 @@ struct ExperimentalDOParams {
std::string testcaseName;
};

class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<ExperimentalDOParams>,
public CommonReferenceTest {
class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<ExperimentalDOParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
Expand Down Expand Up @@ -90,9 +84,12 @@ class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<Experimen
const auto deltas = std::make_shared<op::v0::Parameter>(params.inType, params.deltasShape);
const auto scores = std::make_shared<op::v0::Parameter>(params.inType, params.scoresShape);
const auto im_info = std::make_shared<op::v0::Parameter>(params.inType, params.imageSizeInfoShape);
const auto ExperimentalDO =
std::make_shared<op::v6::ExperimentalDetectronDetectionOutput>(rois, deltas, scores, im_info, params.attrs);
return std::make_shared<ov::Model>(ExperimentalDO->outputs(), ParameterVector{rois, deltas, scores, im_info});
const auto ExperimentalDO = std::make_shared<op::v6::ExperimentalDetectronDetectionOutput>(rois,
deltas,
scores,
im_info,
params.attrs);
return std::make_shared<ov::Model>(ExperimentalDO->outputs(), ParameterVector {rois, deltas, scores, im_info});
}
};

Expand All @@ -104,54 +101,68 @@ template <element::Type_t IN_ET>
std::vector<ExperimentalDOParams> generateExperimentalDOFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;

std::vector<ExperimentalDOParams> experimentalDOParams{
ExperimentalDOParams(
Attrs{
0.01000000074505806f, // score_threshold
0.2f, // nms_threshold
2.0f, // max_delta_log_wh
2, // num_classes
500, // post_nms_count
5, // max_detections_per_image
true, // class_agnostic_box_regression
{10.0f, 10.0f, 5.0f, 5.0f} // deltas_weights
},
16,
IN_ET,
std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 4.0f,
1.0f, 8.0f, 5.0f, 1.0f, 1.0f, 10.0f, 10.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,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ector<T>{4.8929863f, 0.892986298f, 12.0f, 12.1070137f, 0.0f, 0.892986298f, 10.1070137f,
12.1070137f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
std::vector<int32_t>{0, 1, 0, 0, 0},
std::vector<T>{0.8f, 0.9f, 0.0f, 0.0f, 0.0f}),
std::vector<ExperimentalDOParams> experimentalDOParams {
ExperimentalDOParams(Attrs{0.01000000074505806f, // score_threshold
0.2f, // nms_threshold
2.0f, // max_delta_log_wh
2, // num_classes
500, // post_nms_count
5, // max_detections_per_image
true, // class_agnostic_box_regression
{10.0f, 10.0f, 5.0f, 5.0f} // deltas_weights
},
16,
IN_ET,
std::vector<T>{1.0f, 1.0f, 10.0f, 10.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 8.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 8.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,

1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f},
std::vector<T>{0.8929862f,
0.892986297607421875,
12.10701370239257812,
12.10701370239257812,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0},
std::vector<int32_t>{1, 0, 0, 0, 0},
std::vector<T>{1.0f, 0.0f, 0.0f, 0.0f, 0.0f}),
};
return experimentalDOParams;
}

std::vector<ExperimentalDOParams> generateExperimentalDOCombinedParams() {
const std::vector<std::vector<ExperimentalDOParams>> ExperimentalDOTypeParams{
const std::vector<std::vector<ExperimentalDOParams>> ExperimentalDOTypeParams {
generateExperimentalDOFloatParams<element::Type_t::f32>(),
generateExperimentalDOFloatParams<element::Type_t::f16>(),
generateExperimentalDOFloatParams<element::Type_t::bf16>(),
};
};
std::vector<ExperimentalDOParams> combinedParams;

for (const auto& params : ExperimentalDOTypeParams) {
Expand All @@ -160,8 +171,6 @@ std::vector<ExperimentalDOParams> generateExperimentalDOCombinedParams() {
return combinedParams;
}

INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronDetectionOutput_With_Hardcoded_Refs,
ReferenceExperimentalDOLayerTest,
testing::ValuesIn(generateExperimentalDOCombinedParams()),
ReferenceExperimentalDOLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronDetectionOutput_With_Hardcoded_Refs, ReferenceExperimentalDOLayerTest,
testing::ValuesIn(generateExperimentalDOCombinedParams()), ReferenceExperimentalDOLayerTest::getTestCaseName);
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void experimental_detectron_detection_output(const float* input_rois,
const float* input_deltas,
const float* input_scores,
const float* input_im_info,
size_t roi_count,
const op::v6::ExperimentalDetectronDetectionOutput::Attributes& attrs,
float* output_boxes,
float* output_scores,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void refine_boxes(const float* boxes,
const float ctr_x = x0 + 0.5f * ww;
const float ctr_y = y0 + 0.5f * hh;

for (int class_idx = 0; class_idx < classes_num; ++class_idx) {
for (int class_idx = 1; class_idx < classes_num; ++class_idx) {
const int64_t deltas_base_offset = classes_num * 4 * roi_idx + 4 * class_idx;
const float dx = deltas[deltas_base_offset + 0] / weights[0];
const float dy = deltas[deltas_base_offset + 1] / weights[1];
Expand All @@ -76,10 +76,10 @@ void refine_boxes(const float* boxes,
float y1_new = pred_ctr_y + 0.5f * pred_h - coordinates_offset;

// adjust new corner locations to be within the image region,
x0_new = std::min(std::max(0.0f, x0_new), img_W);
y0_new = std::min(std::max(0.0f, y0_new), img_H);
x1_new = std::min(std::max(0.0f, x1_new), img_W);
y1_new = std::min(std::max(0.0f, y1_new), img_H);
x0_new = std::max<float>(0.0f, x0_new);
y0_new = std::max<float>(0.0f, y0_new);
x1_new = std::max<float>(0.0f, x1_new);
y1_new = std::max<float>(0.0f, y1_new);

// recompute new width & height
const float box_w = x1_new - x0_new + coordinates_offset;
Expand Down Expand Up @@ -214,15 +214,14 @@ void experimental_detectron_detection_output(const float* boxes,
const float* input_deltas,
const float* input_scores,
const float* input_im_info,
size_t roi_count,
const op::v6::ExperimentalDetectronDetectionOutput::Attributes& attrs,
float* output_boxes,
float* output_scores,
int32_t* output_classes) {
const float img_H = input_im_info[0];
const float img_W = input_im_info[1];
const int64_t classes_num = attrs.num_classes;
const int64_t rois_num = static_cast<int64_t>(roi_count);
const int64_t rois_num = static_cast<int64_t>(attrs.max_detections_per_image);
const int64_t max_detections_per_image = static_cast<int64_t>(attrs.max_detections_per_image);
const int64_t max_detections_per_class = attrs.post_nms_count;
const float score_threshold = attrs.score_threshold;
Expand Down Expand Up @@ -256,7 +255,7 @@ void experimental_detectron_detection_output(const float* boxes,
std::vector<int64_t> detections_per_class(classes_num, 0);
int64_t total_detections_num = 0;

for (int64_t class_idx = 0; class_idx < classes_num; ++class_idx) {
for (int64_t class_idx = 1; class_idx < classes_num; ++class_idx) {
nms_cf(&refined_scores[rois_num * class_idx],
&refined_boxes[rois_num * 4 * class_idx],
&refined_boxes_areas[rois_num * class_idx],
Expand Down
Loading

0 comments on commit af16ea1

Please sign in to comment.