aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/Helpers.h
diff options
context:
space:
mode:
authorJohn Richardson <john.richardson@arm.com>2017-09-07 11:21:10 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit6f4d49f95c3598e41a7532faa637f42d8be5f4dd (patch)
tree78bdf01c935b4f195d65a09cd734b63aba3bfe7a /tests/validation/Helpers.h
parente997859ed978a42191e429f9357c95c38d84baaa (diff)
downloadComputeLibrary-6f4d49f95c3598e41a7532faa637f42d8be5f4dd.tar.gz
COMPMID-504: Move NonLinearFilter to new validation
Change-Id: Ie2e9c34dd541cf570b9aef29d94ac79e2360e0e9 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87580 Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'tests/validation/Helpers.h')
-rw-r--r--tests/validation/Helpers.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h
index 30959161bb..5fdd57f7ba 100644
--- a/tests/validation/Helpers.h
+++ b/tests/validation/Helpers.h
@@ -26,6 +26,7 @@
#include "arm_compute/core/Types.h"
#include "arm_compute/core/Utils.h"
+#include "tests/Globals.h"
#include "tests/validation/half.h"
#include <random>
@@ -129,6 +130,55 @@ std::pair<T, T> get_activation_layer_test_bounds(ActivationLayerInfo::Activation
return bounds;
}
+/** Fill mask with the corresponding given pattern.
+ *
+ * @param[in,out] mask Mask to be filled according to pattern
+ * @param[in] cols Columns (width) of mask
+ * @param[in] rows Rows (height) of mask
+ * @param[in] pattern Pattern to fill the mask according to
+ */
+inline void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern)
+{
+ unsigned int v = 0;
+ std::mt19937 gen(library->seed());
+ std::bernoulli_distribution dist(0.5);
+
+ for(int r = 0; r < rows; ++r)
+ {
+ for(int c = 0; c < cols; ++c, ++v)
+ {
+ uint8_t val = 0;
+
+ switch(pattern)
+ {
+ case MatrixPattern::BOX:
+ val = 255;
+ break;
+ case MatrixPattern::CROSS:
+ val = ((r == (rows / 2)) || (c == (cols / 2))) ? 255 : 0;
+ break;
+ case MatrixPattern::DISK:
+ val = (((r - rows / 2.0f + 0.5f) * (r - rows / 2.0f + 0.5f)) / ((rows / 2.0f) * (rows / 2.0f)) + ((c - cols / 2.0f + 0.5f) * (c - cols / 2.0f + 0.5f)) / ((cols / 2.0f) *
+ (cols / 2.0f))) <= 1.0f ? 255 : 0;
+ break;
+ case MatrixPattern::OTHER:
+ val = (dist(gen) ? 0 : 255);
+ break;
+ default:
+ return;
+ }
+
+ mask[v] = val;
+ }
+ }
+
+ if(pattern == MatrixPattern::OTHER)
+ {
+ std::uniform_int_distribution<uint8_t> distribution_u8(0, ((cols * rows) - 1));
+ mask[distribution_u8(gen)] = 255;
+ }
+}
+
/** Calculate output tensor shape give a vector of input tensor to concatenate
*
* @param[in] input_shapes Shapes of the tensors to concatenate across depth.