aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference
diff options
context:
space:
mode:
authorgiuros01 <giuseppe.rossini@arm.com>2018-10-03 12:44:35 +0100
committerAnthony Barbier <Anthony.barbier@arm.com>2018-11-15 09:13:14 +0000
commitcd96a26f67bfbb9b0efe6e0e2b229d0b46b4e3e6 (patch)
treebe95114ff6f5a8a17dace8734be6239312631cea /tests/validation/reference
parent1c32bf396eb690a54fd94487e3f258b2c7d31753 (diff)
downloadComputeLibrary-cd96a26f67bfbb9b0efe6e0e2b229d0b46b4e3e6.tar.gz
COMPMID-1329: Add support for GenerateProposals operator in CL
Change-Id: Ib0798cc17496b7817f5b5769b25d98913a33a69d
Diffstat (limited to 'tests/validation/reference')
-rw-r--r--tests/validation/reference/BoundingBoxTransform.cpp8
-rw-r--r--tests/validation/reference/ComputeAllAnchors.cpp79
-rw-r--r--tests/validation/reference/ComputeAllAnchors.h45
3 files changed, 128 insertions, 4 deletions
diff --git a/tests/validation/reference/BoundingBoxTransform.cpp b/tests/validation/reference/BoundingBoxTransform.cpp
index 6ac512e749..9918ff68c5 100644
--- a/tests/validation/reference/BoundingBoxTransform.cpp
+++ b/tests/validation/reference/BoundingBoxTransform.cpp
@@ -84,10 +84,10 @@ SimpleTensor<T> bounding_box_transform(const SimpleTensor<T> &boxes, const Simpl
const T pred_h = T(std::exp(dh)) * height;
// Store the prediction into the output tensor
- pred_boxes_ptr[start_delta] = scale * utility::clamp<T>(pred_ctr_x - T(0.5) * pred_w, T(0), T(img_w));
- pred_boxes_ptr[start_delta + 1] = scale * utility::clamp<T>(pred_ctr_y - T(0.5) * pred_h, T(0), T(img_h));
- pred_boxes_ptr[start_delta + 2] = scale * utility::clamp<T>(pred_ctr_x + T(0.5) * pred_w, T(0), T(img_w));
- pred_boxes_ptr[start_delta + 3] = scale * utility::clamp<T>(pred_ctr_y + T(0.5) * pred_h, T(0), T(img_h));
+ pred_boxes_ptr[start_delta] = scale * utility::clamp<T>(pred_ctr_x - T(0.5) * pred_w, T(0), T(img_w - 1));
+ pred_boxes_ptr[start_delta + 1] = scale * utility::clamp<T>(pred_ctr_y - T(0.5) * pred_h, T(0), T(img_h - 1));
+ pred_boxes_ptr[start_delta + 2] = scale * utility::clamp<T>(pred_ctr_x + T(0.5) * pred_w, T(0), T(img_w - 1));
+ pred_boxes_ptr[start_delta + 3] = scale * utility::clamp<T>(pred_ctr_y + T(0.5) * pred_h, T(0), T(img_h - 1));
}
}
return pred_boxes;
diff --git a/tests/validation/reference/ComputeAllAnchors.cpp b/tests/validation/reference/ComputeAllAnchors.cpp
new file mode 100644
index 0000000000..48f4767fae
--- /dev/null
+++ b/tests/validation/reference/ComputeAllAnchors.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "ComputeAllAnchors.h"
+
+#include "arm_compute/core/Types.h"
+#include "arm_compute/core/utils/misc/ShapeCalculator.h"
+#include "arm_compute/core/utils/misc/Utility.h"
+#include "tests/validation/Helpers.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace reference
+{
+template <typename T>
+SimpleTensor<T> compute_all_anchors(const SimpleTensor<T> &anchors, const ComputeAnchorsInfo &info)
+{
+ const int num_anchors = anchors.shape()[1];
+ const auto width = int(info.feat_width());
+ const auto height = int(info.feat_height());
+ const float stride = 1. / info.spatial_scale();
+
+ SimpleTensor<T> all_anchors(TensorShape(4, width * height * num_anchors), anchors.data_type());
+ const T *anchors_ptr = anchors.data();
+ T *all_anchors_ptr = all_anchors.data();
+
+ // Iterate over the input grid and anchors
+ for(int y = 0; y < height; y++)
+ {
+ for(int x = 0; x < width; x++)
+ {
+ for(int a = 0; a < num_anchors; a++)
+ {
+ const T shift_x = T(x) * T(stride);
+ const T shift_y = T(y) * T(stride);
+ const size_t anchor_id = a + x * num_anchors + y * width * num_anchors;
+ // x1
+ all_anchors_ptr[anchor_id * 4] = anchors_ptr[4 * a] + shift_x;
+ // y1
+ all_anchors_ptr[anchor_id * 4 + 1] = anchors_ptr[4 * a + 1] + shift_y;
+ // x2
+ all_anchors_ptr[anchor_id * 4 + 2] = anchors_ptr[4 * a + 2] + shift_x;
+ // y2
+ all_anchors_ptr[anchor_id * 4 + 3] = anchors_ptr[4 * a + 3] + shift_y;
+ }
+ }
+ }
+ return all_anchors;
+}
+template SimpleTensor<float> compute_all_anchors(const SimpleTensor<float> &anchors, const ComputeAnchorsInfo &info);
+template SimpleTensor<half> compute_all_anchors(const SimpleTensor<half> &anchors, const ComputeAnchorsInfo &info);
+} // namespace reference
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/validation/reference/ComputeAllAnchors.h b/tests/validation/reference/ComputeAllAnchors.h
new file mode 100644
index 0000000000..b21bf3cc7e
--- /dev/null
+++ b/tests/validation/reference/ComputeAllAnchors.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_TEST_COMPUTEALLANCHORS_H__
+#define __ARM_COMPUTE_TEST_COMPUTEALLANCHORS_H__
+
+#include "arm_compute/core/Types.h"
+#include "arm_compute/core/utils/misc/ShapeCalculator.h"
+#include "tests/validation/Helpers.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace reference
+{
+template <typename T>
+SimpleTensor<T> compute_all_anchors(const SimpleTensor<T> &anchors, const ComputeAnchorsInfo &info);
+} // namespace reference
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_TEST_COMPUTEALLANCHORS_H__ */