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