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 <bsgcomp@arm.com>
Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h
index 4bbe4c5..1fba3d4 100644
--- a/tests/AssetsLibrary.h
+++ b/tests/AssetsLibrary.h
@@ -456,10 +456,25 @@
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)