blob: 1f9319b10f820316296aca24c7cc7ff5a478bade [file] [log] [blame]
Ramy Elgammal73f19af2022-10-23 11:44:49 +01001/*
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
25#include "arm_compute/core/TensorInfo.h"
26#include "arm_compute/core/Types.h"
27
28#include "arm_compute/core/CL/CLKernelLibrary.h"
29#include "arm_compute/runtime/CL/CLScheduler.h"
30#include "arm_compute/dynamic_fusion/runtime/gpu/cl/ClWorkloadRuntime.h"
31#include "arm_compute/dynamic_fusion/sketch/OperatorAttributes.h"
32#include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadSketch.h"
33#include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuConv2d.h"
34
35#include "tests/AssetsLibrary.h"
36#include "tests/CL/CLAccessor.h"
37#include "tests/Globals.h"
38#include "tests/IAccessor.h"
39#include "tests/framework/Asserts.h"
40#include "tests/framework/Fixture.h"
41#include "tests/framework/Macros.h"
42#include "tests/framework/datasets/Datasets.h"
43#include "tests/validation/Validation.h"
44#include "tests/validation/reference/ConvolutionLayer.h"
45
46#include "tests/datasets/SmallConvolutionLayerDataset.h"
47#include "tests/validation/fixtures/dynamic_fusion/gpu/cl/DirectConv2dFixture.h"
48
49#ifdef ARM_COMPUTE_ASSERTS_ENABLED
50#include "tests/SimpleTensorPrinter.h"
51#endif /* ARM_COMPUTE_ASSERTS_ENABLED */
52#include "tests/framework/Asserts.h"
53#include "tests/framework/Macros.h"
54#include "tests/validation/Validation.h"
55namespace arm_compute
56{
57namespace test
58{
59namespace validation
60{
61TEST_SUITE(CL)
62TEST_SUITE(DYNAMIC_FUSION)
63TEST_SUITE(GPU_CONV2D)
64
65RelativeTolerance<float> tolerance_f32(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
66RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.1)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */
67constexpr float tolerance_num = 0.02f; /**< Tolerance number */
68
69template <typename T>
70using DynamicFusionGpuConv2dFixture = DynamicFusionGpuConv2dValidationFixture<CLTensor, CLAccessor, GpuConv2d, T>;
71TEST_SUITE(FP32)
72FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuConv2dFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
73 framework::dataset::make("DataType", DataType::F32)),
74 framework::dataset::make("DataLayout", { DataLayout::NHWC })),
75 framework::dataset::make("QuantizationInfo", QuantizationInfo())))
76{
77 // Validate output
78 validate(CLAccessor(_target), _reference, tolerance_f32);
79}
80TEST_SUITE_END() // FP32
81
82#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
83TEST_SUITE(FP16)
84FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuConv2dFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
85 framework::dataset::make("DataType", DataType::F16)),
86 framework::dataset::make("DataLayout", { DataLayout::NHWC })),
87 framework::dataset::make("QuantizationInfo", QuantizationInfo())))
88{
89 // Validate output
90 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
91}
92TEST_SUITE_END() // FP16
93#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
94
95TEST_SUITE_END() // GPU_CONV2D
96TEST_SUITE_END() // DYNAMIC_FUSION
97TEST_SUITE_END() // CL
98} // namespace validation
99} // namespace test
100} // namespace arm_compute