Skip to content

Commit af16ea1

Browse files
author
Evgenya Stepyreva
authored
Revert "Fix experimental detectron do ref impl (openvinotoolkit#10621)" (openvinotoolkit#12683) (openvinotoolkit#13009)
* Revert "Fix experimental detectron do ref impl (openvinotoolkit#10621)" This reverts commit d872338. * Disabled Experimental Detectron per agreement with GPU team. Ticket to fix it: 90209
1 parent dcc8f92 commit af16ea1

File tree

8 files changed

+246
-265
lines changed

8 files changed

+246
-265
lines changed

docs/template_plugin/backend/evaluates_map.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -2112,19 +2112,18 @@ bool evaluate(const shared_ptr<op::v6::ExperimentalDetectronDetectionOutput>& op
21122112
const HostTensorVector& outputs,
21132113
const HostTensorVector& inputs) {
21142114
const auto attrs = op->get_attrs();
2115-
const size_t output_roi_count = attrs.max_detections_per_image;
2115+
size_t rois_num = attrs.max_detections_per_image;
21162116

2117-
const Shape output_boxes_shape = Shape{output_roi_count, 4};
2118-
const Shape output_classes_shape = Shape{output_roi_count};
2119-
const Shape output_scores_shape = Shape{output_roi_count};
2117+
const Shape output_boxes_shape = Shape{rois_num, 4};
2118+
const Shape output_classes_shape = Shape{rois_num};
2119+
const Shape output_scores_shape = Shape{rois_num};
21202120

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

21232123
const auto boxes_data = get_floats(inputs[0], inputs[0]->get_shape());
21242124
const auto input_deltas_data = get_floats(inputs[1], inputs[1]->get_shape());
21252125
const auto input_scores_data = get_floats(inputs[2], inputs[2]->get_shape());
21262126
const auto input_im_info_data = get_floats(inputs[3], inputs[3]->get_shape());
2127-
const auto input_roi_count = inputs[0]->get_shape()[0];
21282127

21292128
std::vector<float> output_boxes(shape_size(output_boxes_shape));
21302129
std::vector<int32_t> output_classes(shape_size(output_classes_shape));
@@ -2141,7 +2140,6 @@ bool evaluate(const shared_ptr<op::v6::ExperimentalDetectronDetectionOutput>& op
21412140
input_deltas_data.data(),
21422141
input_scores_data.data(),
21432142
input_im_info_data.data(),
2144-
input_roi_count,
21452143
attrs,
21462144
output_boxes.data(),
21472145
output_scores.data(),

docs/template_plugin/tests/functional/op_reference/experimental_detectron_detection_output.cpp

+73-64
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5-
#include "openvino/op/experimental_detectron_detection_output.hpp"
6-
75
#include <gtest/gtest.h>
86

7+
#include "openvino/op/experimental_detectron_detection_output.hpp"
98
#include "base_reference_test.hpp"
109

1110
using namespace reference_tests;
@@ -19,13 +18,9 @@ struct ExperimentalDOParams {
1918
ExperimentalDOParams(const Attrs& attrs,
2019
const size_t num_rois,
2120
const element::Type& iType,
22-
const std::vector<IT>& roisValues,
23-
const std::vector<IT>& deltasValues,
24-
const std::vector<IT>& scoresValues,
25-
const std::vector<IT>& imageSizeInfoValues,
26-
const std::vector<IT>& refBoxesValues,
27-
const std::vector<int32_t>& refClassesValues,
28-
const std::vector<IT>& refScoresValues,
21+
const std::vector<IT>& roisValues, const std::vector<IT>& deltasValues,
22+
const std::vector<IT>& scoresValues, const std::vector<IT>& imageSizeInfoValues,
23+
const std::vector<IT>& refBoxesValues, const std::vector<int32_t>& refClassesValues, const std::vector<IT>& refScoresValues,
2924
const std::string& testcaseName = "")
3025
: attrs(attrs),
3126
inType(iType),
@@ -38,11 +33,11 @@ struct ExperimentalDOParams {
3833
refClassesData(CreateTensor(ov::element::i32, refClassesValues)),
3934
refScoresData(CreateTensor(iType, refScoresValues)),
4035
testcaseName(testcaseName) {
41-
roisShape = Shape{num_rois, 4};
42-
deltasShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes * 4)};
43-
scoresShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes)};
44-
imageSizeInfoShape = Shape{1, 3};
45-
}
36+
roisShape = Shape{num_rois, 4};
37+
deltasShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes * 4)};
38+
scoresShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes)};
39+
imageSizeInfoShape = Shape{1, 3};
40+
}
4641

