@@ -21,6 +21,7 @@ struct NMSRotatedParams {
21
21
reference_tests::Tensor iouThreshold;
22
22
reference_tests::Tensor scoreThreshold;
23
23
reference_tests::Tensor softNmsSigma;
24
+ bool sortResultsDescending = true ;
24
25
bool clockwise = true ;
25
26
reference_tests::Tensor expectedSelectedIndices;
26
27
reference_tests::Tensor expectedSelectedScores;
@@ -35,6 +36,7 @@ struct Builder : ParamsBuilder<NMSRotatedParams> {
35
36
REFERENCE_TESTS_ADD_SET_PARAM (Builder, iouThreshold);
36
37
REFERENCE_TESTS_ADD_SET_PARAM (Builder, scoreThreshold);
37
38
REFERENCE_TESTS_ADD_SET_PARAM (Builder, softNmsSigma);
39
+ REFERENCE_TESTS_ADD_SET_PARAM (Builder, sortResultsDescending);
38
40
REFERENCE_TESTS_ADD_SET_PARAM (Builder, clockwise);
39
41
REFERENCE_TESTS_ADD_SET_PARAM (Builder, expectedSelectedIndices);
40
42
REFERENCE_TESTS_ADD_SET_PARAM (Builder, expectedSelectedScores);
@@ -91,7 +93,7 @@ class ReferenceNMSRotatedTest : public testing::TestWithParam<NMSRotatedParams>,
91
93
max_output_boxes_per_class,
92
94
iou_threshold,
93
95
score_threshold,
94
- false ,
96
+ params. sortResultsDescending ,
95
97
params.expectedSelectedIndices .type ,
96
98
params.clockwise );
97
99
return std::make_shared<Model>(nms->outputs (), ParameterVector{boxes, scores});
@@ -129,7 +131,7 @@ class ReferenceNMSRotatedTestWithoutConstants : public ReferenceNMSRotatedTest {
129
131
max_output_boxes_per_class,
130
132
iou_threshold,
131
133
score_threshold,
132
- false ,
134
+ params. sortResultsDescending ,
133
135
params.expectedSelectedIndices .type ,
134
136
params.clockwise );
135
137
return std::make_shared<Model>(
@@ -146,6 +148,8 @@ TEST_P(ReferenceNMSRotatedTestWithoutConstants, CompareWithRefs) {
146
148
Exec ();
147
149
}
148
150
151
+ // clang-format off
152
+ // To make the test data shape more readable
149
153
template <element::Type_t ET, element::Type_t ET_BOX, element::Type_t ET_TH, element::Type_t ET_IND>
150
154
std::vector<NMSRotatedParams> generateParams () {
151
155
using T = typename element_type_traits<ET>::value_type;
@@ -173,6 +177,140 @@ std::vector<NMSRotatedParams> generateParams() {
173
177
std::vector<T_TH>{0.0 , 0.0 , 0.96 , 0.0 , 0.0 , 0.7 , 0.0 , 0.0 , 0.65 }))
174
178
.expectedValidOutputs (reference_tests::Tensor (ET_IND, {1 }, std::vector<T_IND>{3 }))
175
179
.testcaseName (" NMSRotated_new_rotation_basic" ),
180
+ Builder{}
181
+ .boxes (reference_tests::Tensor (ET, {1 , 4 , 5 }, std::vector<T>{/* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
182
+ /* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
183
+ /* 2*/ 4.0 , 8.0 , 10.0 , 12.0 , 0.3 ,
184
+ /* 3*/ 2.0 , 5.0 , 13.0 , 7.0 , 0.6 }))
185
+ .scores (reference_tests::Tensor (ET, {1 , 2 , 4 }, std::vector<T>{/* 0*/ 0.65 , 0.7 , 0.55 , 0.96 , /* 1*/ 0.65 , 0.7 , 0.55 , 0.96 }))
186
+ .maxOutputBoxesPerClass (reference_tests::Tensor (ET_BOX, {}, std::vector<T_BOX>{5000 }))
187
+ .iouThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .5f }))
188
+ .scoreThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
189
+ .softNmsSigma (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
190
+ .sortResultsDescending (false )
191
+ .expectedSelectedIndices (reference_tests::Tensor (
192
+ ET_IND,
193
+ {6 , 3 },
194
+ std::vector<T_IND>{0 , 0 , 3 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 3 , 0 , 1 , 1 , 0 , 1 , 0 })) // batch, class, box_id (sorted max score first)
195
+ .expectedSelectedScores (
196
+ reference_tests::Tensor (ET_TH,
197
+ {6 , 3 },
198
+ std::vector<T_TH>{0.0 , 0.0 , 0.96 , 0.0 , 0.0 , 0.7 , 0.0 , 0.0 , 0.65 , 0.0 , 1.0 , 0.96 , 0.0 , 1.0 , 0.7 , 0.0 , 1.0 , 0.65 }))
199
+ .expectedValidOutputs (reference_tests::Tensor (ET_IND, {1 }, std::vector<T_IND>{6 }))
200
+ .testcaseName (" NMSRotated_new_rotation_class_2" ),
201
+ Builder{}
202
+ .boxes (reference_tests::Tensor (ET, {2 , 4 , 5 }, std::vector<T>{/* First batch */
203
+ /* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
204
+ /* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
205
+ /* 2*/ 4.0 , 8.0 , 10.0 , 12.0 , 0.3 ,
206
+ /* 3*/ 2.0 , 5.0 , 13.0 , 7.0 , 0.6 ,
207
+ /* Second batch */
208
+ /* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
209
+ /* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
210
+ /* 2*/ 4.0 , 8.0 , 10.0 , 12.0 , 0.3 ,
211
+ /* 3*/ 2.0 , 5.0 , 13.0 , 7.0 , 0.6 }))
212
+ .scores (reference_tests::Tensor (ET, {2 , 1 , 4 }, std::vector<T>{0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 }))
213
+ .maxOutputBoxesPerClass (reference_tests::Tensor (ET_BOX, {}, std::vector<T_BOX>{5000 }))
214
+ .iouThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .5f }))
215
+ .scoreThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
216
+ .softNmsSigma (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
217
+ .sortResultsDescending (false )
218
+ .expectedSelectedIndices (reference_tests::Tensor (
219
+ ET_IND,
220
+ {6 , 3 },
221
+ std::vector<T_IND>{0 , 0 , 3 , 0 , 0 , 1 , 0 , 0 , 0 ,
222
+ 1 , 0 , 3 , 1 , 0 , 1 , 1 , 0 , 0 })) // batch, class, box_id (sorted max score first)
223
+ .expectedSelectedScores (
224
+ reference_tests::Tensor (ET_TH,
225
+ {6 , 3 },
226
+ std::vector<T_TH>{0.0 , 0.0 , 0.96 , 0.0 , 0.0 , 0.7 , 0.0 , 0.0 , 0.65 , 1.0 , 0.0 , 0.96 , 1.0 , 0.0 , 0.7 , 1.0 , 0.0 , 0.65 }))
227
+ .expectedValidOutputs (reference_tests::Tensor (ET_IND, {1 }, std::vector<T_IND>{6 }))
228
+ .testcaseName (" NMSRotated_new_rotation_batch_2" ),
229
+ Builder{}
230
+ .boxes (reference_tests::Tensor (ET, {2 , 4 , 5 }, std::vector<T>{/* First batch */
231
+ /* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
232
+ /* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
233
+ /* 2*/ 4.0 , 8.0 , 10.0 , 12.0 , 0.3 ,
234
+ /* 3*/ 2.0 , 5.0 , 13.0 , 7.0 , 0.6 ,
235
+ /* Second batch */
236
+ /* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
237
+ /* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
238
+ /* 2*/ 4.0 , 8.0 , 10.0 , 12.0 , 0.3 ,
239
+ /* 3*/ 2.0 , 5.0 , 13.0 , 7.0 , 0.6 }))
240
+ .scores (reference_tests::Tensor (ET, {2 , 2 , 4 }, std::vector<T>{0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 ,
241
+ 0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 ,
242
+ 0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 ,
243
+ 0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 }))
244
+ .maxOutputBoxesPerClass (reference_tests::Tensor (ET_BOX, {}, std::vector<T_BOX>{5000 }))
245
+ .iouThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .5f }))
246
+ .scoreThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
247
+ .softNmsSigma (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
248
+ .sortResultsDescending (false )
249
+ .expectedSelectedIndices (reference_tests::Tensor (
250
+ ET_IND,
251
+ {12 , 3 },
252
+ std::vector<T_IND>{0 , 0 , 3 , 0 , 0 , 1 , 0 , 0 , 0 ,
253
+ 0 , 1 , 3 , 0 , 1 , 1 , 0 , 1 , 0 ,
254
+ 1 , 0 , 3 , 1 , 0 , 1 , 1 , 0 , 0 ,
255
+ 1 , 1 , 3 , 1 , 1 , 1 , 1 , 1 , 0 })) // batch, class, box_id (sorted max score first)
256
+ .expectedSelectedScores (
257
+ reference_tests::Tensor (ET_TH,
258
+ {12 , 3 },
259
+ std::vector<T_TH>{0.0 , 0.0 , 0.96 , 0.0 , 0.0 , 0.7 , 0.0 , 0.0 , 0.65 ,
260
+ 0.0 , 1.0 , 0.96 , 0.0 , 1.0 , 0.7 , 0.0 , 1.0 , 0.65 ,
261
+ 1.0 , 0.0 , 0.96 , 1.0 , 0.0 , 0.7 , 1.0 , 0.0 , 0.65 ,
262
+ 1.0 , 1.0 , 0.96 , 1.0 , 1.0 , 0.7 , 1.0 , 1.0 , 0.65 ,
263
+ }))
264
+
265
+ .expectedValidOutputs (reference_tests::Tensor (ET_IND, {1 }, std::vector<T_IND>{12 }))
266
+ .testcaseName (" NMSRotated_new_rotation_batch_2_class_2_sort_attr_false" ),
267
+ Builder{}
268
+ .boxes (reference_tests::Tensor (ET, {2 , 4 , 5 }, std::vector<T>{/* First batch */
269
+ /* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
270
+ /* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
271
+ /* 2*/ 4.0 , 8.0 , 10.0 , 12.0 , 0.3 ,
272
+ /* 3*/ 2.0 , 5.0 , 13.0 , 7.0 , 0.6 ,
273
+ /* Second batch */
274
+ /* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
275
+ /* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
276
+ /* 2*/ 4.0 , 8.0 , 10.0 , 12.0 , 0.3 ,
277
+ /* 3*/ 2.0 , 5.0 , 13.0 , 7.0 , 0.6 }))
278
+ .scores (reference_tests::Tensor (ET, {2 , 2 , 4 }, std::vector<T>{0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 ,
279
+ 0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 ,
280
+ 0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 ,
281
+ 0.65 , 0.7 , 0.55 , 0.96 , 0.65 , 0.7 , 0.55 , 0.96 }))
282
+ .maxOutputBoxesPerClass (reference_tests::Tensor (ET_BOX, {}, std::vector<T_BOX>{5000 }))
283
+ .iouThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .5f }))
284
+ .scoreThreshold (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
285
+ .softNmsSigma (reference_tests::Tensor (ET_TH, {}, std::vector<T_TH>{0 .0f }))
286
+ .sortResultsDescending (true )
287
+
288
+ .expectedSelectedIndices (reference_tests::Tensor (
289
+ ET_IND,
290
+ {12 , 3 },
291
+ std::vector<T_IND>{0 , 0 , 3 , 0 , 1 , 3 , 1 , 0 , 3 , 1 , 1 , 3 ,
292
+ 0 , 0 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 ,
293
+ 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 1 , 0 })) // batch, class, box_id (sorted max score first)
294
+ .expectedSelectedScores (
295
+ reference_tests::Tensor (ET_TH,
296
+ {12 , 3 },
297
+ std::vector<T_TH>{0.0 , 0.0 , 0.96 ,
298
+ 0.0 , 1.0 , 0.96 ,
299
+ 1.0 , 0.0 , 0.96 ,
300
+ 1.0 , 1.0 , 0.96 ,
301
+
302
+ 0.0 , 0.0 , 0.7 ,
303
+ 0.0 , 1.0 , 0.7 ,
304
+ 1.0 , 0.0 , 0.7 ,
305
+ 1.0 , 1.0 , 0.7 ,
306
+
307
+ 0.0 , 0.0 , 0.65 ,
308
+ 0.0 , 1.0 , 0.65 ,
309
+ 1.0 , 0.0 , 0.65 ,
310
+ 1.0 , 1.0 , 0.65
311
+ }))
312
+ .expectedValidOutputs (reference_tests::Tensor (ET_IND, {1 }, std::vector<T_IND>{12 }))
313
+ .testcaseName (" NMSRotated_new_rotation_batch_2_class_2_sort_attr_true" ),
176
314
Builder{}
177
315
.boxes (reference_tests::Tensor (ET, {1 , 4 , 5 }, std::vector<T>{/* 0*/ 7.0 , 4.0 , 8.0 , 7.0 , 0.5 ,
178
316
/* 1*/ 4.0 , 7.0 , 9.0 , 11.0 , 0.6 ,
@@ -418,6 +556,7 @@ std::vector<NMSRotatedParams> generateParams() {
418
556
};
419
557
return params;
420
558
}
559
+ // clang-format on
421
560
422
561
std::vector<NMSRotatedParams> generateCombinedParams () {
423
562
const std::vector<std::vector<NMSRotatedParams>> generatedParams{
0 commit comments