blob: 9c64131a6125fab2fcd081fee5b7379ca5771714 [file] [log] [blame]
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +01001/*
Anthony Barbier1c0d0ff2018-01-31 13:05:09 +00002 * Copyright (c) 2017-2018 ARM Limited.
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +01003 *
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 */
Pablo Tello2fdc4092017-11-23 15:50:08 +000024#include "arm_compute/core/NEON/kernels/NEGEMMInterleave4x4Kernel.h"
Pablo Tello088cc7f2017-12-07 15:20:55 +000025#include "arm_compute/core/NEON/kernels/NEGEMMTranspose1xWKernel.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010026#include "arm_compute/core/Types.h"
27#include "arm_compute/runtime/NEON/functions/NEGEMM.h"
28#include "arm_compute/runtime/Tensor.h"
29#include "arm_compute/runtime/TensorAllocator.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010030#include "tests/NEON/Accessor.h"
Pablo Tello2fdc4092017-11-23 15:50:08 +000031#include "tests/NEON/Helper.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010032#include "tests/PaddingCalculator.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010033#include "tests/datasets/LargeGEMMDataset.h"
34#include "tests/datasets/SmallGEMMDataset.h"
Anthony Barbier1c0d0ff2018-01-31 13:05:09 +000035#include "tests/datasets/TinyGEMMDataset.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010036#include "tests/framework/Asserts.h"
37#include "tests/framework/Macros.h"
38#include "tests/framework/datasets/Datasets.h"
39#include "tests/validation/Validation.h"
40#include "tests/validation/fixtures/GEMMFixture.h"
Pablo Tello2fdc4092017-11-23 15:50:08 +000041#include "tests/validation/fixtures/GEMMInterleave4x4Fixture.h"
Pablo Tello088cc7f2017-12-07 15:20:55 +000042#include "tests/validation/fixtures/GEMMTranspose1xWFixture.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010043
44namespace arm_compute
45{
46namespace test
47{
48namespace validation
49{
50namespace
51{
52constexpr AbsoluteTolerance<float> tolerance_f(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010053
54/** CNN data types */
55const auto CNNDataTypes = framework::dataset::make("DataType",
56{
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +000057#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010058 DataType::F16,
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +000059#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010060 DataType::F32,
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010061});
Pablo Tello2fdc4092017-11-23 15:50:08 +000062
63const auto data_interleave = framework::dataset::make("M", 8, 12) * framework::dataset::make("N", 8, 12);
Pablo Tello088cc7f2017-12-07 15:20:55 +000064const auto data_transpose = framework::dataset::make("M", 8, 14) * framework::dataset::make("N", 7, 14);
65
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010066} // namespace
67
68TEST_SUITE(NEON)
69TEST_SUITE(GEMM)
70
Pablo Tello088cc7f2017-12-07 15:20:55 +000071TEST_SUITE(TRANSPOSE_1XW)
72using NEGEMMTranspose1xW = NESynthetizeFunctionWithZeroConstantBorder<NEGEMMTranspose1xWKernel, 4>;
73using NEGEMMTranspose1xWFixture = GEMMTranspose1xWValidationFixture<Tensor, Accessor, NEGEMMTranspose1xW, float>;
74TEST_SUITE(FP32)
75FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMTranspose1xWFixture, framework::DatasetMode::PRECOMMIT, data_transpose * framework::dataset::make("DataType", DataType::F32))
76{
77 // Validate output
78 validate(Accessor(_target), _reference);
79}
80TEST_SUITE_END() // FP32
81
Pablo Tello088cc7f2017-12-07 15:20:55 +000082TEST_SUITE_END() // TRANSPOSE_1XW
83
Pablo Tello2fdc4092017-11-23 15:50:08 +000084TEST_SUITE(INTERLEAVE_4X4)
85using NEGEMMInterleave4x4 = NESynthetizeFunctionWithZeroConstantBorder<NEGEMMInterleave4x4Kernel, 4>;
86
87TEST_SUITE(FP32)
88using NEGEMMInterleave4x4Fixture = GEMMInterleave4x4ValidationFixture<Tensor, Accessor, NEGEMMInterleave4x4, float>;
89FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMInterleave4x4Fixture, framework::DatasetMode::PRECOMMIT, data_interleave * framework::dataset::make("DataType", DataType::F32))
90{
91 // Validate output
92 validate(Accessor(_target), _reference);
93}
94TEST_SUITE_END() // FP32
95
Pablo Tello2fdc4092017-11-23 15:50:08 +000096TEST_SUITE_END() // INTERLEAVE_4X4
97
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010098DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMDataset(), datasets::LargeGEMMDataset()), CNNDataTypes),
99 shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type)
100{
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100101 // Create tensors
Vidhya Sudhan Loganathan014333d2018-07-02 09:13:49 +0100102 Tensor a = create_tensor<Tensor>(shape_a, data_type, 1);
103 Tensor b = create_tensor<Tensor>(shape_b, data_type, 1);
104 Tensor c = create_tensor<Tensor>(shape_c, data_type, 1);
105 Tensor dst = create_tensor<Tensor>(output_shape, data_type, 1);
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100106
107 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
108 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
109 ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS);
110 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
111
112 // Create and configure function
113 NEGEMM gemm;
114 gemm.configure(&a, &b, &c, &dst, alpha, beta);
115
116 //TODO(COMPMID-415): Validate valid region
117}
118
119template <typename T>
120using NEGEMMFixture = GEMMValidationFixture<Tensor, Accessor, NEGEMM, T>;
121
122TEST_SUITE(Float)
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000123#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100124TEST_SUITE(FP16)
Georgios Pinitas583137c2017-08-31 18:12:42 +0100125FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture<half>, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F16)))
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100126{
127 // Validate output
128 validate(Accessor(_target), _reference, tolerance_f);
129}
Georgios Pinitas583137c2017-08-31 18:12:42 +0100130FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture<half>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType",
131 DataType::F16)))
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100132{
133 // Validate output
134 validate(Accessor(_target), _reference, tolerance_f);
135}
136TEST_SUITE_END()
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000137#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100138
139TEST_SUITE(FP32)
140FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture<float>, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F32)))
141{
142 // Validate output
143 validate(Accessor(_target), _reference, tolerance_f);
144}
145FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32)))
146{
147 // Validate output
148 validate(Accessor(_target), _reference, tolerance_f);
149}
150TEST_SUITE_END()
151TEST_SUITE_END()
152
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100153TEST_SUITE_END()
154TEST_SUITE_END()
155} // namespace validation
156} // namespace test
157} // namespace arm_compute