COMPMID-1849: Add DetectorPostProcess operator
Part1 - Rework of CPPNonMaximumSuppression

Change-Id: I2b34fbd12188db49b0ac050a12312494eeefd819
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1585
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
diff --git a/tests/SConscript b/tests/SConscript
index 103874f..c8de603 100644
--- a/tests/SConscript
+++ b/tests/SConscript
@@ -32,7 +32,7 @@
 variables = [
     #FIXME: Remove before release!
     BoolVariable("benchmark_examples", "Build benchmark examples programs", True),
-    BoolVariable("validate_examples", "Build benchmark examples programs", True),
+    BoolVariable("validate_examples", "Build validate examples programs", True),
     #FIXME Switch the following two options to False before releasing
     BoolVariable("validation_tests", "Build validation test programs", True),
     BoolVariable("benchmark_tests", "Build benchmark test programs", True),
diff --git a/tests/validation/CPP/NonMaximalSuppression.cpp b/tests/validation/CPP/NonMaximumSuppression.cpp
similarity index 93%
rename from tests/validation/CPP/NonMaximalSuppression.cpp
rename to tests/validation/CPP/NonMaximumSuppression.cpp
index 6cd7b52..bf24b2c 100644
--- a/tests/validation/CPP/NonMaximalSuppression.cpp
+++ b/tests/validation/CPP/NonMaximumSuppression.cpp
@@ -22,7 +22,7 @@
  * SOFTWARE.
  */
 #include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/CPP/functions/CPPDetectionOutputLayer.h"
+#include "arm_compute/runtime/CPP/functions/CPPNonMaximumSuppression.h"
 #include "arm_compute/runtime/Tensor.h"
 #include "arm_compute/runtime/TensorAllocator.h"
 #include "tests/NEON/Accessor.h"
@@ -42,11 +42,11 @@
 {
 namespace
 {
-const auto max_output_boxes_dataset = framework::dataset::make("MaxOutputBoxes", 1, 10);
-const auto score_threshold_dataset  = framework::dataset::make("ScoreThreshold", { 0.1f, 0.5f, 0.f, 1.f });
-const auto nms_threshold_dataset    = framework::dataset::make("NMSThreshold", { 0.1f, 0.5f, 0.f, 1.f });
-const auto NMSParametersSmall       = datasets::Small2DNonMaxSuppressionShapes() * max_output_boxes_dataset * score_threshold_dataset * nms_threshold_dataset;
-const auto NMSParametersBig         = datasets::Large2DNonMaxSuppressionShapes() * max_output_boxes_dataset * score_threshold_dataset * nms_threshold_dataset;
+const auto max_output_boxes_dataset  = framework::dataset::make("MaxOutputBoxes", 1, 10);
+const auto score_threshold_dataset   = framework::dataset::make("ScoreThreshold", { 0.1f, 0.5f, 0.f, 1.f });
+const auto iou_nms_threshold_dataset = framework::dataset::make("NMSThreshold", { 0.1f, 0.5f, 0.f, 1.f });
+const auto NMSParametersSmall        = datasets::Small2DNonMaxSuppressionShapes() * max_output_boxes_dataset * score_threshold_dataset * iou_nms_threshold_dataset;
+const auto NMSParametersBig          = datasets::Large2DNonMaxSuppressionShapes() * max_output_boxes_dataset * score_threshold_dataset * iou_nms_threshold_dataset;
 
 } // namespace
 
@@ -137,8 +137,8 @@
     validate(Accessor(_target), _reference);
 }
 
-TEST_SUITE_END() // CPP
 TEST_SUITE_END() // NMS
+TEST_SUITE_END() // CPP
 } // namespace validation
 } // namespace test
 } // namespace arm_compute
diff --git a/tests/validation/reference/NonMaxSuppression.cpp b/tests/validation/reference/NonMaxSuppression.cpp
index 5b7980d..8fc370b 100644
--- a/tests/validation/reference/NonMaxSuppression.cpp
+++ b/tests/validation/reference/NonMaxSuppression.cpp
@@ -76,10 +76,10 @@
 inline float compute_intersection(const std::pair<float, float> &b0_min, const std::pair<float, float> &b0_max,
                                   const std::pair<float, float> &b1_min, const std::pair<float, float> &b1_max, float b0_size, float b1_size)
 {
-    const float inter = std::max<float>(std::min<float>(b0_max.first, b1_max.first) - std::max<float>(b0_min.first, b1_min.first), 0.0) * std::max<float>(std::min<float>(b0_max.second,
+    const float inter = std::max<float>(std::min<float>(b0_max.first, b1_max.first) - std::max<float>(b0_min.first, b1_min.first), 0.0f) * std::max<float>(std::min<float>(b0_max.second,
                         b1_max.second)
                         - std::max<float>(b0_min.second, b1_min.second),
-                        0.0);
+                        0.0f);
     return inter / (b0_size + b1_size - inter);
 }
 
@@ -107,7 +107,7 @@
     std::vector<CandidateBox> candidates_vector;
     for(int i = 0; i < scores.num_elements(); ++i)
     {
-        if(scores[i] > threshold)
+        if(scores[i] >= threshold)
         {
             const auto cb = CandidateBox({ i, scores[i] });
             candidates_vector.push_back(cb);
@@ -115,7 +115,7 @@
     }
     std::stable_sort(candidates_vector.begin(), candidates_vector.end(), [](const CandidateBox bb0, const CandidateBox bb1)
     {
-        return bb0.second >= bb1.second;
+        return bb0.second > bb1.second;
     });
     return candidates_vector;
 }
@@ -155,6 +155,12 @@
         }
     }
     std::copy_n(selected.begin(), selected.size(), indices.data());
+
+    for(unsigned int i = selected.size(); i < max_output_size; ++i)
+    {
+        indices[i] = -1;
+    }
+
     return indices;
 }
 } // namespace reference