From 563494c2f447e201e88e6d7133a41e12971777eb Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Mon, 30 Apr 2018 17:29:41 +0100 Subject: COMPMID-1084 Rework the way validation is performed for NHWC data layout Change-Id: I00b95f560548da76718298b642c8166f92421097 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/129520 Tested-by: Jenkins Reviewed-by: Michele DiGiorgio Reviewed-by: Anthony Barbier --- tests/AssetsLibrary.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/AssetsLibrary.h') diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h index 4bbe4c56f6..1fba3d4b46 100644 --- a/tests/AssetsLibrary.h +++ b/tests/AssetsLibrary.h @@ -456,10 +456,25 @@ void AssetsLibrary::fill(T &&tensor, D &&distribution, std::random_device::resul std::mt19937 gen(_seed + seed_offset); + const bool is_nhwc = tensor.data_layout() == DataLayout::NHWC; + TensorShape shape(tensor.shape()); + + if(is_nhwc) + { + // Ensure that the equivalent tensors will be filled for both data layouts + permute(shape, PermutationVector(1U, 2U, 0U)); + } + // Iterate over all elements for(int element_idx = 0; element_idx < tensor.num_elements(); ++element_idx) { - const Coordinates id = index2coord(tensor.shape(), element_idx); + Coordinates id = index2coord(shape, element_idx); + + if(is_nhwc) + { + // Write in the correct id for permuted shapes + permute(id, PermutationVector(2U, 0U, 1U)); + } // Iterate over all channels for(int channel = 0; channel < tensor.num_channels(); ++channel) -- cgit v1.2.1