blob: 4d038b2780dfc4736c2e646c44aeb8e2d23b9d14 [file] [log] [blame]
Ramy Elgammalf800adf2022-12-14 15:39:29 +00001/*
2 * Copyright (c) 2023 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 */
SiCong Li23882a92023-06-28 09:49:45 +010024#ifndef ACL_INTERNAL_TEST_CKW_IN_DF // Do not include this test if ACL_INTERNAL_TEST_CKW_IN_DF and the op has not been ported to ckw
Ramy Elgammalf800adf2022-12-14 15:39:29 +000025#include "tests/CL/CLAccessor.h"
26#include "tests/datasets/ReshapeLayerDataset.h"
27#include "tests/framework/Macros.h"
28#include "tests/framework/datasets/Datasets.h"
29#include "tests/validation/Validation.h"
30#include "tests/validation/fixtures/dynamic_fusion/operators/ReshapeFixture.h"
31
32namespace arm_compute
33{
34namespace test
35{
36namespace validation
37{
38TEST_SUITE(CL)
39TEST_SUITE(DYNAMIC_FUSION)
40TEST_SUITE(RESHAPE)
41
Omar Al Khatib3c7c1fa2023-03-07 09:57:49 +000042DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(framework::dataset::make("InputInfo",
Ramy Elgammalf800adf2022-12-14 15:39:29 +000043{
Omar Al Khatib3c7c1fa2023-03-07 09:57:49 +000044 TensorInfo(TensorShape(9U, 5U, 7U, 3U), 1, DataType::F32), TensorInfo(TensorShape(8U, 4U, 6U, 4U), 1, DataType::F32), TensorInfo(TensorShape(8U, 4U, 6U, 4U), 1, DataType::F32) /*mismatching dimensions*/,
Ramy Elgammalf800adf2022-12-14 15:39:29 +000045}),
Gunes Bayircc287732023-01-19 15:56:00 +000046framework::dataset::make("OutputShape",
Ramy Elgammalf800adf2022-12-14 15:39:29 +000047{
Gunes Bayircc287732023-01-19 15:56:00 +000048 TensorShape(9U, 5U, 21U),
49 TensorShape(8U, 24U, 4U),
50 TensorShape(192U, 192U),
Ramy Elgammalf800adf2022-12-14 15:39:29 +000051})),
Gunes Bayircc287732023-01-19 15:56:00 +000052framework::dataset::make("Expected", { true, true, false })),
53input_info, output_shape, expected)
Ramy Elgammalf800adf2022-12-14 15:39:29 +000054{
55 // Create a new workload sketch
56 auto cl_compile_ctx = CLKernelLibrary::get().get_compile_context();
Viet-Hoa Do3fcf3dc2023-05-17 15:17:48 +010057 auto context = GpuWorkloadContext{ &cl_compile_ctx };
58 GpuWorkloadSketch sketch{ &context };
Ramy Elgammalf800adf2022-12-14 15:39:29 +000059
60 // Create sketch tensors
Gunes Bayircc287732023-01-19 15:56:00 +000061 TensorShape input_shape = input_info.tensor_shape();
Omar Al Khatib3c7c1fa2023-03-07 09:57:49 +000062 ARM_COMPUTE_UNUSED(input_shape);
Viet-Hoa Do3fcf3dc2023-05-17 15:17:48 +010063 TensorInfo src_info = context.create_tensor_info(input_info);
Gunes Bayircc287732023-01-19 15:56:00 +000064
Ramy Elgammalf800adf2022-12-14 15:39:29 +000065 ReshapeAttributes attributes;
66 attributes.shape(output_shape);
Gunes Bayircc287732023-01-19 15:56:00 +000067 Status status = GpuReshape::validate_op(sketch, &src_info, attributes);
Ramy Elgammalf800adf2022-12-14 15:39:29 +000068 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
69}
70
71template <typename T>
72using DynamicFusionGpuReshapeLayerFixture = DynamicFusionGpuReshapeLayerValidationFixture<CLTensor, CLAccessor, GpuReshape, T>;
73
74TEST_SUITE(F32)
75FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuReshapeLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::SmallReshapeLayerDataset(), framework::dataset::make("DataType",
76 DataType::F32)))
77{
78 // Validate output
79 validate(CLAccessor(_target), _reference);
80}
81TEST_SUITE_END() // F32
82
83TEST_SUITE(F16)
84FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuReshapeLayerFixture<half>, framework::DatasetMode::ALL, combine(datasets::SmallReshapeLayerDataset(), framework::dataset::make("DataType",
85 DataType::F16)))
86{
87 // Validate output
88 validate(CLAccessor(_target), _reference);
89}
90TEST_SUITE_END() // F16
91
92TEST_SUITE(U8)
93FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuReshapeLayerFixture<uint8_t>, framework::DatasetMode::ALL, combine(datasets::SmallReshapeLayerDataset(), framework::dataset::make("DataType",
94 DataType::U8)))
95{
96 // Validate output
97 validate(CLAccessor(_target), _reference);
98}
99TEST_SUITE_END() // U8
100
101TEST_SUITE(S8)
102FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuReshapeLayerFixture<int8_t>, framework::DatasetMode::ALL, combine(datasets::SmallReshapeLayerDataset(), framework::dataset::make("DataType",
103 DataType::S8)))
104{
105 // Validate output
106 validate(CLAccessor(_target), _reference);
107}
108TEST_SUITE_END() // S8
109
110TEST_SUITE(S16)
111FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuReshapeLayerFixture<int16_t>, framework::DatasetMode::ALL, combine(datasets::SmallReshapeLayerDataset(), framework::dataset::make("DataType",
112 DataType::S16)))
113{
114 // Validate output
115 validate(CLAccessor(_target), _reference);
116}
117TEST_SUITE_END() // S16
118
119TEST_SUITE_END() // RESHAPE
120TEST_SUITE_END() // DYNAMIC_FUSION
121TEST_SUITE_END() // CL
122} // namespace validation
123} // namespace test
124} // namespace arm_compute
SiCong Li23882a92023-06-28 09:49:45 +0100125
126#endif // ACL_INTERNAL_TEST_CKW_IN_DF