Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 1 | /* |
Matthew Bentham | 314d3e2 | 2023-06-23 10:53:52 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, 2023 Arm Limited. |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +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 | */ |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 24 | #include "src/core/CL/kernels/CLFuseBatchNormalizationKernel.h" |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
| 27 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 28 | #include "arm_compute/core/CL/ICLTensor.h" |
| 29 | #include "arm_compute/core/Helpers.h" |
| 30 | #include "arm_compute/core/TensorInfo.h" |
| 31 | #include "arm_compute/core/Utils.h" |
Matthew Bentham | 314d3e2 | 2023-06-23 10:53:52 +0000 | [diff] [blame] | 32 | #include "arm_compute/core/utils/StringUtils.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 33 | |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 34 | #include "src/core/CL/CLValidate.h" |
| 35 | #include "src/core/helpers/AutoConfiguration.h" |
| 36 | #include "src/core/helpers/WindowHelpers.h" |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 37 | #include "support/StringSupport.h" |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace |
| 42 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 43 | Status validate_arguments(const ITensorInfo *input_weights, |
| 44 | const ITensorInfo *bn_mean, |
| 45 | const ITensorInfo *bn_var, |
| 46 | const ITensorInfo *fused_weights, |
| 47 | const ITensorInfo *fused_bias, |
| 48 | const ITensorInfo *input_bias, |
| 49 | const ITensorInfo *bn_beta, |
| 50 | const ITensorInfo *bn_gamma, |
| 51 | float epsilon, |
| 52 | FuseBatchNormalizationType fbn_type) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 53 | { |
| 54 | ARM_COMPUTE_UNUSED(epsilon); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 55 | ARM_COMPUTE_ERROR_ON_NULLPTR(input_weights, bn_mean, bn_var); |
| 56 | ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input_weights); |
| 57 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input_weights, 1, DataType::F16, DataType::F32); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 58 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(bn_mean, bn_var); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 59 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input_weights, bn_mean, bn_var); |
| 60 | ARM_COMPUTE_RETURN_ERROR_ON(input_bias == nullptr && fused_bias == nullptr); |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 61 | ARM_COMPUTE_RETURN_ERROR_ON(bn_mean->num_dimensions() > 1); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 62 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 63 | if (fbn_type == FuseBatchNormalizationType::CONVOLUTION) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 64 | { |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 65 | ARM_COMPUTE_RETURN_ERROR_ON(input_weights->dimension(3) != bn_mean->dimension(0)); |
| 66 | } |
| 67 | else |
| 68 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 69 | const size_t channel_idx = |
| 70 | get_data_layout_dimension_index(input_weights->data_layout(), DataLayoutDimension::CHANNEL); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 71 | ARM_COMPUTE_RETURN_ERROR_ON(input_weights->dimension(channel_idx) != bn_mean->dimension(0)); |
| 72 | } |
| 73 | |
| 74 | // Validate bias |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 75 | if (input_bias != nullptr) |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 76 | { |
| 77 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(bn_mean, input_bias); |
| 78 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input_weights, input_bias); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 79 | } |
| 80 | // Validate beta |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 81 | if (bn_beta != nullptr) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 82 | { |
| 83 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(bn_mean, bn_beta); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 84 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input_weights, bn_beta); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 85 | } |
| 86 | // Validate gamma |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 87 | if (bn_gamma != nullptr) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 88 | { |
| 89 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(bn_mean, bn_gamma); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 90 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input_weights, bn_gamma); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 91 | } |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 92 | // Validate output weights |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 93 | if (fused_weights != nullptr && fused_weights->total_size() != 0) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 94 | { |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 95 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input_weights, fused_weights); |
| 96 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input_weights, fused_weights); |
| 97 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input_weights, fused_weights); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 98 | } |
| 99 | // Validate output bias |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 100 | if (fused_bias != nullptr && fused_bias->total_size() != 0) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 101 | { |
| 102 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(bn_mean, fused_bias); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 103 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input_weights, fused_bias); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | return Status{}; |
| 107 | } |
| 108 | } // namespace |
| 109 | |
| 110 | CLFuseBatchNormalizationKernel::CLFuseBatchNormalizationKernel() |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 111 | : _input_weights(nullptr), |
| 112 | _input_bias(nullptr), |
| 113 | _bn_mean(nullptr), |
| 114 | _bn_var(nullptr), |
| 115 | _bn_gamma(nullptr), |
| 116 | _bn_beta(nullptr), |
| 117 | _fused_weights(nullptr), |
| 118 | _fused_bias(nullptr), |
| 119 | _epsilon(), |
| 120 | _run_in_place_weights(false), |
| 121 | _run_in_place_bias(false) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 122 | { |
Giorgio Arena | 4a95bba | 2021-06-28 11:00:27 +0100 | [diff] [blame] | 123 | _type = CLKernelType::ELEMENTWISE; |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 124 | } |
| 125 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 126 | void CLFuseBatchNormalizationKernel::configure(const ICLTensor *input_weights, |
| 127 | const ICLTensor *bn_mean, |
| 128 | const ICLTensor *bn_var, |
| 129 | ICLTensor *fused_weights, |
| 130 | ICLTensor *fused_bias, |
| 131 | const ICLTensor *input_bias, |
| 132 | const ICLTensor *bn_beta, |
| 133 | const ICLTensor *bn_gamma, |
| 134 | float epsilon, |
| 135 | FuseBatchNormalizationType fbn_type) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 136 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 137 | configure(CLKernelLibrary::get().get_compile_context(), input_weights, bn_mean, bn_var, fused_weights, fused_bias, |
| 138 | input_bias, bn_beta, bn_gamma, epsilon, fbn_type); |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 139 | } |
| 140 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 141 | void CLFuseBatchNormalizationKernel::configure(const CLCompileContext &compile_context, |
| 142 | const ICLTensor *input_weights, |
| 143 | const ICLTensor *bn_mean, |
| 144 | const ICLTensor *bn_var, |
| 145 | ICLTensor *fused_weights, |
| 146 | ICLTensor *fused_bias, |
| 147 | const ICLTensor *input_bias, |
| 148 | const ICLTensor *bn_beta, |
| 149 | const ICLTensor *bn_gamma, |
| 150 | float epsilon, |
| 151 | FuseBatchNormalizationType fbn_type) |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 152 | { |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 153 | ARM_COMPUTE_ERROR_ON_NULLPTR(input_weights, bn_mean, bn_var); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 154 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 155 | auto padding_info = |
| 156 | get_padding_info({input_weights, bn_mean, bn_var, fused_weights, fused_bias, input_bias, bn_beta, bn_gamma}); |
Giorgio Arena | 861c2ec | 2020-10-21 14:29:51 +0100 | [diff] [blame] | 157 | |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 158 | _input_weights = input_weights; |
| 159 | _input_bias = input_bias; |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 160 | _bn_mean = bn_mean; |
| 161 | _bn_var = bn_var; |
| 162 | _bn_beta = bn_beta; |
| 163 | _bn_gamma = bn_gamma; |
| 164 | _fused_weights = fused_weights; |
| 165 | _fused_bias = fused_bias; |
| 166 | _epsilon = epsilon; |
| 167 | |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 168 | _run_in_place_weights = (fused_weights == nullptr) || (fused_weights == input_weights); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 169 | _run_in_place_bias = |
| 170 | (input_bias != nullptr && fused_bias == nullptr) || (input_bias != nullptr && fused_bias == input_bias); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 171 | |
| 172 | // Auto initialize outputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 173 | if (_fused_weights != nullptr) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 174 | { |
| 175 | // Output tensor auto initialization if not yet initialized |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 176 | auto_init_if_empty(*_fused_weights->info(), *_input_weights->info()->clone()); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 177 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 178 | if (_fused_bias != nullptr) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 179 | { |
| 180 | // Output tensor auto initialization if not yet initialized |
| 181 | auto_init_if_empty(*_fused_bias->info(), *_bn_mean->info()->clone()); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | // Validate arguments |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 185 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments( |
| 186 | input_weights->info(), bn_mean->info(), bn_var->info(), |
| 187 | (fused_weights != nullptr) ? fused_weights->info() : nullptr, |
| 188 | (fused_bias != nullptr) ? fused_bias->info() : nullptr, (input_bias != nullptr) ? input_bias->info() : nullptr, |
| 189 | (bn_beta != nullptr) ? bn_beta->info() : nullptr, (bn_gamma != nullptr) ? bn_gamma->info() : nullptr, epsilon, |
| 190 | fbn_type)); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 191 | |
| 192 | // Configure kernel window |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 193 | Window win = calculate_max_window(*input_weights->info()); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 194 | ICLKernel::configure_internal(win); |
| 195 | |
| 196 | // Set build options |
| 197 | CLBuildOptions build_opts; |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 198 | build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input_weights->info()->data_type())); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 199 | build_opts.add_option_if(fbn_type == FuseBatchNormalizationType::CONVOLUTION, |
| 200 | "-DDIM2=" + support::cpp11::to_string(input_weights->info()->dimension(2))); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 201 | build_opts.add_option("-DEPSILON=" + float_to_string_with_full_precision(epsilon)); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 202 | build_opts.add_option_if(_input_weights->info()->data_layout() == DataLayout::NHWC, "-DNHWC"); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 203 | build_opts.add_option_if(_run_in_place_weights, "-DIN_PLACE_W"); |
| 204 | build_opts.add_option_if(_run_in_place_bias, "-DIN_PLACE_B"); |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 205 | build_opts.add_option_if(input_bias != nullptr, "-DBIAS"); |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 206 | build_opts.add_option_if(bn_beta != nullptr, "-DBETA"); |
| 207 | build_opts.add_option_if(bn_gamma != nullptr, "-DGAMMA"); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 208 | |
| 209 | // Create kernel |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 210 | _kernel = create_kernel(compile_context, "fuse_batchnormalization_layer", build_opts.options()); |
Giorgio Arena | 861c2ec | 2020-10-21 14:29:51 +0100 | [diff] [blame] | 211 | |
| 212 | ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info)); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 213 | } |
| 214 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 215 | Status CLFuseBatchNormalizationKernel::validate(const ITensorInfo *input_weights, |
| 216 | const ITensorInfo *bn_mean, |
| 217 | const ITensorInfo *bn_var, |
| 218 | const ITensorInfo *fused_weights, |
| 219 | const ITensorInfo *fused_bias, |
| 220 | const ITensorInfo *input_bias, |
| 221 | const ITensorInfo *bn_beta, |
| 222 | const ITensorInfo *bn_gamma, |
| 223 | float epsilon, |
| 224 | FuseBatchNormalizationType fbn_type) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 225 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 226 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input_weights, bn_mean, bn_var, fused_weights, fused_bias, |
| 227 | input_bias, bn_beta, bn_gamma, epsilon, fbn_type)); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 228 | return Status{}; |
| 229 | } |
| 230 | |
| 231 | void CLFuseBatchNormalizationKernel::run(const arm_compute::Window &window, cl::CommandQueue &queue) |
| 232 | { |
| 233 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 234 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window); |
| 235 | |
| 236 | // Create window slice |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 237 | Window collapsed_window = window.collapse(window, Window::DimZ); |
| 238 | Window slice_1d = window.first_slice_window_1D(); |
| 239 | Window slice_3d = collapsed_window.first_slice_window_3D(); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 240 | |
| 241 | // Add kernel arguments |
| 242 | unsigned int idx = 0; |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 243 | add_3D_tensor_argument(idx, _input_weights, slice_3d); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 244 | if (_input_bias != nullptr) |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 245 | { |
Manuel Bottini | 2732cca | 2019-05-28 11:44:41 +0100 | [diff] [blame] | 246 | add_1D_tensor_argument(idx, _input_bias, slice_1d); |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 247 | } |
| 248 | add_1D_tensor_argument(idx, _bn_mean, slice_1d); |
| 249 | add_1D_tensor_argument(idx, _bn_var, slice_1d); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 250 | if (!_run_in_place_weights) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 251 | { |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 252 | add_3D_tensor_argument(idx, _fused_weights, slice_3d); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 253 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 254 | if (!_run_in_place_bias) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 255 | { |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 256 | add_1D_tensor_argument(idx, _fused_bias, slice_1d); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 257 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 258 | if (_bn_beta != nullptr) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 259 | { |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 260 | add_1D_tensor_argument(idx, _bn_beta, slice_1d); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 261 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 262 | if (_bn_gamma != nullptr) |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 263 | { |
Gian Marco Iodice | 761c8d0 | 2019-06-10 14:46:49 +0100 | [diff] [blame] | 264 | add_1D_tensor_argument(idx, _bn_gamma, slice_1d); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 265 | } |
Georgios Pinitas | 275f99c | 2019-08-23 12:44:11 +0100 | [diff] [blame] | 266 | enqueue(queue, *this, slice_3d, lws_hint()); |
Georgios Pinitas | c936917 | 2018-09-26 11:25:40 +0100 | [diff] [blame] | 267 | } |
| 268 | } // namespace arm_compute |