diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2019-06-10 14:46:49 +0100 |
---|---|---|
committer | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2019-06-11 12:08:08 +0000 |
commit | 761c8d02ff875877db7aa7c850cf8d128592e822 (patch) | |
tree | 10871f3dccfa262d4a051d3d88b899be6acac0a2 /tests/validation/CL/FuseBatchNormalization.cpp | |
parent | d5134364fc4ca40ea65635192e7959327d690a01 (diff) | |
download | ComputeLibrary-761c8d02ff875877db7aa7c850cf8d128592e822.tar.gz |
COMPMID-2398: Add test for CLFuseBatchNormalizationLayer
Change-Id: I786df628ce15fc33fc42c9437fe82972e02e3b16
Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1317
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/CL/FuseBatchNormalization.cpp')
-rw-r--r-- | tests/validation/CL/FuseBatchNormalization.cpp | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/tests/validation/CL/FuseBatchNormalization.cpp b/tests/validation/CL/FuseBatchNormalization.cpp new file mode 100644 index 0000000000..92d63c0c3d --- /dev/null +++ b/tests/validation/CL/FuseBatchNormalization.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2019 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/runtime/CL/functions/CLFuseBatchNormalization.h" +#include "tests/CL/CLAccessor.h" +#include "tests/Globals.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/FuseBatchNormalizationFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +AbsoluteTolerance<float> absolute_tolerance_f32(0.001f); +AbsoluteTolerance<float> absolute_tolerance_f16(0.2f); +} // namespace + +template <typename T> +using CLFuseBatchNormalizationConvFixture = FuseBatchNormalizationFixture<CLTensor, CLAccessor, CLFuseBatchNormalization, 4, T>; + +// *INDENT-OFF* +// clang-format off + +/** Shapes to test - Precommit */ +const auto shape_conv_values_precommit = concat(datasets::Small4DShapes(), datasets::Small3DShapes()); + +/** Shapes to test - Nightly */ +const auto shape_conv_values_nightly = concat(datasets::Large4DShapes(), datasets::Large3DShapes()); + +/** Data layout to test */ +const auto data_layout_values = framework::dataset::make("DataLayout", { DataLayout::NHWC, DataLayout::NCHW }); + +/** In-place flags to test */ +const auto in_place_values = framework::dataset::make("InPlace", { true, false }); + +/** With bias flags to test */ +const auto with_bias_values = framework::dataset::make("WithBias", { true, false }); + +/** With gamma flags to test */ +const auto with_gamma_values = framework::dataset::make("WithGamma", { true, false }); + +/** With beta flags to test */ +const auto with_beta_values = framework::dataset::make("WithBeta", { true, false }); + +TEST_SUITE(CL) +TEST_SUITE(FuseBatchNormalization) +TEST_SUITE(Convolution) +TEST_SUITE(Float) +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFuseBatchNormalizationConvFixture<float>, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(combine(combine(combine( + shape_conv_values_precommit, + framework::dataset::make("DataType", { DataType::F32 })), + data_layout_values), + in_place_values), + with_bias_values), + with_gamma_values), + with_beta_values)) +{ + // Validate outputs + validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f32); + validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f32); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLFuseBatchNormalizationConvFixture<float>, framework::DatasetMode::NIGHTLY, + combine(combine(combine(combine(combine(combine( + shape_conv_values_nightly, + framework::dataset::make("DataType", { DataType::F32 })), + data_layout_values), + in_place_values), + with_bias_values), + with_gamma_values), + with_beta_values)) +{ + // Validate outputs + validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f32); + validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f32); +} + +TEST_SUITE_END() // FP32 + +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFuseBatchNormalizationConvFixture<half>, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(combine(combine(combine( + shape_conv_values_precommit, + framework::dataset::make("DataType", { DataType::F16 })), + data_layout_values), + in_place_values), + with_bias_values), + with_gamma_values), + with_beta_values)) +{ + // Validate outputs + validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f16); + validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLFuseBatchNormalizationConvFixture<half>, framework::DatasetMode::NIGHTLY, + combine(combine(combine(combine(combine(combine( + shape_conv_values_nightly, + framework::dataset::make("DataType", { DataType::F16 })), + data_layout_values), + in_place_values), + with_bias_values), + with_gamma_values), + with_beta_values)) +{ + // Validate outputs + validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f16); + validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f16); +} + +TEST_SUITE_END() // FP16 +TEST_SUITE_END() // Float +TEST_SUITE_END() // Convolution +TEST_SUITE_END() // FuseBatchNormalization +TEST_SUITE_END() // CL +} // namespace validation +} // namespace test +} // namespace arm_compute
\ No newline at end of file |