blob: 56430d96504381006b15c6394de5d28be97c425b [file] [log] [blame]
Sanghoon Leef47bfb92018-01-23 15:16:47 +00001/*
2 * Copyright (c) 2017-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/NELocallyConnectedLayer.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/LocallyConnectedDataset.h"
31#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
35#include "tests/validation/fixtures/LocallyConnectedFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43namespace
44{
45constexpr RelativeTolerance<float> tolerance_f32(0.0001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
46} // namespace
47
48TEST_SUITE(NEON)
49TEST_SUITE(LocallyConnected)
50
51DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallLocallyConnectedDataset(), datasets::LargeLocallyConnectedDataset()),
52 framework::dataset::make("DataType", DataType::F32)),
53 src_shape, weights_shape, bias_shape, dst_shape, info, data_type)
54{
55 // Create tensors
56 Tensor src = create_tensor<Tensor>(src_shape, data_type);
57 Tensor weights = create_tensor<Tensor>(weights_shape, data_type);
58 Tensor bias = create_tensor<Tensor>(bias_shape, data_type);
59 Tensor dst = create_tensor<Tensor>(dst_shape, data_type);
60
61 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
62 ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS);
63 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
64 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
65
66 // Create and configure function.
67 NELocallyConnectedLayer lc;
68 lc.configure(&src, &weights, &bias, &dst, info);
69
70 // Validate valid region
71 const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape);
72 validate(dst.info()->valid_region(), dst_valid_region);
73}
74
75template <typename T>
76using NELocallyConnectedFixture = LocallyConnectedValidationFixture<Tensor, Accessor, NELocallyConnectedLayer, T>;
77FIXTURE_DATA_TEST_CASE(RunSmall, NELocallyConnectedFixture<float>, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallLocallyConnectedDataset(),
78 framework::dataset::make("DataType",
79 DataType::F32)))
80{
81 // Validate output
82 validate(Accessor(_target), _reference, tolerance_f32);
83}
84
85FIXTURE_DATA_TEST_CASE(RunLarge, NELocallyConnectedFixture<float>, framework::DatasetMode::PRECOMMIT, combine(datasets::LargeLocallyConnectedDataset(),
86 framework::dataset::make("DataType",
87 DataType::F32)))
88{
89 // Validate output
90 validate(Accessor(_target), _reference, tolerance_f32);
91}
92TEST_SUITE_END()
93TEST_SUITE_END()
94} // namespace validation
95} // namespace test
96} // namespace arm_compute