aboutsummaryrefslogtreecommitdiff
path: root/tests/Utils.h
diff options
context:
space:
mode:
authorJohn Richardson <john.richardson@arm.com>2018-06-05 12:47:20 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:53:09 +0000
commit32af1f8ed8466647abb4f0532c70f72530a1a9ca (patch)
tree41d32d89a3b1315bc84dd7b0c416e181029ae3c1 /tests/Utils.h
parent80127549c3fabc941e6dcb5e61136ecb20f9c735 (diff)
downloadComputeLibrary-32af1f8ed8466647abb4f0532c70f72530a1a9ca.tar.gz
COMPMID-761: Add CL/NEON Convolution benchmark tests
Change-Id: I684baff3bfdff2244e04facd2d85d84609b7caff Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/134769 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/Utils.h')
-rw-r--r--tests/Utils.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/Utils.h b/tests/Utils.h
index d0eebb1204..278af414db 100644
--- a/tests/Utils.h
+++ b/tests/Utils.h
@@ -596,6 +596,61 @@ inline T create_pyramid(const PyramidInfo &pyramid_info)
return pyramid;
}
+/** Initialize a convolution matrix.
+ *
+ * @param[in, out] conv The input convolution matrix.
+ * @param[in] width The width of the convolution matrix.
+ * @param[in] height The height of the convolution matrix.
+ * @param[in] seed The random seed to be used.
+ */
+inline void init_conv(int16_t *conv, unsigned int width, unsigned int height, std::random_device::result_type seed)
+{
+ std::mt19937 gen(seed);
+ std::uniform_int_distribution<int16_t> distribution_int16(-32768, 32767);
+
+ for(unsigned int i = 0; i < width * height; ++i)
+ {
+ conv[i] = distribution_int16(gen);
+ }
+}
+
+/** Initialize a separable convolution matrix.
+ *
+ * @param[in, out] conv The input convolution matrix.
+ * @param[in] width The width of the convolution matrix.
+ * @param[in] height The height of the convolution matrix.
+ * @param[in] seed The random seed to be used.
+ */
+inline void init_separable_conv(int16_t *conv, unsigned int width, unsigned int height, std::random_device::result_type seed)
+{
+ std::mt19937 gen(seed);
+ // Set it between -128 and 127 to ensure the matrix does not overflow
+ std::uniform_int_distribution<int16_t> distribution_int16(-128, 127);
+
+ int16_t conv_row[width];
+ int16_t conv_col[height];
+
+ conv_row[0] = conv_col[0] = 1;
+ for(unsigned int i = 1; i < width; ++i)
+ {
+ conv_row[i] = distribution_int16(gen);
+ }
+
+ for(unsigned int i = 1; i < height; ++i)
+ {
+ conv_col[i] = distribution_int16(gen);
+ }
+
+ // Multiply two matrices
+ for(unsigned int i = 0; i < width; ++i)
+ {
+ for(unsigned int j = 0; j < height; ++j)
+ {
+ conv[i * width + j] = conv_col[i] * conv_row[j];
+ }
+ }
+}
+
/** Create a vector of random ROIs.
*
* @param[in] shape The shape of the input tensor.