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