4742
Attrs attrs;
4843
PartialShape roisShape;
@@ -61,8 +56,7 @@ struct ExperimentalDOParams {
6156
std::string testcaseName;
6257
};
6358

64-
class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<ExperimentalDOParams>,
65-
public CommonReferenceTest {
59+
class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<ExperimentalDOParams>, public CommonReferenceTest {
6660
public:
6761
void SetUp() override {
6862
auto params = GetParam();
@@ -90,9 +84,12 @@ class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<Experimen
9084
const auto deltas = std::make_shared<op::v0::Parameter>(params.inType, params.deltasShape);
9185
const auto scores = std::make_shared<op::v0::Parameter>(params.inType, params.scoresShape);
9286
const auto im_info = std::make_shared<op::v0::Parameter>(params.inType, params.imageSizeInfoShape);
93-
const auto ExperimentalDO =
94-
std::make_shared<op::v6::ExperimentalDetectronDetectionOutput>(rois, deltas, scores, im_info, params.attrs);
95-
return std::make_shared<ov::Model>(ExperimentalDO->outputs(), ParameterVector{rois, deltas, scores, im_info});
87+
const auto ExperimentalDO = std::make_shared<op::v6::ExperimentalDetectronDetectionOutput>(rois,
88+
deltas,
89+
scores,
90+
im_info,
91+
params.attrs);
92+
return std::make_shared<ov::Model>(ExperimentalDO->outputs(), ParameterVector {rois, deltas, scores, im_info});
9693
}
9794
};
9895

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

107-
std::vector<ExperimentalDOParams> experimentalDOParams{
108-
ExperimentalDOParams(
109-
Attrs{
110-
0.01000000074505806f, // score_threshold
111-
0.2f, // nms_threshold
112-
2.0f, // max_delta_log_wh
113-
2, // num_classes
114-
500, // post_nms_count
115-
5, // max_detections_per_image
116-
true, // class_agnostic_box_regression
117-
{10.0f, 10.0f, 5.0f, 5.0f} // deltas_weights
118-
},
119-
16,
120-
IN_ET,
121-
std::vector<T>{1.0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0f, 1.0f, 1.0f, 1.0f, 1.0f,
133-
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,
134-
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
135-
136-
std::vector<T>{0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.8f, 0.9f, 0.5f,
137-
0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
138-
0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f},
139-
std::vector<T>{16.0f, 12.0f, 1.0f},
140-
std::vector<T>{4.8929863f, 0.892986298f, 12.0f, 12.1070137f, 0.0f, 0.892986298f, 10.1070137f,
141-
12.1070137f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
142-
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
143-
std::vector<int32_t>{0, 1, 0, 0, 0},
144-
std::vector<T>{0.8f, 0.9f, 0.0f, 0.0f, 0.0f}),
104+
std::vector<ExperimentalDOParams> experimentalDOParams {
105+
ExperimentalDOParams(Attrs{0.01000000074505806f, // score_threshold
106+
0.2f, // nms_threshold
107+
2.0f, // max_delta_log_wh
108+
2, // num_classes
109+
500, // post_nms_count
110+
5, // max_detections_per_image
111+
true, // class_agnostic_box_regression
112+
{10.0f, 10.0f, 5.0f, 5.0f} // deltas_weights
113+
},
114+
16,
115+
IN_ET,
116+
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,
117+
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,
118+
1.0f,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, 1.0f},
130+
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,
131+
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
132+
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
133+
std::vector<T>{1.0f, 1.0f, 1.0f},
134+
std::vector<T>{0.8929862f,
135+
0.892986297607421875,
136+
12.10701370239257812,
137+
12.10701370239257812,
138+
0.0f,
139+
0.0f,
140+
0.0f,
141+
0.0f,
142+
0.0f,
143+
0.0f,
144+
0.0f,
145+
0.0f,
146+
0.0f,
147+
0.0f,
148+
0.0f,
149+
0.0f,
150+
0.0f,
151+
0.0f,
152+
0.0f,
153+
0.0},
154+
std::vector<int32_t>{1, 0, 0, 0, 0},
155+
std::vector<T>{1.0f, 0.0f, 0.0f, 0.0f, 0.0f}),
145156
};
146157
return experimentalDOParams;
147158
}
148159

149160
std::vector<ExperimentalDOParams> generateExperimentalDOCombinedParams() {
150-
const std::vector<std::vector<ExperimentalDOParams>> ExperimentalDOTypeParams{
161+
const std::vector<std::vector<ExperimentalDOParams>> ExperimentalDOTypeParams {
151162
generateExperimentalDOFloatParams<element::Type_t::f32>(),
152163
generateExperimentalDOFloatParams<element::Type_t::f16>(),
153164
generateExperimentalDOFloatParams<element::Type_t::bf16>(),
154-
};
165+
};
155166
std::vector<ExperimentalDOParams> combinedParams;
156167

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

163-
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronDetectionOutput_With_Hardcoded_Refs,
164-
ReferenceExperimentalDOLayerTest,
165-
testing::ValuesIn(generateExperimentalDOCombinedParams()),
166-
ReferenceExperimentalDOLayerTest::getTestCaseName);
167-
} // namespace
174+
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronDetectionOutput_With_Hardcoded_Refs, ReferenceExperimentalDOLayerTest,
175+
testing::ValuesIn(generateExperimentalDOCombinedParams()), ReferenceExperimentalDOLayerTest::getTestCaseName);
176+
} // namespace

