From 345ab188c66017bf80512024a42b8e85ee96c872 Mon Sep 17 00:00:00 2001 From: Alex Gilday Date: Tue, 9 Jan 2018 11:40:19 +0000 Subject: 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 Reviewed-by: Georgios Pinitas --- tests/AssetsLibrary.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tests/AssetsLibrary.h') 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 + 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 +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(tensor(id)); + std::copy_n(raw_ptr, raw.element_size(), out_ptr); + } +} + template void AssetsLibrary::fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset) const { -- cgit v1.2.1