blob: dede3aef29f6ef1552ddf86cc0bc080ee363a51d [file] [log] [blame]
Pablo Tello299025a2017-09-29 11:30:12 +01001/*
2 * Copyright (c) 2017 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/NEGEMMLowp.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28#include "tests/NEON/Accessor.h"
Gian Marcofa4cacd2017-10-18 17:05:02 +010029#include "tests/datasets/LargeGEMMLowpDataset.h"
30#include "tests/datasets/SmallGEMMLowpDataset.h"
Pablo Tello299025a2017-09-29 11:30:12 +010031#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
Pablo Tellobf2fb952017-09-29 16:43:25 +010035#include "tests/validation/fixtures/GEMMInterleaveBlockedFixture.h"
Pablo Tello299025a2017-09-29 11:30:12 +010036#include "tests/validation/fixtures/GEMMLowpFixture.h"
37
Pablo Tellobf2fb952017-09-29 16:43:25 +010038#include "arm_compute/core/NEON/kernels/NEGEMMInterleaveBlockedKernel.h"
39#include "tests/NEON/Helper.h"
40
Pablo Tello299025a2017-09-29 11:30:12 +010041namespace arm_compute
42{
43namespace test
44{
45namespace validation
46{
47namespace
48{
Pablo Tellobf2fb952017-09-29 16:43:25 +010049const auto data_mnk = framework::dataset::make("M", 12, 20) * framework::dataset::make("N", 12, 20) * framework::dataset::make("K", 12, 15);
Pablo Tello299025a2017-09-29 11:30:12 +010050const auto data_offsets = framework::dataset::make("a", -3, 3) * framework::dataset::make("b", -1, 2) * framework::dataset::make("c", 1, 3) * framework::dataset::make("cm", 0,
51 3)
52 * framework::dataset::make("shift", 0, 4);
53
Pablo Tellobf2fb952017-09-29 16:43:25 +010054const auto data_int_blk = framework::dataset::make("M", 8, 12) * framework::dataset::make("N", 8, 12) * framework::dataset::make("by", 8, 13) * framework::dataset::make("block", 4, 9);
55
56const auto data_int_blk_tr = framework::dataset::make("M", 8, 17) * framework::dataset::make("N", 8, 14) * framework::dataset::make("by", 12) * framework::dataset::make("block", 4);
57
Pablo Tello299025a2017-09-29 11:30:12 +010058} // namespace
59
60TEST_SUITE(NEON)
61TEST_SUITE(GEMMLowp)
62
63TEST_SUITE(U8)
Pablo Tellobf2fb952017-09-29 16:43:25 +010064
65TEST_SUITE(INTERLEAVE_BLOCKED)
66
67using NEInterleaveBlocked = NESynthetizeFunction<NEGEMMInterleaveBlockedKernel>;
68using NEGEMMInterleaveBlockedFixture = GEMMInterleaveBlockedValidationFixture<Tensor, Accessor, NEInterleaveBlocked>;
69FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMInterleaveBlockedFixture, framework::DatasetMode::PRECOMMIT, data_int_blk)
70{
71 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +010072 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +010073}
74TEST_SUITE_END()
75
76TEST_SUITE(INTERLEAVE_BLOCKED_TRANSPOSED)
77using NEInterleaveBlockedTransposed = NESynthetizeFunction<NEGEMMInterleaveBlockedKernel>;
78using NEGEMMInterleaveBlockedTransposedFixture = GEMMInterleaveBlockedValidationFixture<Tensor, Accessor, NEInterleaveBlockedTransposed, true>;
79FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMInterleaveBlockedTransposedFixture, framework::DatasetMode::PRECOMMIT, data_int_blk_tr)
80{
81 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +010082 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +010083}
84
85TEST_SUITE_END()
86
Pablo Tello299025a2017-09-29 11:30:12 +010087using NEGEMMLowpOffsetFixture = GEMMLowpOffsetValidationFixture<Tensor, Accessor, NEGEMMLowp>;
Gian Marcofa4cacd2017-10-18 17:05:02 +010088
89DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMLowpDataset(), datasets::LargeGEMMLowpDataset()), framework::dataset::make("DataType",
90 DataType::U8)),
91 shape_a, shape_b, shape_c, a_offset, b_offset, c_offset, c_mult_int, out_shift, data_type)
92{
93 // Create tensors
94 Tensor a = create_tensor<Tensor>(shape_a, data_type);
95 Tensor b = create_tensor<Tensor>(shape_b, data_type);
96 Tensor c = create_tensor<Tensor>(shape_c, data_type);
97
98 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
99 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
100 ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS);
101
102 // Create and configure function
103 NEGEMMLowp gemmlowp;
104 gemmlowp.configure(&a, &b, &c, a_offset, b_offset, c_offset, c_mult_int, out_shift);
105}
106
107FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpOffsetFixture, framework::DatasetMode::ALL, combine(datasets::SmallGEMMLowpDataset(), framework::dataset::make("DataType", DataType::U8)))
Pablo Tello299025a2017-09-29 11:30:12 +0100108{
109 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100110 validate(Accessor(_target), _reference);
111}
112
113FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpOffsetFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMLowpDataset(), framework::dataset::make("DataType", DataType::U8)))
114{
115 // Validate output
116 validate(Accessor(_target), _reference);
Pablo Tello299025a2017-09-29 11:30:12 +0100117}
118TEST_SUITE_END()
119
Anthony Barbier960ccc42017-10-19 13:26:42 +0100120//FIXME: This is in the process of being updated, for more info please refer to COMPMID-624.
121#if 0 // defined(__aarch64__)
Pablo Tellobf2fb952017-09-29 16:43:25 +0100122TEST_SUITE(U32)
123using NEGEMMLowpFixture = GEMMLowpValidationFixture<Tensor, Accessor, NEGEMMLowp>;
124FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpFixture, framework::DatasetMode::PRECOMMIT, framework::dataset::make("M", 12, 20) * framework::dataset::make("N", 12, 20) * framework::dataset::make("K",
125 16))
126{
127 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100128 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +0100129}
130TEST_SUITE_END()
131#endif // defined(__aarch64__)
Pablo Tello299025a2017-09-29 11:30:12 +0100132TEST_SUITE_END()
133TEST_SUITE_END()
134} // namespace validation
135} // namespace test
136} // namespace arm_compute