From 4bdd177c75789451cad9ba1ecf929214ed75c009 Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Thu, 17 Dec 2020 16:47:07 +0000 Subject: Fix fill() for FP data type in fixtures - Part 2 Resolves: COMPMID-4056 Signed-off-by: Giorgio Arena Change-Id: I6623eb9c0e66e52af4e0e9fb386031f4a09125b7 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4722 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- tests/validation/fixtures/BatchToSpaceLayerFixture.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/validation/fixtures/BatchToSpaceLayerFixture.h') diff --git a/tests/validation/fixtures/BatchToSpaceLayerFixture.h b/tests/validation/fixtures/BatchToSpaceLayerFixture.h index ca6d20a838..a8d132753c 100644 --- a/tests/validation/fixtures/BatchToSpaceLayerFixture.h +++ b/tests/validation/fixtures/BatchToSpaceLayerFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Arm Limited. + * Copyright (c) 2018-2020 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -50,7 +50,10 @@ protected: template void fill(U &&tensor, int i) { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); + static_assert(std::is_floating_point::value || std::is_same::value, "Only floating point data types supported."); + using DistributionType = typename std::conditional::value, arm_compute::utils::uniform_real_distribution_fp16, std::uniform_real_distribution>::type; + + DistributionType distribution{ T(-1.0f), T(1.0f) }; library->fill(tensor, distribution, i); } TensorType compute_target(TensorShape input_shape, TensorShape block_shape_shape, TensorShape output_shape, @@ -87,8 +90,8 @@ protected: // Fill tensors fill(AccessorType(input), 0); { - auto block_shape_data = AccessorType(block_shape); - const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); + auto block_shape_data = AccessorType(block_shape); + const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); for(unsigned int i = 0; i < block_shape_shape.x(); ++i) { static_cast(block_shape_data.data())[i] = output_shape[i + idx_width] / input_shape[i + idx_width]; -- cgit v1.2.1