Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 1 | /* |
Matthew Bentham | 945b8da | 2023-07-12 11:54:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2021, 2023 Arm Limited. |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +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 | #ifndef ARM_COMPUTE_TEST_ARITHMETIC_OPERATIONS_FIXTURE |
| 25 | #define ARM_COMPUTE_TEST_ARITHMETIC_OPERATIONS_FIXTURE |
| 26 | |
| 27 | #include "arm_compute/core/TensorShape.h" |
| 28 | #include "arm_compute/core/Types.h" |
| 29 | #include "tests/AssetsLibrary.h" |
| 30 | #include "tests/Globals.h" |
| 31 | #include "tests/IAccessor.h" |
| 32 | #include "tests/framework/Asserts.h" |
| 33 | #include "tests/framework/Fixture.h" |
| 34 | #include "tests/validation/Helpers.h" |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 35 | #include "tests/validation/reference/ActivationLayer.h" |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 36 | #include "tests/validation/reference/ArithmeticOperations.h" |
| 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 45 | class ArithmeticOperationGenericFixture : public framework::Fixture |
| 46 | { |
| 47 | public: |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 48 | void setup(reference::ArithmeticOperation op, const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 49 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, ActivationLayerInfo act_info, bool is_inplace) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 50 | { |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 51 | _op = op; |
| 52 | _act_info = act_info; |
| 53 | _is_inplace = is_inplace; |
| 54 | _target = compute_target(shape0, shape1, data_type, convert_policy, qinfo0, qinfo1, qinfo_out); |
| 55 | _reference = compute_reference(shape0, shape1, data_type, convert_policy, qinfo0, qinfo1, qinfo_out); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | protected: |
| 59 | template <typename U> |
| 60 | void fill(U &&tensor, int i) |
| 61 | { |
| 62 | library->fill_tensor_uniform(tensor, i); |
| 63 | } |
| 64 | |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 65 | TensorType compute_target(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 66 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 67 | { |
| 68 | // Create tensors |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 69 | const TensorShape out_shape = TensorShape::broadcast_shape(shape0, shape1); |
| 70 | TensorType ref_src1 = create_tensor<TensorType>(shape0, data_type, 1, qinfo0); |
| 71 | TensorType ref_src2 = create_tensor<TensorType>(shape1, data_type, 1, qinfo1); |
| 72 | TensorType dst = create_tensor<TensorType>(out_shape, data_type, 1, qinfo_out); |
| 73 | |
| 74 | // Check whether do in-place computation and whether inputs are broadcast compatible |
| 75 | TensorType *actual_dst = &dst; |
| 76 | if(_is_inplace) |
| 77 | { |
| 78 | bool src1_is_inplace = !arm_compute::detail::have_different_dimensions(out_shape, shape0, 0) && (qinfo0 == qinfo_out); |
| 79 | bool src2_is_inplace = !arm_compute::detail::have_different_dimensions(out_shape, shape1, 0) && (qinfo1 == qinfo_out); |
| 80 | bool do_in_place = out_shape.total_size() != 0 && (src1_is_inplace || src2_is_inplace); |
| 81 | ARM_COMPUTE_ASSERT(do_in_place); |
| 82 | |
| 83 | if(src1_is_inplace) |
| 84 | { |
| 85 | actual_dst = &ref_src1; |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | actual_dst = &ref_src2; |
| 90 | } |
| 91 | } |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 92 | |
| 93 | // Create and configure function |
| 94 | FunctionType arith_op; |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 95 | arith_op.configure(&ref_src1, &ref_src2, actual_dst, convert_policy, _act_info); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 96 | |
Michele Di Giorgio | 4fc10b3 | 2021-04-30 18:30:41 +0100 | [diff] [blame] | 97 | ARM_COMPUTE_ASSERT(ref_src1.info()->is_resizable()); |
| 98 | ARM_COMPUTE_ASSERT(ref_src2.info()->is_resizable()); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 99 | |
| 100 | // Allocate tensors |
| 101 | ref_src1.allocator()->allocate(); |
| 102 | ref_src2.allocator()->allocate(); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 103 | |
Michele Di Giorgio | 4fc10b3 | 2021-04-30 18:30:41 +0100 | [diff] [blame] | 104 | ARM_COMPUTE_ASSERT(!ref_src1.info()->is_resizable()); |
| 105 | ARM_COMPUTE_ASSERT(!ref_src2.info()->is_resizable()); |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 106 | |
| 107 | // If don't do in-place computation, still need to allocate original dst |
| 108 | if(!_is_inplace) |
| 109 | { |
| 110 | ARM_COMPUTE_ASSERT(dst.info()->is_resizable()); |
| 111 | dst.allocator()->allocate(); |
| 112 | ARM_COMPUTE_ASSERT(!dst.info()->is_resizable()); |
| 113 | } |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 114 | |
| 115 | // Fill tensors |
| 116 | fill(AccessorType(ref_src1), 0); |
| 117 | fill(AccessorType(ref_src2), 1); |
| 118 | |
| 119 | // Compute function |
| 120 | arith_op.run(); |
| 121 | |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 122 | return std::move(*actual_dst); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 123 | } |
| 124 | |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 125 | SimpleTensor<T> compute_reference(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 126 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 127 | { |
| 128 | // Create reference |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 129 | SimpleTensor<T> ref_src1{ shape0, data_type, 1, qinfo0 }; |
| 130 | SimpleTensor<T> ref_src2{ shape1, data_type, 1, qinfo1 }; |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 131 | SimpleTensor<T> ref_dst{ TensorShape::broadcast_shape(shape0, shape1), data_type, 1, qinfo_out }; |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 132 | |
| 133 | // Fill reference |
| 134 | fill(ref_src1, 0); |
| 135 | fill(ref_src2, 1); |
| 136 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 137 | auto result = reference::arithmetic_operation<T>(_op, ref_src1, ref_src2, ref_dst, convert_policy); |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 138 | return _act_info.enabled() ? reference::activation_layer(result, _act_info, qinfo_out) : result; |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | TensorType _target{}; |
| 142 | SimpleTensor<T> _reference{}; |
| 143 | reference::ArithmeticOperation _op{ reference::ArithmeticOperation::ADD }; |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 144 | ActivationLayerInfo _act_info{}; |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 145 | bool _is_inplace{}; |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 149 | class ArithmeticAdditionBroadcastValidationFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 150 | { |
| 151 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 152 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, bool is_inplace) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 153 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 154 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::ADD, shape0, shape1, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 155 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), ActivationLayerInfo(), is_inplace); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 156 | } |
| 157 | }; |
| 158 | |
| 159 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 160 | class ArithmeticAdditionValidationFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 161 | { |
| 162 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 163 | void setup(const TensorShape &shape, DataType data_type, ConvertPolicy convert_policy, bool is_inplace) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 164 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 165 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::ADD, shape, shape, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 166 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), ActivationLayerInfo(), is_inplace); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 167 | } |
| 168 | }; |
| 169 | |
| 170 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 171 | class ArithmeticAdditionBroadcastValidationFloatFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 172 | { |
| 173 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 174 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, ActivationLayerInfo act_info, bool is_inplace) |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 175 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 176 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::ADD, shape0, shape1, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 177 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, is_inplace); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 178 | } |
| 179 | }; |
| 180 | |
| 181 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 182 | class ArithmeticAdditionValidationFloatFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 183 | { |
| 184 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 185 | void setup(const TensorShape &shape, DataType data_type, ConvertPolicy convert_policy, ActivationLayerInfo act_info, bool is_inplace) |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 186 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 187 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::ADD, shape, shape, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 188 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, is_inplace); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 189 | } |
| 190 | }; |
| 191 | |
| 192 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 193 | class ArithmeticAdditionValidationQuantizedFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 194 | { |
| 195 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 196 | void setup(const TensorShape &shape, DataType data_type, ConvertPolicy convert_policy, QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, bool is_inplace) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 197 | |
| 198 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 199 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::ADD, shape, shape, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 200 | qinfo0, qinfo1, qinfo_out, ActivationLayerInfo(), is_inplace); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 201 | } |
| 202 | }; |
| 203 | |
| 204 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Michalis Spyrou | 2232a20 | 2020-07-13 15:15:33 +0100 | [diff] [blame] | 205 | class ArithmeticAdditionValidationQuantizedBroadcastFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 206 | { |
| 207 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 208 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, |
| 209 | bool is_inplace) |
Michalis Spyrou | 2232a20 | 2020-07-13 15:15:33 +0100 | [diff] [blame] | 210 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 211 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::ADD, shape0, shape1, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 212 | qinfo0, qinfo1, qinfo_out, ActivationLayerInfo(), is_inplace); |
Michalis Spyrou | 2232a20 | 2020-07-13 15:15:33 +0100 | [diff] [blame] | 213 | } |
| 214 | }; |
| 215 | |
| 216 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 217 | class ArithmeticSubtractionBroadcastValidationFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 218 | { |
| 219 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 220 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, bool is_inplace) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 221 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 222 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::SUB, shape0, shape1, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 223 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), ActivationLayerInfo(), is_inplace); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 224 | } |
| 225 | }; |
| 226 | |
| 227 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 228 | class ArithmeticSubtractionBroadcastValidationFloatFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 229 | { |
| 230 | public: |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 231 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, ActivationLayerInfo act_info, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 232 | bool is_inplace) |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 233 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 234 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::SUB, shape0, shape1, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 235 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, is_inplace); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 236 | } |
| 237 | }; |
| 238 | |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 239 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 240 | class ArithmeticSubtractionValidationFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 241 | { |
| 242 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 243 | void setup(const TensorShape &shape, DataType data_type, ConvertPolicy convert_policy, bool is_inplace) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 244 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 245 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::SUB, shape, shape, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 246 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), ActivationLayerInfo(), is_inplace); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 247 | } |
| 248 | }; |
| 249 | |
| 250 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 251 | class ArithmeticSubtractionValidationFloatFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 252 | { |
| 253 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 254 | void setup(const TensorShape &shape, DataType data_type, ConvertPolicy convert_policy, ActivationLayerInfo act_info, bool is_inplace) |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 255 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 256 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::SUB, shape, shape, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 257 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, is_inplace); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 258 | } |
| 259 | }; |
| 260 | |
| 261 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 262 | class ArithmeticSubtractionValidationQuantizedFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 263 | { |
| 264 | public: |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 265 | void setup(const TensorShape &shape, DataType data_type, ConvertPolicy convert_policy, QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, bool is_inplace) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 266 | |
| 267 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 268 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::SUB, shape, shape, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 269 | qinfo0, qinfo1, qinfo_out, ActivationLayerInfo(), is_inplace); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 270 | } |
| 271 | }; |
Michalis Spyrou | eae6584 | 2020-06-15 20:23:59 +0100 | [diff] [blame] | 272 | |
| 273 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 274 | class ArithmeticSubtractionValidationQuantizedBroadcastFixture : public ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 275 | { |
| 276 | public: |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 277 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type, ConvertPolicy convert_policy, QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 278 | bool is_inplace) |
Michalis Spyrou | eae6584 | 2020-06-15 20:23:59 +0100 | [diff] [blame] | 279 | { |
Georgios Pinitas | da81675 | 2021-07-02 09:22:14 +0100 | [diff] [blame] | 280 | ArithmeticOperationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(reference::ArithmeticOperation::SUB, shape0, shape1, data_type, convert_policy, |
Sheri Zhang | a387e27 | 2021-06-29 17:34:06 +0100 | [diff] [blame] | 281 | qinfo0, qinfo1, qinfo_out, ActivationLayerInfo(), is_inplace); |
Michalis Spyrou | eae6584 | 2020-06-15 20:23:59 +0100 | [diff] [blame] | 282 | } |
| 283 | }; |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 284 | } // namespace validation |
| 285 | } // namespace test |
| 286 | } // namespace arm_compute |
| 287 | #endif /* ARM_COMPUTE_TEST_ARITHMETIC_OPERATIONS_FIXTURE */ |