diff options
author | Sang-Hoon Park <sang-hoon.park@arm.com> | 2020-05-12 22:01:23 +0100 |
---|---|---|
committer | Sang-Hoon Park <sang-hoon.park@arm.com> | 2020-05-14 10:41:01 +0000 |
commit | a8a7c1d2691fc688dabc275d8b68e5a1267f00af (patch) | |
tree | 54bd44259d715df0fec12f0c98614646b902a1a0 /tests/validation/fixtures/ActivationLayerFixture.h | |
parent | 1a378107af40669eaa23a12e064bb8fabff2473e (diff) | |
download | ComputeLibrary-a8a7c1d2691fc688dabc275d8b68e5a1267f00af.tar.gz |
COMPMID-3295: Static input for ActivationLayer test suite
- A member function added to AssetsLibrary to fill tensors with
static values.
- ActivationLayerFixture has been modified use the new function.
- Redundant nightly tests are removed.
Change-Id: Ib2a1103a1e438e808183170dc9d097599523c6ec
Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3188
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/fixtures/ActivationLayerFixture.h')
-rw-r--r-- | tests/validation/fixtures/ActivationLayerFixture.h | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/tests/validation/fixtures/ActivationLayerFixture.h b/tests/validation/fixtures/ActivationLayerFixture.h index 3294986519..551ee2d8cf 100644 --- a/tests/validation/fixtures/ActivationLayerFixture.h +++ b/tests/validation/fixtures/ActivationLayerFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -68,6 +68,37 @@ public: } protected: + std::vector<T> get_boundary_values(T min, T max) + { + // This function will return a vector filled with the following values that can + // represent two partitions derived from equivalent partitioning. + // * Lower parition: min, min + delta, lower quarter (nominal), center - delta + // * Upper partition: center, center + delta, upper quarter (nominal), max - delta, max + const auto delta = is_data_type_float(_data_type) ? T(0.1f) : T(1); + const auto center_value = (min + max) / 2; + const auto lower_quarter = (min + center_value) / 2; + const auto upper_quarter = (center_value + max) / 2; + + std::vector<T> boundary_values{}; + + // To ensure all the inserted values are within the given range after subtracing/adding delta + auto insert_values = [&boundary_values, &min, &max](const std::initializer_list<T> &new_values) + { + for(auto &v : new_values) + { + if(v >= min && v <= max) + { + boundary_values.emplace_back(v); + } + } + }; + + insert_values({ min, static_cast<T>(min + delta), static_cast<T>(lower_quarter), static_cast<T>(center_value - delta) }); // lower partition + insert_values({ static_cast<T>(center_value), static_cast<T>(center_value + delta), static_cast<T>(upper_quarter), static_cast<T>(max - delta), max }); // upper partition + + return boundary_values; + } + template <typename U> void fill(U &&tensor) { @@ -76,20 +107,14 @@ protected: float min_bound = 0; float max_bound = 0; std::tie(min_bound, max_bound) = get_activation_layer_test_bounds<T>(_function, _data_type); - std::uniform_real_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); - } - else if(is_data_type_quantized(tensor.data_type())) - { - library->fill_tensor_uniform(tensor, 0); + library->fill_static_values(tensor, get_boundary_values(static_cast<T>(min_bound), static_cast<T>(max_bound))); } else { - int min_bound = 0; - int max_bound = 0; - std::tie(min_bound, max_bound) = get_activation_layer_test_bounds<T>(_function, _data_type); - std::uniform_int_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); + PixelValue min{}; + PixelValue max{}; + std::tie(min, max) = get_min_max(tensor.data_type()); + library->fill_static_values(tensor, get_boundary_values(min.get<T>(), max.get<T>())); } } |