aboutsummaryrefslogtreecommitdiff
path: root/tests/AssetsLibrary.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/AssetsLibrary.h')
-rw-r--r--tests/AssetsLibrary.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h
index f8635ea576..9a22b2fefb 100644
--- a/tests/AssetsLibrary.h
+++ b/tests/AssetsLibrary.h
@@ -216,6 +216,19 @@ public:
/** Fills the specified @p raw tensor with random values drawn from @p
* distribution.
*
+ * @param[in, out] vec To be filled vector.
+ * @param[in] distribution Distribution used to fill the tensor.
+ * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator.
+ *
+ * @note The @p distribution has to provide operator(Generator &) which
+ * will be used to draw samples.
+ */
+ template <typename T, typename D>
+ void fill(std::vector<T> &vec, D &&distribution, std::random_device::result_type seed_offset) const;
+
+ /** Fills the specified @p raw tensor with random values drawn from @p
+ * distribution.
+ *
* @param[in, out] raw To be filled raw.
* @param[in] distribution Distribution used to fill the tensor.
* @param[in] seed_offset The offset will be added to the global seed before initialising the random generator.
@@ -522,6 +535,22 @@ void AssetsLibrary::fill_boxes(T &&tensor, D &&distribution, std::random_device:
}
template <typename T, typename D>
+void AssetsLibrary::fill(std::vector<T> &vec, D &&distribution, std::random_device::result_type seed_offset) const
+{
+ ARM_COMPUTE_ERROR_ON_MSG(vec.empty(), "Vector must not be empty");
+
+ using ResultType = typename std::remove_reference<D>::type::result_type;
+
+ std::mt19937 gen(_seed + seed_offset);
+ for(size_t i = 0; i < vec.size(); ++i)
+ {
+ const ResultType value = distribution(gen);
+
+ vec[i] = value;
+ }
+}
+
+template <typename T, typename D>
void AssetsLibrary::fill(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const
{
using ResultType = typename std::remove_reference<D>::type::result_type;