summaryrefslogtreecommitdiff
path: root/tests/AssetsLibrary.h
diff options
context:
space:
mode:
authorAnthony Barbier <anthony.barbier@arm.com>2018-01-24 16:23:15 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-01-24 16:23:15 +0000
commitf45d5a9be1bf4d315a227b80617582b8eb4214d2 (patch)
tree29f24fc5f51448e831080d76eef3ac75d43c1934 /tests/AssetsLibrary.h
parent6943bb00e79fe2ea4c127dc04b3440c5b0b29ce0 (diff)
downloadarmcl-f45d5a9be1bf4d315a227b80617582b8eb4214d2.tar.gz
armcl-f45d5a9be1bf4d315a227b80617582b8eb4214d2.tar.bz2
armcl-f45d5a9be1bf4d315a227b80617582b8eb4214d2.zip
arm_compute v18.01
Change-Id: I9bfa178c2e38bfd5fc812e62aab6760d87748e05
Diffstat (limited to 'tests/AssetsLibrary.h')
-rw-r--r--tests/AssetsLibrary.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h
index 8e32fd534..1fe8c6373 100644
--- a/tests/AssetsLibrary.h
+++ b/tests/AssetsLibrary.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017, 2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -275,6 +275,17 @@ public:
*/
void fill(RawTensor &raw, const std::string &name, Format format, Channel channel) const;
+ /** Fills the specified @p tensor with the content of the raw tensor.
+ *
+ * @param[in, out] tensor To be filled tensor.
+ * @param[in] raw Raw tensor used to fill the tensor.
+ *
+ * @warning No check is performed that the specified format actually
+ * matches the format of the tensor.
+ */
+ template <typename T>
+ void fill(T &&tensor, RawTensor raw) const;
+
/** Fill a tensor with uniform distribution across the range of its type
*
* @param[in, out] tensor To be filled tensor.
@@ -474,6 +485,19 @@ void AssetsLibrary::fill(T &&tensor, const std::string &name, Format format, Cha
}
template <typename T>
+void AssetsLibrary::fill(T &&tensor, RawTensor raw) const
+{
+ for(size_t offset = 0; offset < raw.size(); offset += raw.element_size())
+ {
+ const Coordinates id = index2coord(raw.shape(), offset / raw.element_size());
+
+ const RawTensor::value_type *const raw_ptr = raw.data() + offset;
+ const auto out_ptr = static_cast<RawTensor::value_type *>(tensor(id));
+ std::copy_n(raw_ptr, raw.element_size(), out_ptr);
+ }
+}
+
+template <typename T>
void AssetsLibrary::fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset) const
{
switch(tensor.data_type())