blob: 926a2dad861d8d3f7850c27e2bd87f88a75f0dc9 [file] [log] [blame]
Michalis Spyroua6825a42018-09-13 12:24:03 +01001/*
2 * Copyright (c) 2018 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/NEON/functions/NEYOLOLayer.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28#include "tests/NEON/Accessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/ActivationFunctionsDataset.h"
31#include "tests/datasets/ShapeDatasets.h"
32#include "tests/framework/Asserts.h"
33#include "tests/framework/Macros.h"
34#include "tests/framework/datasets/Datasets.h"
35#include "tests/validation/Validation.h"
36#include "tests/validation/fixtures/YOLOLayerFixture.h"
37
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44namespace
45{
46/** Tolerance */
47constexpr AbsoluteTolerance<float> tolerance_f32(1e-6f);
48#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
49constexpr RelativeTolerance<float> tolerance_f16(0.001f);
50#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
51
52/** Floating point data sets. */
53const auto YOLODataset = combine(combine(combine(combine(framework::dataset::make("InPlace", { false, true }), framework::dataset::make("ActivationFunction",
54 ActivationLayerInfo::ActivationFunction::LOGISTIC)),
55 framework::dataset::make("AlphaBeta", { 0.5f, 1.f })),
56 framework::dataset::make("Classes", 40)),
57 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }));
58} // namespace
59
60TEST_SUITE(NEON)
61TEST_SUITE(YOLOLayer)
62
63template <typename T>
64using NEYOLOLayerFixture = YOLOValidationFixture<Tensor, Accessor, NEYOLOLayer, T>;
65
66TEST_SUITE(Float)
67TEST_SUITE(FP32)
68FIXTURE_DATA_TEST_CASE(RunSmall, NEYOLOLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallYOLOShapes(), YOLODataset), framework::dataset::make("DataType",
69 DataType::F32)))
70{
71 // Validate output
72 validate(Accessor(_target), _reference, tolerance_f32);
73}
74
75FIXTURE_DATA_TEST_CASE(RunLarge, NEYOLOLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeYOLOShapes(), YOLODataset), framework::dataset::make("DataType",
76 DataType::F32)))
77{
78 // Validate output
79 validate(Accessor(_target), _reference, tolerance_f32);
80}
81TEST_SUITE_END() // FP32
82
83#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
84TEST_SUITE(FP16)
85FIXTURE_DATA_TEST_CASE(RunSmall, NEYOLOLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallYOLOShapes(), YOLODataset), framework::dataset::make("DataType",
86 DataType::F16)))
87{
88 // Validate output
89 validate(Accessor(_target), _reference, tolerance_f16);
90}
91FIXTURE_DATA_TEST_CASE(RunLarge, NEYOLOLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeYOLOShapes(), YOLODataset), framework::dataset::make("DataType",
92 DataType::F16)))
93{
94 // Validate output
95 validate(Accessor(_target), _reference, tolerance_f16);
96}
97TEST_SUITE_END() // FP16
98#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
99TEST_SUITE_END() // Float
100
101TEST_SUITE_END() // YOLOLayer
102TEST_SUITE_END() // NEON
103} // namespace validation
104} // namespace test
105} // namespace arm_compute