From e2588184240b4850f62859ca9f3c5e95c9d8e129 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Thu, 13 Dec 2018 18:31:18 +0000 Subject: COMPMID-1755 NEON: Extend DepthConvert to support Cast Change-Id: I8e2ed9e97cbe86d8caf162bd84ecfd9b43b0bd3b Reviewed-on: https://review.mlplatform.org/401 Tested-by: Arm Jenkins Reviewed-by: Giuseppe Rossini Reviewed-by: Georgios Pinitas --- .../validation/fixtures/DepthConvertLayerFixture.h | 54 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/DepthConvertLayerFixture.h b/tests/validation/fixtures/DepthConvertLayerFixture.h index 29034c5334..a3d379eede 100644 --- a/tests/validation/fixtures/DepthConvertLayerFixture.h +++ b/tests/validation/fixtures/DepthConvertLayerFixture.h @@ -41,29 +41,40 @@ namespace test namespace validation { template -class DepthConvertLayerValidationFixture : public framework::Fixture +class DepthConvertLayerValidationBaseFixture : public framework::Fixture { public: template - void setup(TensorShape shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift) + void setup(TensorShape shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, QuantizationInfo quantization_info) { - _shift = shift; - _target = compute_target(shape, dt_in, dt_out, policy, shift); - _reference = compute_reference(shape, dt_in, dt_out, policy, shift); + _shift = shift; + _quantization_info = quantization_info; + _target = compute_target(shape, dt_in, dt_out, policy, shift); + _reference = compute_reference(shape, dt_in, dt_out, policy, shift); } protected: template void fill(U &&tensor, int i) { - library->fill_tensor_uniform(tensor, i); + if(is_data_type_quantized(tensor.data_type())) + { + std::pair bounds = get_quantized_bounds(tensor.quantization_info(), -1.0f, 1.0f); + std::uniform_int_distribution distribution(bounds.first, bounds.second); + + library->fill(tensor, distribution, i); + } + else + { + library->fill_tensor_uniform(tensor, i); + } } TensorType compute_target(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift) { // Create tensors - TensorType src = create_tensor(shape, dt_in, 1); - TensorType dst = create_tensor(shape, dt_out, 1); + TensorType src = create_tensor(shape, dt_in, 1, _quantization_info); + TensorType dst = create_tensor(shape, dt_out, 1, _quantization_info); // Create and configure function FunctionType depth_convert; @@ -91,7 +102,7 @@ protected: SimpleTensor compute_reference(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift) { // Create reference - SimpleTensor src{ shape, dt_in, 1 }; + SimpleTensor src{ shape, dt_in, 1, _quantization_info }; // Fill reference fill(src, 0); @@ -102,6 +113,31 @@ protected: TensorType _target{}; SimpleTensor _reference{}; int _shift{}; + QuantizationInfo _quantization_info{}; +}; + +template +class DepthConvertLayerValidationFixture : public DepthConvertLayerValidationBaseFixture +{ +public: + template + void setup(TensorShape shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift) + { + DepthConvertLayerValidationBaseFixture::setup(shape, dt_in, dt_out, policy, + shift, QuantizationInfo()); + } +}; + +template +class DepthConvertLayerValidationQuantizedFixture : public DepthConvertLayerValidationBaseFixture +{ +public: + template + void setup(TensorShape shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, QuantizationInfo quantization_info) + { + DepthConvertLayerValidationBaseFixture::setup(shape, dt_in, dt_out, policy, + shift, quantization_info); + } }; } // namespace validation } // namespace test -- cgit v1.2.1