1 /*
2 * Copyright (c) 2018-2020 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/CLScheduler.h"
25 #include "arm_compute/runtime/CL/CLTensor.h"
26 #include "arm_compute/runtime/CL/tuners/BifrostTuner.h"
27 #include "src/core/CL/kernels/CLDirectConvolutionLayerKernel.h"
28 #include "tests/Utils.h"
29 #include "tests/framework/Asserts.h"
30 #include "tests/framework/Macros.h"
31
32 namespace arm_compute
33 {
34 namespace test
35 {
36 namespace validation
37 {
38 TEST_SUITE(CL)
TEST_SUITE(UNIT)39 TEST_SUITE(UNIT)
40 TEST_SUITE(Tuner)
41
42 /** Validates static tuning of Bifrost tuner */
43 TEST_CASE(BifrostTunerSimple, framework::DatasetMode::ALL)
44 {
45 // Create tuner
46 tuners::BifrostTuner tuner;
47
48 // Create tensors
49 auto src = create_tensor<CLTensor>(TensorShape(13U, 13U, 16U), DataType::F32);
50 auto weights = create_tensor<CLTensor>(TensorShape(3U, 3U, 16U, 3U), DataType::F32);
51 auto bias = create_tensor<CLTensor>(TensorShape(3U), DataType::F32);
52 auto dst = create_tensor<CLTensor>(TensorShape(13U, 13U, 3U), DataType::F32);
53
54 // Create kernel
55 cl::NDRange fake_lws(2000);
56 CLDirectConvolutionLayerKernel conv;
57 conv.set_target(GPUTarget::G72);
58
59 // Configure
60 conv.configure(&src, &weights, &bias, &dst, PadStrideInfo(1, 1, 1, 1));
61
62 // Hard-wire lws to kernel and validate lws
63 conv.set_lws_hint(fake_lws);
64 ARM_COMPUTE_EXPECT(conv.lws_hint()[0] == 2000, framework::LogLevel::ERRORS);
65
66 // Tune kernel and validate
67 tuner.tune_kernel_static(conv);
68 ARM_COMPUTE_EXPECT(conv.lws_hint()[0] != 2000, framework::LogLevel::ERRORS);
69
70 // Clear tuner
71 CLScheduler::get().default_init();
72 }
73 TEST_SUITE_END()
74 TEST_SUITE_END()
75 TEST_SUITE_END()
76 } // namespace validation
77 } // namespace test
78 } // namespace arm_compute
79