From 9414f64c231a013664102e2c284b10266c6b4d4e Mon Sep 17 00:00:00 2001 From: Ioan-Cristian Szabo Date: Fri, 27 Oct 2017 17:35:40 +0100 Subject: COMPMID-582: Add validation to channel_extract kernels. Change-Id: I5022d02f06f9d849dad76e3d9b8e48632c236429 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/121191 Reviewed-by: Anthony Barbier Tested-by: Jenkins --- tests/AssetsLibrary.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'tests/AssetsLibrary.h') diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h index c9bd427845..afdf714ff1 100644 --- a/tests/AssetsLibrary.h +++ b/tests/AssetsLibrary.h @@ -416,22 +416,24 @@ void AssetsLibrary::fill_borders_with_garbage(T &&tensor, D &&distribution, std: template void AssetsLibrary::fill(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const { - Window window; - for(unsigned int d = 0; d < tensor.shape().num_dimensions(); ++d) - { - window.set(d, Window::Dimension(0, tensor.shape()[d], 1)); - } + using ResultType = typename std::remove_reference::type::result_type; std::mt19937 gen(_seed + seed_offset); - //FIXME: Replace with normal loop - execute_window_loop(window, [&](const Coordinates & id) + // Iterate over all elements + for(int element_idx = 0; element_idx < tensor.num_elements(); ++element_idx) { - using ResultType = typename std::remove_reference::type::result_type; - const ResultType value = distribution(gen); - void *const out_ptr = tensor(id); - store_value_with_data_type(out_ptr, value, tensor.data_type()); - }); + const Coordinates id = index2coord(tensor.shape(), element_idx); + + // Iterate over all channels + for(int channel = 0; channel < tensor.num_channels(); ++channel) + { + const ResultType value = distribution(gen); + ResultType &target_value = reinterpret_cast(tensor(id))[channel]; + + store_value_with_data_type(&target_value, value, tensor.data_type()); + } + } fill_borders_with_garbage(tensor, distribution, seed_offset); } -- cgit v1.2.1