src/core/reference/include/ngraph/runtime/reference/experimental_detectron_detection_output.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ void experimental_detectron_detection_output(const float* input_rois,
3434
const float* input_deltas,
3535
const float* input_scores,
3636
const float* input_im_info,
37-
size_t roi_count,
3837
const op::v6::ExperimentalDetectronDetectionOutput::Attributes& attrs,
3938
float* output_boxes,
4039
float* output_scores,

src/core/reference/src/runtime/reference/experimental_detectron_detection_output.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void refine_boxes(const float* boxes,
5454
const float ctr_x = x0 + 0.5f * ww;
5555
const float ctr_y = y0 + 0.5f * hh;
5656

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

7878
// adjust new corner locations to be within the image region,
79-
x0_new = std::min(std::max(0.0f, x0_new), img_W);
80-
y0_new = std::min(std::max(0.0f, y0_new), img_H);
81-
x1_new = std::min(std::max(0.0f, x1_new), img_W);
82-
y1_new = std::min(std::max(0.0f, y1_new), img_H);
79+
x0_new = std::max<float>(0.0f, x0_new);
80+
y0_new = std::max<float>(0.0f, y0_new);
81+
x1_new = std::max<float>(0.0f, x1_new);
82+
y1_new = std::max<float>(0.0f, y1_new);
8383

8484
// recompute new width & height
8585
const float box_w = x1_new - x0_new + coordinates_offset;
@@ -214,15 +214,14 @@ void experimental_detectron_detection_output(const float* boxes,
214214
const float* input_deltas,
215215
const float* input_scores,
216216
const float* input_im_info,
217-
size_t roi_count,
218217
const op::v6::ExperimentalDetectronDetectionOutput::Attributes& attrs,
219218
float* output_boxes,
220219
float* output_scores,
221220
int32_t* output_classes) {
222221
const float img_H = input_im_info[0];
223222
const float img_W = input_im_info[1];
224223
const int64_t classes_num = attrs.num_classes;
225-
const int64_t rois_num = static_cast<int64_t>(roi_count);
224+
const int64_t rois_num = static_cast<int64_t>(attrs.max_detections_per_image);
226225
const int64_t max_detections_per_image = static_cast<int64_t>(attrs.max_detections_per_image);
227226
const int64_t max_detections_per_class = attrs.post_nms_count;
228227
const float score_threshold = attrs.score_threshold;
@@ -256,7 +255,7 @@ void experimental_detectron_detection_output(const float* boxes,
256255
std::vector<int64_t> detections_per_class(classes_num, 0);
257256
int64_t total_detections_num = 0;
258257

259-
for (int64_t class_idx = 0; class_idx < classes_num; ++class_idx) {
258+
for (int64_t class_idx = 1; class_idx < classes_num; ++class_idx) {
260259
nms_cf(&refined_scores[rois_num * class_idx],
261260
&refined_boxes[rois_num * 4 * class_idx],
262261
&refined_boxes_areas[rois_num * class_idx],

0 commit comments

Comments
 (0)