blob: 598e219fd9f4afb0d346adee5b3d4be3b5b46ee4 [file] [log] [blame]
Georgios Pinitas8a5146f2021-01-12 15:51:07 +00001/*
2 * Copyright (c) 2021 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 */
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000024#include "tests/validation/fixtures/UNIT/ContextFixture.h"
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000025
26#include "src/gpu/cl/ClContext.h"
27
28using namespace arm_compute::mlgo;
29
30namespace arm_compute
31{
32namespace test
33{
34namespace validation
35{
36TEST_SUITE(CL)
37TEST_SUITE(UNIT)
38TEST_SUITE(Context)
39
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000040EMPTY_BODY_FIXTURE_TEST_CASE(SimpleContextCApi, SimpleContextCApiFixture<AclTarget::AclGpuOcl>, framework::DatasetMode::ALL)
41EMPTY_BODY_FIXTURE_TEST_CASE(SimpleContextCppApi, SimpleContextCppApiFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
42EMPTY_BODY_FIXTURE_TEST_CASE(MultipleContexts, MultipleContextsFixture<AclTarget::AclGpuOcl>, framework::DatasetMode::ALL)
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000043
44/** Test-case for MLGO kernel configuration file
45 *
46 * Validate that CpuCapabilities are set correctly
47 *
48 * Test Steps:
49 * - Create a file with the MLGO configuration
50 * - Pass the kernel file to the Context during creation
51 * - Validate that the MLGO file has been parsed successfully
52 */
53TEST_CASE(CheckMLGO, framework::DatasetMode::ALL)
54{
55 // Create test mlgo file
56 std::string mlgo_str = R"_(
57
58 <header>
59
60 gemm-version, [1,2,1]
61 ip-type,gpu
62 </header>
63 <heuristics-table>
64 0, g76 , 8, f32, best-performance, static, gemm-type, [m,n,k,n]
65 1, g76 , 8, f16, best-performance, static, gemm-config-reshaped, [m,n,k,n]
66 </heuristics-table>
67 <heuristic, 0>
68 b , 0, var, m, ==, num, 10., 1, 2
69 l , 1, gemm-type, reshaped
70 b , 2, var, r_mn, >=, num, 2., 3, 6
71
72 b , 3, var, n, >=, num, 200., 4, 5
73 l, 4, gemm-type, reshaped-only-rhs
74 l , 5, gemm-type, reshaped
75 l , 6, gemm-type, reshaped-only-rhs
76 </heuristic>
77
78 <heuristic, 1>
79 l ,0,gemm-config-reshaped,[4,2,4,2,8,1,0,1,0]
80 </heuristic>
81
82 )_";
83 const std::string mlgo_filename = "test.mlgo";
84 std::ofstream ofs(mlgo_filename, std::ofstream::trunc);
85 ARM_COMPUTE_EXPECT(ofs, framework::LogLevel::ERRORS);
86 ofs << mlgo_str;
87 ofs.close();
88
Georgios Pinitas3f26ef42021-02-23 10:01:33 +000089 acl::Context::Options opts;
90 opts.copts.kernel_config_file = mlgo_filename.c_str();
91 arm_compute::gpu::opencl::ClContext ctx(&opts.copts);
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000092
93 const MLGOHeuristics &heuristics = ctx.mlgo();
94
95 ARM_COMPUTE_EXPECT(heuristics.query_gemm_type(Query{ "g76", DataType::F32, 10, 1024, 20, 1 }).second == GEMMType::RESHAPED,
96 framework::LogLevel::ERRORS);
97 ARM_COMPUTE_EXPECT((heuristics.query_gemm_config_reshaped(Query{ "g76", DataType::F16, 100, 100, 20, 32 }).second == GEMMConfigReshaped{ 4, 2, 4, 2, 8, true, false, true, false }),
98 framework::LogLevel::ERRORS);
99}
100
101TEST_SUITE_END() // Context
102TEST_SUITE_END() // UNIT
103TEST_SUITE_END() // CL
104} // namespace validation
105} // namespace test
106} // namespace arm_compute