Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 1 | /* |
| 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 Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 24 | #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 Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 25 | #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 | |
| 32 | namespace arm_compute |
| 33 | { |
| 34 | namespace test |
| 35 | { |
| 36 | namespace validation |
| 37 | { |
| 38 | TEST_SUITE(CL) |
| 39 | TEST_SUITE(DYNAMIC_FUSION) |
| 40 | TEST_SUITE(RESHAPE) |
| 41 | |
Omar Al Khatib | 3c7c1fa | 2023-03-07 09:57:49 +0000 | [diff] [blame] | 42 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(framework::dataset::make("InputInfo", |
Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 43 | { |
Omar Al Khatib | 3c7c1fa | 2023-03-07 09:57:49 +0000 | [diff] [blame] | 44 | 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 Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 45 | }), |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 46 | framework::dataset::make("OutputShape", |
Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 47 | { |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 48 | TensorShape(9U, 5U, 21U), |
| 49 | TensorShape(8U, 24U, 4U), |
| 50 | TensorShape(192U, 192U), |
Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 51 | })), |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 52 | framework::dataset::make("Expected", { true, true, false })), |
| 53 | input_info, output_shape, expected) |
Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 54 | { |
| 55 | // Create a new workload sketch |
| 56 | auto cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 57 | auto context = GpuWorkloadContext{ &cl_compile_ctx }; |
| 58 | GpuWorkloadSketch sketch{ &context }; |
Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 59 | |
| 60 | // Create sketch tensors |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 61 | TensorShape input_shape = input_info.tensor_shape(); |
Omar Al Khatib | 3c7c1fa | 2023-03-07 09:57:49 +0000 | [diff] [blame] | 62 | ARM_COMPUTE_UNUSED(input_shape); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 63 | TensorInfo src_info = context.create_tensor_info(input_info); |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 64 | |
Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 65 | ReshapeAttributes attributes; |
| 66 | attributes.shape(output_shape); |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 67 | Status status = GpuReshape::validate_op(sketch, &src_info, attributes); |
Ramy Elgammal | f800adf | 2022-12-14 15:39:29 +0000 | [diff] [blame] | 68 | ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS); |
| 69 | } |
| 70 | |
| 71 | template <typename T> |
| 72 | using DynamicFusionGpuReshapeLayerFixture = DynamicFusionGpuReshapeLayerValidationFixture<CLTensor, CLAccessor, GpuReshape, T>; |
| 73 | |
| 74 | TEST_SUITE(F32) |
| 75 | FIXTURE_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 | } |
| 81 | TEST_SUITE_END() // F32 |
| 82 | |
| 83 | TEST_SUITE(F16) |
| 84 | FIXTURE_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 | } |
| 90 | TEST_SUITE_END() // F16 |
| 91 | |
| 92 | TEST_SUITE(U8) |
| 93 | FIXTURE_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 | } |
| 99 | TEST_SUITE_END() // U8 |
| 100 | |
| 101 | TEST_SUITE(S8) |
| 102 | FIXTURE_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 | } |
| 108 | TEST_SUITE_END() // S8 |
| 109 | |
| 110 | TEST_SUITE(S16) |
| 111 | FIXTURE_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 | } |
| 117 | TEST_SUITE_END() // S16 |
| 118 | |
| 119 | TEST_SUITE_END() // RESHAPE |
| 120 | TEST_SUITE_END() // DYNAMIC_FUSION |
| 121 | TEST_SUITE_END() // CL |
| 122 | } // namespace validation |
| 123 | } // namespace test |
| 124 | } // namespace arm_compute |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 125 | |
| 126 | #endif // ACL_INTERNAL_TEST_CKW_IN_DF |