blob: bd259f785e21f6c52e358fbabdfc8f6150c2ac9d [file] [log] [blame]
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +00001/*
2 * Copyright (c) 2023 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/runtime/CL/CLTensor.h"
25#include "arm_compute/runtime/CL/functions/CLMatMul.h"
26#include "tests/CL/CLAccessor.h"
27#include "tests/datasets/LargeMatMulDataset.h"
28#include "tests/datasets/SmallMatMulDataset.h"
29#include "tests/framework/Macros.h"
30#include "tests/framework/datasets/Datasets.h"
31#include "tests/validation/Validation.h"
32#include "tests/validation/fixtures/MatMulFixture.h"
33
34namespace arm_compute
35{
36namespace test
37{
38namespace validation
39{
40namespace
41{
42RelativeTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for fp32 data type */
43constexpr float abs_tolerance_f32(
44 0.0001f); /**< Absolute tolerance value for comparing reference's output against implementation's output for fp32 data type in case using relative tolerance fails because of small values */
45constexpr float abs_tolerance_f16(
46 0.001f); /**< Absolute tolerance value for comparing reference's output against implementation's output for fp16 data type in case using relative tolerance fails because of small values */
47RelativeTolerance<half_float::half> tolerance_f16(half(0.01)); /**< Tolerance value for comparing reference's output against implementation's output for fp16 data type */
48} // namespace
49template <typename T>
50using MatMulFixture = MatMulValidationFixture<CLTensor, CLAccessor, CLMatMul, T>;
51
52TEST_SUITE(CL)
53TEST_SUITE(MatMul)
54TEST_SUITE(FP32)
55FIXTURE_DATA_TEST_CASE(RunSmall, MatMulFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallMatMulDataset(),
56 framework::dataset::make("pretransose_A", { false, true })),
57 framework::dataset::make("pretransose_B", { false, true })),
58 framework::dataset::make("DataType", DataType::F32)))
59{
60 // Validate output
61 validate(CLAccessor(_target), _reference, tolerance_f32);
62}
63FIXTURE_DATA_TEST_CASE(RunLarge, MatMulFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeMatMulDataset(),
64 framework::dataset::make("pretransose_A", { false, true })),
65 framework::dataset::make("pretransose_B", { false, true })),
66 framework::dataset::make("DataType", DataType::F32)))
67{
68 // Validate output
69 validate(CLAccessor(_target), _reference, tolerance_f32);
70}
71TEST_SUITE_END() // FP32
72TEST_SUITE(FP16)
73FIXTURE_DATA_TEST_CASE(RunSmall, MatMulFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallMatMulDataset(),
74 framework::dataset::make("pretransose_A", { false, true })),
75 framework::dataset::make("pretransose_B", { false, true })),
76 framework::dataset::make("DataType", DataType::F16)))
77{
78 // Validate output
79 validate(CLAccessor(_target), _reference, tolerance_f16);
80}
81FIXTURE_DATA_TEST_CASE(RunLarge, MatMulFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeMatMulDataset(),
82 framework::dataset::make("pretransose_A", { false, true })),
83 framework::dataset::make("pretransose_B", { false, true })),
84 framework::dataset::make("DataType", DataType::F16)))
85{
86 // Validate output
87 validate(CLAccessor(_target), _reference, tolerance_f16);
88}
89TEST_SUITE_END() // FP16
90TEST_SUITE_END() // MatMul
91TEST_SUITE_END() // CL
92} // namespace validation
93} // namespace test
94} // namespace arm_compute