diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/validation/Helpers.h | 37 | ||||
-rw-r--r-- | tests/validation/fixtures/BatchNormalizationLayerFixture.h | 73 | ||||
-rw-r--r-- | tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h | 18 | ||||
-rw-r--r-- | tests/validation/reference/CannyEdgeDetector.cpp | 2 |
4 files changed, 31 insertions, 99 deletions
diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h index 8b994946f2..779ecdca11 100644 --- a/tests/validation/Helpers.h +++ b/tests/validation/Helpers.h @@ -176,43 +176,6 @@ void fill_lookuptable(T &&table) } } -/** Helper function to get the testing range for batch normalization layer. - * - * @return A pair containing the lower upper testing bounds. - */ -template <typename T> -std::pair<T, T> get_batchnormalization_layer_test_bounds() -{ - const bool is_float = std::is_floating_point<T>::value; - std::pair<T, T> bounds; - - // Set initial values - if(is_float) - { - bounds = std::make_pair(-1.f, 1.f); - } - else - { - bounds = std::make_pair(1, 1); - } - - return bounds; -} - -/** Helper function to get the testing range for NormalizePlanarYUV layer. - * - * @return A pair containing the lower upper testing bounds. - */ -template <typename T> -std::pair<T, T> get_normalize_planar_yuv_layer_test_bounds() -{ - std::pair<T, T> bounds; - - bounds = std::make_pair(-1.f, 1.f); - - return bounds; -} - /** Convert quantized simple tensor into float using tensor quantization information. * * @param[in] src Quantized tensor. diff --git a/tests/validation/fixtures/BatchNormalizationLayerFixture.h b/tests/validation/fixtures/BatchNormalizationLayerFixture.h index 65e89b92da..359752f14e 100644 --- a/tests/validation/fixtures/BatchNormalizationLayerFixture.h +++ b/tests/validation/fixtures/BatchNormalizationLayerFixture.h @@ -59,63 +59,30 @@ protected: template <typename U> void fill(U &&src_tensor, U &&mean_tensor, U &&var_tensor, U &&beta_tensor, U &&gamma_tensor) { - if(is_data_type_float(_data_type)) + const float min_bound = -1.f; + const float max_bound = 1.f; + std::uniform_real_distribution<> distribution(min_bound, max_bound); + std::uniform_real_distribution<> distribution_var(0, max_bound); + library->fill(src_tensor, distribution, 0); + library->fill(mean_tensor, distribution, 1); + library->fill(var_tensor, distribution_var, 0); + if(_use_beta) { - float min_bound = 0.f; - float max_bound = 0.f; - std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds<T>(); - std::uniform_real_distribution<> distribution(min_bound, max_bound); - std::uniform_real_distribution<> distribution_var(0, max_bound); - library->fill(src_tensor, distribution, 0); - library->fill(mean_tensor, distribution, 1); - library->fill(var_tensor, distribution_var, 0); - if(_use_beta) - { - library->fill(beta_tensor, distribution, 3); - } - else - { - // Fill with default value 0.f - library->fill_tensor_value(beta_tensor, 0.f); - } - if(_use_gamma) - { - library->fill(gamma_tensor, distribution, 4); - } - else - { - // Fill with default value 1.f - library->fill_tensor_value(gamma_tensor, 1.f); - } + library->fill(beta_tensor, distribution, 3); } else { - int min_bound = 0; - int max_bound = 0; - std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds<T>(); - std::uniform_int_distribution<> distribution(min_bound, max_bound); - std::uniform_int_distribution<> distribution_var(0, max_bound); - library->fill(src_tensor, distribution, 0); - library->fill(mean_tensor, distribution, 1); - library->fill(var_tensor, distribution_var, 0); - if(_use_beta) - { - library->fill(beta_tensor, distribution, 3); - } - else - { - // Fill with default value 0 - library->fill_tensor_value(beta_tensor, static_cast<T>(0)); - } - if(_use_gamma) - { - library->fill(gamma_tensor, distribution, 4); - } - else - { - // Fill with default value 1 - library->fill_tensor_value(gamma_tensor, static_cast<T>(1)); - } + // Fill with default value 0.f + library->fill_tensor_value(beta_tensor, 0.f); + } + if(_use_gamma) + { + library->fill(gamma_tensor, distribution, 4); + } + else + { + // Fill with default value 1.f + library->fill_tensor_value(gamma_tensor, 1.f); } } diff --git a/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h b/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h index 9d8c8fcbce..3bb935e49f 100644 --- a/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h +++ b/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h @@ -58,20 +58,24 @@ protected: { if(is_data_type_float(_data_type)) { - float min_bound = 0.f; - float max_bound = 0.f; - std::tie(min_bound, max_bound) = get_normalize_planar_yuv_layer_test_bounds<T>(); + const float min_bound = -1.f; + const float max_bound = 1.f; std::uniform_real_distribution<> distribution(min_bound, max_bound); std::uniform_real_distribution<> distribution_std(0.1, max_bound); library->fill(src_tensor, distribution, 0); library->fill(mean_tensor, distribution, 1); library->fill(std_tensor, distribution_std, 2); } - else if(is_data_type_quantized_asymmetric(src_tensor.data_type())) + else if(is_data_type_quantized_asymmetric(_data_type)) { - library->fill_tensor_uniform(src_tensor, 0); - library->fill_tensor_uniform(mean_tensor, 1); - library->fill_tensor_uniform(std_tensor, 2); + const QuantizationInfo quant_info = src_tensor.quantization_info(); + const int min_bound = quant_info.quantize(-1.f, RoundingPolicy::TO_NEAREST_UP); + const int max_bound = quant_info.quantize(1.f, RoundingPolicy::TO_NEAREST_UP); + std::uniform_int_distribution<> distribution(min_bound, max_bound); + std::uniform_int_distribution<> distribution_std(quant_info.quantize(0.1f, RoundingPolicy::TO_NEAREST_UP), max_bound); + library->fill(src_tensor, distribution, 0); + library->fill(mean_tensor, distribution, 1); + library->fill(std_tensor, distribution_std, 2); } } diff --git a/tests/validation/reference/CannyEdgeDetector.cpp b/tests/validation/reference/CannyEdgeDetector.cpp index d50452bfe8..92a11db0bd 100644 --- a/tests/validation/reference/CannyEdgeDetector.cpp +++ b/tests/validation/reference/CannyEdgeDetector.cpp @@ -31,8 +31,6 @@ #include "tests/validation/reference/Phase.h" #include "tests/validation/reference/Sobel.h" -#include "tests/SimpleTensorPrinter.h" - #include <cmath> #include <stack> |