blob: 4924f98ea68a0a2a1e77bf2be6f4b1845956fdbc [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 */
Gian Marco Iodiceab182122017-10-09 15:05:40 +010024#include "arm_compute/core/NEON/kernels/NEGEMMInterleaveBlockedKernel.h"
Pablo Tello299025a2017-09-29 11:30:12 +010025#include "arm_compute/core/Types.h"
26#include "arm_compute/runtime/NEON/functions/NEGEMMLowp.h"
27#include "arm_compute/runtime/Tensor.h"
28#include "arm_compute/runtime/TensorAllocator.h"
29#include "tests/NEON/Accessor.h"
Gian Marco Iodiceab182122017-10-09 15:05:40 +010030#include "tests/NEON/Helper.h"
Gian Marcofa4cacd2017-10-18 17:05:02 +010031#include "tests/datasets/LargeGEMMLowpDataset.h"
32#include "tests/datasets/SmallGEMMLowpDataset.h"
Pablo Tello299025a2017-09-29 11:30:12 +010033#include "tests/framework/Asserts.h"
34#include "tests/framework/Macros.h"
35#include "tests/framework/datasets/Datasets.h"
36#include "tests/validation/Validation.h"
Pablo Tellobf2fb952017-09-29 16:43:25 +010037#include "tests/validation/fixtures/GEMMInterleaveBlockedFixture.h"
Pablo Tello299025a2017-09-29 11:30:12 +010038#include "tests/validation/fixtures/GEMMLowpFixture.h"
39
40namespace arm_compute
41{
42namespace test
43{
44namespace validation
45{
46namespace
47{
Pablo Tello6ff12a02017-11-02 16:09:35 +000048const 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);
49const 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);
50const auto data_matrix_multiply = framework::dataset::make("M", 12, 20) * framework::dataset::make("N", 12, 20) * framework::dataset::make("K", 16);
Pablo Tello299025a2017-09-29 11:30:12 +010051} // namespace
52
53TEST_SUITE(NEON)
54TEST_SUITE(GEMMLowp)
55
Pablo Tello6ff12a02017-11-02 16:09:35 +000056TEST_SUITE(S8)
Pablo Tellobf2fb952017-09-29 16:43:25 +010057
58TEST_SUITE(INTERLEAVE_BLOCKED)
59
60using NEInterleaveBlocked = NESynthetizeFunction<NEGEMMInterleaveBlockedKernel>;
61using NEGEMMInterleaveBlockedFixture = GEMMInterleaveBlockedValidationFixture<Tensor, Accessor, NEInterleaveBlocked>;
62FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMInterleaveBlockedFixture, framework::DatasetMode::PRECOMMIT, data_int_blk)
63{
64 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +010065 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +010066}
67TEST_SUITE_END()
68
69TEST_SUITE(INTERLEAVE_BLOCKED_TRANSPOSED)
70using NEInterleaveBlockedTransposed = NESynthetizeFunction<NEGEMMInterleaveBlockedKernel>;
71using NEGEMMInterleaveBlockedTransposedFixture = GEMMInterleaveBlockedValidationFixture<Tensor, Accessor, NEInterleaveBlockedTransposed, true>;
72FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMInterleaveBlockedTransposedFixture, framework::DatasetMode::PRECOMMIT, data_int_blk_tr)
73{
74 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +010075 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +010076}
77
78TEST_SUITE_END()
79
Pablo Tello299025a2017-09-29 11:30:12 +010080using NEGEMMLowpOffsetFixture = GEMMLowpOffsetValidationFixture<Tensor, Accessor, NEGEMMLowp>;
Gian Marcofa4cacd2017-10-18 17:05:02 +010081
82DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMLowpDataset(), datasets::LargeGEMMLowpDataset()), framework::dataset::make("DataType",
Pablo Tello6ff12a02017-11-02 16:09:35 +000083 DataType::S8)),
Gian Marcofa4cacd2017-10-18 17:05:02 +010084 shape_a, shape_b, shape_c, a_offset, b_offset, c_offset, c_mult_int, out_shift, data_type)
85{
86 // Create tensors
87 Tensor a = create_tensor<Tensor>(shape_a, data_type);
88 Tensor b = create_tensor<Tensor>(shape_b, data_type);
89 Tensor c = create_tensor<Tensor>(shape_c, data_type);
90
91 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
92 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
93 ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS);
94
95 // Create and configure function
96 NEGEMMLowp gemmlowp;
97 gemmlowp.configure(&a, &b, &c, a_offset, b_offset, c_offset, c_mult_int, out_shift);
98}
99
Pablo Tello6ff12a02017-11-02 16:09:35 +0000100FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpOffsetFixture, framework::DatasetMode::ALL, combine(datasets::SmallGEMMLowpDataset(), framework::dataset::make("DataType", DataType::S8)))
Pablo Tello299025a2017-09-29 11:30:12 +0100101{
102 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100103 validate(Accessor(_target), _reference);
104}
105
Pablo Tello6ff12a02017-11-02 16:09:35 +0000106FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpOffsetFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMLowpDataset(), framework::dataset::make("DataType", DataType::S8)))
Gian Marcofa4cacd2017-10-18 17:05:02 +0100107{
108 // Validate output
109 validate(Accessor(_target), _reference);
Pablo Tello299025a2017-09-29 11:30:12 +0100110}
Pablo Tello6ff12a02017-11-02 16:09:35 +0000111TEST_SUITE_END() // U8
Pablo Tello299025a2017-09-29 11:30:12 +0100112
Pablo Tello6ff12a02017-11-02 16:09:35 +0000113TEST_SUITE(S32)
114using NEGEMMLowpMatrixMultiplyFixture = GEMMLowpMatrixMultiplyValidationFixture<Tensor, Accessor, NEGEMMLowpMatrixMultiplyCore>;
115FIXTURE_DATA_TEST_CASE(MatrixMultiply, NEGEMMLowpMatrixMultiplyFixture, framework::DatasetMode::PRECOMMIT, data_matrix_multiply)
Pablo Tellobf2fb952017-09-29 16:43:25 +0100116{
117 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100118 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +0100119}
120TEST_SUITE_END()
Pablo Tello6ff12a02017-11-02 16:09:35 +0000121
Pablo Tello299025a2017-09-29 11:30:12 +0100122TEST_SUITE_END()
Gian Marco Iodiceab182122017-10-09 15:05:40 +0100123TEST_SUITE_END()
Pablo Tello299025a2017-09-29 11:30:12 +0100124} // namespace validation
125} // namespace test
126} // namespace arm_compute