Gian Marco Iodice | 5d01681 | 2022-11-17 11:03:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022 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/Types.h" |
| 25 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 26 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 27 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 28 | #include "src/gpu/cl/kernels/ClIndirectConv2dAddressPrecalculationKernel.h" |
| 29 | #include "tests/CL/CLAccessor.h" |
| 30 | #include "tests/CL/Helper.h" |
| 31 | #include "tests/PaddingCalculator.h" |
| 32 | #include "tests/datasets/ShapeDatasets.h" |
| 33 | #include "tests/framework/Asserts.h" |
| 34 | #include "tests/framework/Macros.h" |
| 35 | #include "tests/framework/datasets/Datasets.h" |
| 36 | #include "tests/validation/Validation.h" |
| 37 | #include "tests/validation/fixtures/IndirectConv2dAddressPrecalculationFixture.h" |
| 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace test |
| 42 | { |
| 43 | namespace validation |
| 44 | { |
| 45 | using namespace arm_compute::misc::shape_calculator; |
| 46 | using namespace arm_compute::opencl::kernels; |
| 47 | |
| 48 | using CLIndirectConv2dAddressPrecalculation = CLSynthetizeOperator<ClIndirectConv2dAddressPrecalculationKernel>; |
| 49 | |
| 50 | using CLIndirectConv2dAddressPrecalculationFixture = IndirectConv2dAddressPrecalculationValidationFixture<CLTensor, CLAccessor, CLIndirectConv2dAddressPrecalculation>; |
| 51 | |
| 52 | // *INDENT-OFF* |
| 53 | // clang-format off |
| 54 | /** Data types */ |
| 55 | |
| 56 | namespace |
| 57 | { |
| 58 | const auto src_w_values = framework::dataset::make("src_w", {91}); |
| 59 | const auto src_h_values = framework::dataset::make("src_h", {103}); |
| 60 | const auto src_b_values = framework::dataset::make("src_b", {1, 2}); |
| 61 | const auto wei_w_values = framework::dataset::make("wei_w", {3, 5}); |
| 62 | const auto wei_h_values = framework::dataset::make("wei_h", {1, 6}); |
| 63 | const auto pad_values = framework::dataset::make("pad", {1, 2, 3}); |
| 64 | const auto stride_values = framework::dataset::make("stride", {1, 2}); |
| 65 | const auto m0_values = framework::dataset::make("M0", { 1, 2, 4, 5, 7 }); |
| 66 | } // namespace |
| 67 | |
| 68 | TEST_SUITE(CL) |
| 69 | TEST_SUITE(IndirectConv2dAddressPrecalculation) |
| 70 | |
| 71 | FIXTURE_DATA_TEST_CASE(RunSmall, CLIndirectConv2dAddressPrecalculationFixture, framework::DatasetMode::ALL, |
| 72 | combine(combine(combine(combine(combine(combine(combine(src_w_values, |
| 73 | src_h_values), |
| 74 | src_b_values), |
| 75 | wei_w_values), |
| 76 | wei_h_values), |
| 77 | pad_values), |
| 78 | stride_values), |
| 79 | m0_values)) |
| 80 | { |
| 81 | // Validate output |
| 82 | validate(CLAccessor(_target), _reference); |
| 83 | } |
| 84 | |
| 85 | TEST_SUITE_END() // IndirectConv2dAddressPrecalculation |
| 86 | TEST_SUITE_END() // CL |
| 87 | } // namespace validation |
| 88 | } // namespace test |
| 89 | } // namespace arm_compute |