Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 1 | /* |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 ARM Limited. |
Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 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/CLWeightsReshapeKernel.h" |
| 25 | #include "arm_compute/core/Types.h" |
| 26 | #include "tests/CL/Helper.h" |
| 27 | |
| 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/datasets/ShapeDatasets.h" |
| 30 | #include "tests/framework/Asserts.h" |
| 31 | #include "tests/framework/Macros.h" |
| 32 | #include "tests/framework/datasets/Datasets.h" |
| 33 | #include "tests/validation/Validation.h" |
| 34 | #include "tests/validation/fixtures/WeightsReshapeFixture.h" |
| 35 | |
| 36 | namespace arm_compute |
| 37 | { |
| 38 | namespace test |
| 39 | { |
| 40 | namespace validation |
| 41 | { |
| 42 | TEST_SUITE(CL) |
| 43 | TEST_SUITE(WeightsReshape) |
| 44 | |
| 45 | using CLWeightsReshape = CLSynthetizeFunction<CLWeightsReshapeKernel>; |
| 46 | |
| 47 | // *INDENT-OFF* |
| 48 | // clang-format off |
| 49 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 50 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), // Mismatching data type |
Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 51 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::QASYMM8), // Bias not supported with QASYMM8 |
| 52 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 53 | }), |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 54 | framework::dataset::make("BiasesInfo", { TensorInfo(TensorShape(4U), 1, DataType::F16), |
Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 55 | TensorInfo(TensorShape(4U), 1, DataType::QASYMM8), |
| 56 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 57 | })), |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 58 | framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(4U, 19U), 1, DataType::F16), |
Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 59 | TensorInfo(TensorShape(4U, 19U), 1, DataType::QASYMM8), |
| 60 | TensorInfo(TensorShape(4U, 19U), 1, DataType::F32), |
| 61 | })), |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 62 | framework::dataset::make("Expected", { false, false, true })), |
Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 63 | input_info, biases_info, output_info, expected) |
| 64 | { |
| 65 | bool status = bool(CLWeightsReshape::validate(&input_info, &biases_info, &output_info)); |
| 66 | ARM_COMPUTE_EXPECT(status == expected, framework::LogLevel::ERRORS); |
| 67 | } |
| 68 | // clang-format on |
| 69 | // *INDENT-ON* |
| 70 | |
| 71 | template <typename T> |
| 72 | using CLWeightsReshapeFixture = WeightsReshapeValidationFixture<CLTensor, CLAccessor, CLWeightsReshape, T>; |
| 73 | |
| 74 | TEST_SUITE(Float) |
| 75 | TEST_SUITE(FP32) |
| 76 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType", |
| 77 | DataType::F32)), |
| 78 | framework::dataset::make("HasBias", { true, false })), |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 79 | framework::dataset::make("NumGroups", { 1, 2, 3, 4 }))) |
Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 80 | { |
| 81 | // Validate output |
| 82 | validate(CLAccessor(_target), _reference); |
| 83 | } |
| 84 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType", |
| 85 | DataType::F32)), |
| 86 | framework::dataset::make("HasBias", { true, false })), |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 87 | framework::dataset::make("NumGroups", { 1, 2, 3, 4 }))) |
Giorgio Arena | c6aa49b | 2018-08-07 11:53:30 +0100 | [diff] [blame] | 88 | { |
| 89 | // Validate output |
| 90 | validate(CLAccessor(_target), _reference); |
| 91 | } |
| 92 | TEST_SUITE_END() |
| 93 | |
| 94 | TEST_SUITE(FP16) |
| 95 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType", |
| 96 | DataType::F16)), |
| 97 | framework::dataset::make("HasBias", { true, false })), |
| 98 | framework::dataset::make("NumGroups", { 1, 2, 3 }))) |
| 99 | { |
| 100 | // Validate output |
| 101 | validate(CLAccessor(_target), _reference); |
| 102 | } |
| 103 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType", |
| 104 | DataType::F16)), |
| 105 | framework::dataset::make("HasBias", { true, false })), |
| 106 | framework::dataset::make("NumGroups", { 1, 2, 3 }))) |
| 107 | { |
| 108 | // Validate output |
| 109 | validate(CLAccessor(_target), _reference); |
| 110 | } |
| 111 | TEST_SUITE_END() |
| 112 | |
| 113 | TEST_SUITE_END() |
| 114 | |
| 115 | TEST_SUITE(QASYMM8) |
| 116 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType", |
| 117 | DataType::QASYMM8)), |
| 118 | framework::dataset::make("HasBias", { false })), |
| 119 | framework::dataset::make("NumGroups", { 1, 2, 3 }))) |
| 120 | { |
| 121 | // Validate output |
| 122 | validate(CLAccessor(_target), _reference); |
| 123 | } |
| 124 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType", |
| 125 | DataType::QASYMM8)), |
| 126 | framework::dataset::make("HasBias", { false })), |
| 127 | framework::dataset::make("NumGroups", { 1, 2, 3 }))) |
| 128 | { |
| 129 | // Validate output |
| 130 | validate(CLAccessor(_target), _reference); |
| 131 | } |
| 132 | TEST_SUITE_END() |
| 133 | |
| 134 | TEST_SUITE_END() |
| 135 | TEST_SUITE_END() |
| 136 | } // namespace validation |
| 137 | } // namespace test |
| 138 | } // namespace arm_compute |