diff options
author | Alex Gilday <alexander.gilday@arm.com> | 2018-01-09 11:40:19 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:42:33 +0000 |
commit | 345ab188c66017bf80512024a42b8e85ee96c872 (patch) | |
tree | 995d7147444483e8d7c342a9c90e615ca9445bc7 /tests/AssetsLibrary.h | |
parent | 780db4eb6a9e3dee565d14f36d772038cd3253da (diff) | |
download | ComputeLibrary-345ab188c66017bf80512024a42b8e85ee96c872.tar.gz |
COMPMID-742: Add image input support for Harris Corners tests
Change-Id: I4833eec0734776d8683fe867bb4f4d827f1a2fb7
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/115503
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/AssetsLibrary.h')
-rw-r--r-- | tests/AssetsLibrary.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h index 49e3a83399..9c93ee0757 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. @@ -475,6 +486,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()) |