Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +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/CLBatchNormalizationLayerKernel.h" |
| 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
| 27 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
Vidhya Sudhan Loganathan | f1f4906 | 2018-05-25 13:21:26 +0100 | [diff] [blame] | 28 | #include "arm_compute/core/CL/CLValidate.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/CL/ICLTensor.h" |
| 30 | #include "arm_compute/core/Helpers.h" |
| 31 | #include "arm_compute/core/TensorInfo.h" |
| 32 | #include "arm_compute/core/Utils.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | #include "arm_compute/core/Window.h" |
| 34 | |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 35 | #include "support/StringSupport.h" |
Michalis Spyrou | 172e570 | 2017-06-26 14:18:47 +0100 | [diff] [blame] | 36 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | using namespace arm_compute; |
| 38 | |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 39 | namespace |
| 40 | { |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 41 | Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, |
| 42 | const ITensorInfo *mean, const ITensorInfo *var, |
| 43 | const ITensorInfo *beta, const ITensorInfo *gamma, |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 44 | float epsilon, ActivationLayerInfo act_info) |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 45 | { |
| 46 | ARM_COMPUTE_UNUSED(epsilon); |
Vidhya Sudhan Loganathan | f1f4906 | 2018-05-25 13:21:26 +0100 | [diff] [blame] | 47 | ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input); |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 48 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32); |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 49 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(mean, var); |
| 50 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, mean, var); |
Michele Di Giorgio | bf3c662 | 2018-03-08 11:52:27 +0000 | [diff] [blame] | 51 | ARM_COMPUTE_RETURN_ERROR_ON(input->dimension(get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::CHANNEL)) != mean->dimension(0)); |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 52 | if(beta != nullptr) |
| 53 | { |
| 54 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(mean, beta); |
| 55 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, beta); |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 56 | } |
| 57 | if(gamma != nullptr) |
| 58 | { |
| 59 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(mean, gamma); |
| 60 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, gamma); |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 63 | if(act_info.enabled()) |
| 64 | { |
| 65 | ActivationLayerInfo::ActivationFunction act = act_info.activation(); |
| 66 | ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() != DataType::F32 && input->data_type() != DataType::F16); |
Georgios Pinitas | 6f109bd | 2018-07-16 12:57:42 +0100 | [diff] [blame] | 67 | ARM_COMPUTE_RETURN_ERROR_ON(act != ActivationLayerInfo::ActivationLayerInfo::ActivationFunction::RELU |
| 68 | && act != ActivationLayerInfo::ActivationLayerInfo::ActivationFunction::BOUNDED_RELU |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 69 | && act != ActivationLayerInfo::ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU); |
| 70 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.b() > act_info.a()); |
| 71 | } |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 72 | |
| 73 | if(output != nullptr && output->total_size() != 0) |
| 74 | { |
| 75 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, output); |
Michele Di Giorgio | bf3c662 | 2018-03-08 11:52:27 +0000 | [diff] [blame] | 76 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input, output); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 77 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 80 | return Status{}; |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Georgios Pinitas | 1b4cbc0 | 2018-05-11 14:19:13 +0100 | [diff] [blame] | 83 | std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, |
| 84 | ITensorInfo *mean, ITensorInfo *var, ITensorInfo *beta, ITensorInfo *gamma) |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 85 | { |
Giorgio Arena | f6a43c5 | 2017-12-01 12:16:25 +0000 | [diff] [blame] | 86 | if(output != nullptr) |
| 87 | { |
| 88 | // Output tensor auto initialization if not yet initialized |
| 89 | auto_init_if_empty(*output, *input->clone()); |
| 90 | } |
| 91 | |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 92 | const unsigned int num_elems_processed_per_iteration = 16 / input->element_size(); |
| 93 | |
| 94 | // Configure kernel window |
| 95 | Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration)); |
| 96 | AccessWindowHorizontal input_access(input, 0, num_elems_processed_per_iteration); |
| 97 | |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 98 | bool window_changed = false; |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 99 | if(output != nullptr) |
| 100 | { |
| 101 | AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); |
| 102 | window_changed = update_window_and_padding(win, input_access, output_access); |
| 103 | output_access.set_valid_region(win, input->valid_region()); |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | window_changed = update_window_and_padding(win, input_access); |
| 108 | } |
| 109 | |
Giorgio Arena | 4746326 | 2019-08-05 17:15:40 +0100 | [diff] [blame] | 110 | // Mean, var, gamma and beta get parallelized for the NHWC case as they follow the channel dimension, which is along the first axis |
Georgios Pinitas | 1b4cbc0 | 2018-05-11 14:19:13 +0100 | [diff] [blame] | 111 | if(input->data_layout() == DataLayout::NHWC) |
| 112 | { |
| 113 | AccessWindowHorizontal mean_access(mean, 0, num_elems_processed_per_iteration); |
| 114 | AccessWindowHorizontal var_access(var, 0, num_elems_processed_per_iteration); |
| 115 | window_changed = window_changed || update_window_and_padding(win, mean_access, var_access); |
| 116 | |
| 117 | if(beta != nullptr) |
| 118 | { |
| 119 | AccessWindowHorizontal beta_access(beta, 0, num_elems_processed_per_iteration); |
| 120 | window_changed = window_changed || update_window_and_padding(win, beta_access); |
| 121 | } |
| 122 | if(gamma != nullptr) |
| 123 | { |
| 124 | AccessWindowHorizontal gamma_access(gamma, 0, num_elems_processed_per_iteration); |
| 125 | window_changed = window_changed || update_window_and_padding(win, gamma_access); |
| 126 | } |
| 127 | } |
| 128 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 129 | Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 130 | return std::make_pair(err, win); |
| 131 | } |
| 132 | } // namespace |
| 133 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 134 | CLBatchNormalizationLayerKernel::CLBatchNormalizationLayerKernel() |
Michele Di Giorgio | dde9ec9 | 2018-02-13 15:24:04 +0000 | [diff] [blame] | 135 | : _input(nullptr), _output(nullptr), _mean(nullptr), _var(nullptr), _beta(nullptr), _gamma(nullptr), _epsilon(0), _run_in_place(false) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 136 | { |
| 137 | } |
| 138 | |
Georgios Pinitas | 409ee0a | 2017-08-18 10:16:09 +0100 | [diff] [blame] | 139 | void CLBatchNormalizationLayerKernel::configure(ICLTensor *input, ICLTensor *output, const ICLTensor *mean, const ICLTensor *var, const ICLTensor *beta, const ICLTensor *gamma, |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 140 | float epsilon, ActivationLayerInfo act_info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 141 | { |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 142 | configure(CLKernelLibrary::get().get_compile_context(), input, output, mean, var, beta, gamma, epsilon, act_info); |
| 143 | } |
| 144 | |
Manuel Bottini | 256c0b9 | 2020-04-21 13:29:30 +0100 | [diff] [blame] | 145 | void CLBatchNormalizationLayerKernel::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const ICLTensor *mean, const ICLTensor *var, const ICLTensor *beta, |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 146 | const ICLTensor *gamma, |
| 147 | float epsilon, ActivationLayerInfo act_info) |
| 148 | { |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 149 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, mean, var); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 150 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 151 | _input = input; |
| 152 | _output = output; |
| 153 | _mean = mean; |
| 154 | _var = var; |
| 155 | _beta = beta; |
| 156 | _gamma = gamma; |
| 157 | _epsilon = epsilon; |
| 158 | |
Michele Di Giorgio | dde9ec9 | 2018-02-13 15:24:04 +0000 | [diff] [blame] | 159 | _run_in_place = (output == nullptr) || (output == input); |
| 160 | |
Giorgio Arena | f6a43c5 | 2017-12-01 12:16:25 +0000 | [diff] [blame] | 161 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr, |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 162 | mean->info(), var->info(), (beta != nullptr) ? beta->info() : nullptr, |
| 163 | (gamma != nullptr) ? gamma->info() : nullptr, epsilon, act_info)); |
Georgios Pinitas | 409ee0a | 2017-08-18 10:16:09 +0100 | [diff] [blame] | 164 | |
Michalis Spyrou | 172e570 | 2017-06-26 14:18:47 +0100 | [diff] [blame] | 165 | const unsigned int num_elems_processed_per_iteration = 16 / input->info()->element_size(); |
| 166 | |
| 167 | // Set build options |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 168 | CLBuildOptions build_opts; |
| 169 | build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())); |
| 170 | build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration)); |
Usama Arif | 6a98a6e | 2019-05-10 17:07:27 +0100 | [diff] [blame] | 171 | build_opts.add_option("-DACTIVATION_TYPE=" + lower_string(string_from_activation_func(act_info.activation()))); |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 172 | build_opts.add_option_if(act_info.enabled(), "-DA_VAL=" + float_to_string_with_full_precision(act_info.a())); |
| 173 | build_opts.add_option_if(act_info.enabled(), "-DB_VAL=" + float_to_string_with_full_precision(act_info.b())); |
Michele Di Giorgio | dde9ec9 | 2018-02-13 15:24:04 +0000 | [diff] [blame] | 174 | build_opts.add_option_if(_run_in_place, "-DIN_PLACE"); |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 175 | build_opts.add_option_if(beta == nullptr, "-DUSE_DEFAULT_BETA"); |
| 176 | build_opts.add_option_if(gamma == nullptr, "-DUSE_DEFAULT_GAMMA"); |
Michalis Spyrou | 172e570 | 2017-06-26 14:18:47 +0100 | [diff] [blame] | 177 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 178 | // Create kernel |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 179 | _kernel = create_kernel(compile_context, "batchnormalization_layer_" + lower_string(string_from_data_layout(input->info()->data_layout())), build_opts.options()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 180 | |
| 181 | // Set kernel static arguments |
Michele Di Giorgio | dde9ec9 | 2018-02-13 15:24:04 +0000 | [diff] [blame] | 182 | unsigned int include_output = (!_run_in_place) ? 1 : 0; |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 183 | unsigned int idx = (1 + include_output) * num_arguments_per_3D_tensor() + 2 * num_arguments_per_1D_tensor(); // Skip the input and output parameters |
| 184 | if(_beta != nullptr) |
| 185 | { |
| 186 | idx += num_arguments_per_1D_tensor(); // Skip beta parameter |
| 187 | } |
| 188 | if(_gamma != nullptr) |
| 189 | { |
| 190 | idx += num_arguments_per_1D_tensor(); // Skip gamma parameter |
| 191 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 192 | _kernel.setArg<cl_float>(idx++, _epsilon); |
| 193 | |
| 194 | // Configure kernel window |
Georgios Pinitas | 1b4cbc0 | 2018-05-11 14:19:13 +0100 | [diff] [blame] | 195 | auto win_config = validate_and_configure_window(input->info(), (_run_in_place) ? nullptr : output->info(), |
| 196 | mean->info(), var->info(), |
| 197 | (beta != nullptr) ? beta->info() : nullptr, |
| 198 | (gamma != nullptr) ? gamma->info() : nullptr); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 199 | ARM_COMPUTE_ERROR_THROW_ON(win_config.first); |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 200 | ICLKernel::configure_internal(win_config.second); |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 201 | |
| 202 | _config_id = "batch_normalization_layer_"; |
| 203 | _config_id += string_from_data_type(input->info()->data_type()); |
| 204 | _config_id += "_"; |
| 205 | _config_id += support::cpp11::to_string(input->info()->dimension(0)); |
| 206 | _config_id += "_"; |
| 207 | _config_id += support::cpp11::to_string(input->info()->dimension(1)); |
| 208 | _config_id += "_"; |
| 209 | _config_id += support::cpp11::to_string(input->info()->dimension(2)); |
Giorgio Arena | 00b93f5 | 2018-06-28 17:18:50 +0100 | [diff] [blame] | 210 | _config_id += "_"; |
| 211 | _config_id += lower_string(string_from_data_layout(input->info()->data_layout())); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 212 | } |
| 213 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 214 | Status CLBatchNormalizationLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output, |
| 215 | const ITensorInfo *mean, const ITensorInfo *var, |
| 216 | const ITensorInfo *beta, const ITensorInfo *gamma, |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 217 | float epsilon, ActivationLayerInfo act_info) |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 218 | { |
Michele Di Giorgio | dde9ec9 | 2018-02-13 15:24:04 +0000 | [diff] [blame] | 219 | const bool run_in_place = (output == nullptr) || (output == input); |
Giorgio Arena | 1167487 | 2018-02-07 15:38:12 +0000 | [diff] [blame] | 220 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, mean, var, beta, gamma, epsilon, act_info)); |
Georgios Pinitas | 1b4cbc0 | 2018-05-11 14:19:13 +0100 | [diff] [blame] | 221 | ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), (run_in_place) ? nullptr : output->clone().get(), |
| 222 | mean->clone().get(), var->clone().get(), |
| 223 | (beta != nullptr) ? beta->clone().get() : nullptr, |
| 224 | (gamma != nullptr) ? gamma->clone().get() : nullptr) |
| 225 | .first); |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 226 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 227 | return Status{}; |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 230 | void CLBatchNormalizationLayerKernel::run(const Window &window, cl::CommandQueue &queue) |
| 231 | { |
| 232 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 233 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window); |
| 234 | |
| 235 | Window slice = window.first_slice_window_3D(); |
| 236 | |
| 237 | Window vector_slice = window.first_slice_window_1D(); |
| 238 | vector_slice.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 239 | |
Michele Di Giorgio | dde9ec9 | 2018-02-13 15:24:04 +0000 | [diff] [blame] | 240 | unsigned int include_output = (!_run_in_place) ? 1 : 0; |
Georgios Pinitas | 236bfe7 | 2017-11-23 15:59:55 +0000 | [diff] [blame] | 241 | unsigned int idx = (1 + include_output) * num_arguments_per_3D_tensor(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 242 | add_1D_tensor_argument(idx, _mean, vector_slice); |
| 243 | add_1D_tensor_argument(idx, _var, vector_slice); |
Michele Di Giorgio | 4d33630 | 2018-03-02 09:43:54 +0000 | [diff] [blame] | 244 | if(_beta != nullptr) |
| 245 | { |
| 246 | add_1D_tensor_argument(idx, _beta, vector_slice); |
| 247 | } |
| 248 | if(_gamma != nullptr) |
| 249 | { |
| 250 | add_1D_tensor_argument(idx, _gamma, vector_slice); |
| 251 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 252 | |
| 253 | do |
| 254 | { |
| 255 | idx = 0; |
| 256 | add_3D_tensor_argument(idx, _input, slice); |
Michele Di Giorgio | dde9ec9 | 2018-02-13 15:24:04 +0000 | [diff] [blame] | 257 | if(!_run_in_place) |
Georgios Pinitas | 409ee0a | 2017-08-18 10:16:09 +0100 | [diff] [blame] | 258 | { |
| 259 | add_3D_tensor_argument(idx, _output, slice); |
| 260 | } |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 261 | enqueue(queue, *this, slice, lws_hint()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 262 | } |
| 263 | while(window.slide_window_slice_3D(slice)); |
| 264 | } |