Compute Library
 21.08
ClSoftmaxKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 Arm Limited.
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  */
26 #include "arm_compute/core/Utils.h"
29 #include "src/core/CL/CLValidate.h"
32 #include "support/Cast.h"
33 #include "support/StringSupport.h"
34 
35 namespace arm_compute
36 {
37 namespace opencl
38 {
39 namespace kernels
40 {
41 namespace
42 {
43 /** Calculates softmax parameters from the quantized input scale and scaling factor for the exponent and places them as build options.
44  *
45  * Prepares these build options:
46  * -INPUT_BETA_MULTIPLIER, INPUT_BETA_LEFT_SHIFT - quantized representation of beta multiplier.
47  * -DIFF_MIN - threshold difference between maximum value of input data and current processed value,
48  * it defines whether the value will be taken into account or not.
49  *
50  * @param[in] build_opts Build options to extend
51  * @param[in] input_scale Input scaling factor
52  * @param[in] beta Exponent scaling factor beta
53  */
54 CLBuildOptions prepare_quantized_softmax_build_options(float input_scale, float beta)
55 {
56  // Number of integer bits in temporary fixed-point representation of current-to-max difference
57  static const int scaled_diff_int_bits = 5;
58  // Number of integer bits used in temporary fixed-point representation of exponent accumulator
59  static const int exp_accumulation_in_bits = 12;
60 
61  const double beta_multiplier = std::min(
62  1.0 * beta * input_scale * (1 << (31 - scaled_diff_int_bits)),
63  (1LL << 31) - 1.0);
64  int input_beta_multiplier;
65  int input_beta_left_shift;
66  quantization::calculate_quantized_multiplier_greater_than_one(beta_multiplier, &input_beta_multiplier, &input_beta_left_shift);
67 
68  const double max_input_rescaled = 1.0 * ((1 << scaled_diff_int_bits) - 1) * (1LL << (31 - scaled_diff_int_bits)) / (1LL << input_beta_left_shift);
69  const int diff_min = -1.f * std::floor(max_input_rescaled);
70 
71  CLBuildOptions build_opts;
72  build_opts.add_option("-DSCALED_DIFF_INT_BITS=" + support::cpp11::to_string(scaled_diff_int_bits));
73  build_opts.add_option("-DEXP_ACCUMULATION_INT_BITS=" + support::cpp11::to_string(exp_accumulation_in_bits));
74  build_opts.add_option("-DINPUT_BETA_MULTIPLIER=" + support::cpp11::to_string(input_beta_multiplier));
75  build_opts.add_option("-DINPUT_BETA_LEFT_SHIFT=" + support::cpp11::to_string(input_beta_left_shift));
76  build_opts.add_option("-DDIFF_MIN=" + support::cpp11::to_string(diff_min));
77 
78  return build_opts;
79 }
80 
81 Status validate_arguments_1DMaxShiftExpSum(const ITensorInfo &src, const ITensorInfo &max, const ITensorInfo &dst, const ITensorInfo &sum)
82 {
86 
87  const bool is_quantized_asymmetric = is_data_type_quantized_asymmetric(src.data_type());
88 
89  // Checks performed when output is configured
90  if(dst.total_size() != 0)
91  {
92  if(is_quantized_asymmetric)
93  {
95  }
96  else
97  {
99  }
101  }
102 
103  // Checks performed when sum is configured
104  if(sum.total_size() != 0)
105  {
106  if(is_quantized_asymmetric)
107  {
109  }
110  else
111  {
113  }
115  }
116 
117  return Status{};
118 }
119 
120 Status validate_arguments_1DNorm(const ITensorInfo &src, const ITensorInfo &sum, const ITensorInfo &dst, const SoftmaxKernelInfo &info)
121 {
125  ARM_COMPUTE_RETURN_ERROR_ON(info.is_log && !is_data_type_float(info.input_data_type));
126 
127  // Note: output should always have a scale of 1/256 and offset 0
128  const QuantizationInfo allowed_quantization_info = get_softmax_output_quantization_info(info.input_data_type, info.is_log);
129  const bool is_quantized_asymmetric = is_data_type_quantized_asymmetric(info.input_data_type);
130 
131  // Checks performed when output is configured
132  if(dst.total_size() != 0)
133  {
135  if(!is_quantized_asymmetric)
136  {
138  }
139  else
140  {
142  ARM_COMPUTE_RETURN_ERROR_ON(dst.quantization_info() != allowed_quantization_info);
143  }
144  }
145 
146  return Status{};
147 }
148 } // namespace
149 
150 /**< Grid size (obtained through auto-tuning) */
151 const unsigned int ClLogits1DMaxShiftExpSumKernel::_grid_size = 64;
152 /**< Vector size in the serial case (obtained through auto-tuning) */
153 const unsigned int ClLogits1DMaxShiftExpSumKernel::_serial_vector_size = 8;
154 /**< Vector size in the parallel case (obtained through auto-tuning, enables the best memory access pattern for Bifrost) .*/
155 const unsigned int ClLogits1DMaxShiftExpSumKernel::_parallel_vector_size = 4;
156 
158 {
160 }
161 
163 {
164  auto padding_info = get_padding_info({ &src, &max, &dst, &sum });
165 
166  // Output auto initialization if not yet initialized
167  auto_init_if_empty(sum, src.clone()->set_tensor_shape(max.tensor_shape()));
168  auto_init_if_empty(dst, *src.clone());
169 
170  // Perform validation step
171  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_1DMaxShiftExpSum(src, max, dst, sum));
172 
173  const DataType dt = src.data_type();
175  const size_t reduction_dim_size = src.dimension(0);
176  const float beta = info.beta;
177  const auto is_signed_qasymm8 = is_data_type_quantized_asymmetric_signed(info.input_data_type);
178  const int min_value = is_signed_qasymm8 ? CL_SCHAR_MIN : 0;
179 
180  ParallelReductionInfo parallel_reduction_info = is_parallel_reduction(reduction_dim_size);
181  const unsigned int vector_size = adjust_vec_size(std::get<1>(parallel_reduction_info), reduction_dim_size);
182 
183  // Set build options
184  CLBuildOptions build_opts;
185  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(dt));
186  build_opts.add_option("-DMIN_VALUE=" + support::cpp11::to_string(min_value));
187  build_opts.add_option("-DVECTOR_SIZE=" + support::cpp11::to_string(vector_size));
188  build_opts.add_option("-DSRC_WIDTH=" + support::cpp11::to_string(reduction_dim_size));
189  build_opts.add_option("-DVECTOR_SIZE_LEFTOVER=" + support::cpp11::to_string(reduction_dim_size % vector_size));
190  build_opts.add_option("-DLOG_VECTOR_SIZE=" + support::cpp11::to_string(lround(log2(vector_size))));
191  build_opts.add_option_if((reduction_dim_size % vector_size) != 0, "-DNON_MULTIPLE_OF_VECTOR_SIZE");
192  build_opts.add_option_if(is_signed_qasymm8, "-DQASYMM8_SIGNED");
193  build_opts.add_option_if(is_data_type_float(dt) && (beta != 1.0f), "-DBETA=" + float_to_string_with_full_precision(beta));
194  build_opts.add_option_if(is_data_type_float(dt) && info.is_log, "-DLOG_SOFTMAX");
195  build_opts.add_option_if(is_data_type_float(dt), "-DMINVAL=" + ((dt == DataType::F16) ? std::string("-HALF_MAX") : std::string("-FLT_MAX")));
196  build_opts.add_options_if(is_data_type_quantized_asymmetric(dt), prepare_quantized_softmax_build_options(qinfo.scale, beta).options());
197 
198  cl::NDRange lws_hint(cl::NullRange);
199  std::string kernel_name = std::string("softmax_layer_max_shift_exp_sum_") + (is_data_type_quantized_asymmetric(dt) ? "quantized_" : "");
200 
201  // Configure parallel kernel if needed
202  if(std::get<0>(parallel_reduction_info))
203  {
204  kernel_name += "parallel";
205  bool is_grid_size_pow2 = (_grid_size != 0) && ((_grid_size & (_grid_size - 1)) == 0);
206  build_opts.add_option_if(is_grid_size_pow2 && _grid_size <= 256, "-DGRID_SIZE=" + support::cpp11::to_string(_grid_size));
207 
208  // Handle boundary conditions.
209  const unsigned int multiple_grid_size = (reduction_dim_size / vector_size) % _grid_size;
210  build_opts.add_option_if((multiple_grid_size != 0) || ((reduction_dim_size % vector_size) != 0), "-DNON_MULTIPLE_OF_GRID_SIZE");
211  // Setting _lws_hint in this way can also communicate grid_size to ClLogits1DMaxShiftExpSumKernel::run().
212  // A single workgroup performs reduction in dimension 0 in the parallel case, hence lws[0]==gws[0].
213  lws_hint = cl::NDRange(_grid_size);
214  }
215  else
216  {
217  kernel_name += "serial";
218  }
219 
220  // Create kernel.
221  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
222 
223  // Configure window
224  Window win = calculate_max_window(src, Steps(reduction_dim_size));
225  IClKernel::configure_internal(win, lws_hint);
226 
228 }
229 
231 {
232  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_1DMaxShiftExpSum(src, max, dst, sum));
233  return Status{};
234 }
235 
237 {
238  bool is_parallel_reduction = (size >= (_grid_size * _serial_vector_size)) && (_grid_size > 1);
239  unsigned int vector_size = is_parallel_reduction ? _parallel_vector_size : _serial_vector_size;
240  return std::make_tuple(is_parallel_reduction, vector_size);
241 }
242 
243 void ClLogits1DMaxShiftExpSumKernel::run_op(ITensorPack &tensors, const Window &window, ::cl::CommandQueue &queue)
244 {
247 
248  auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
249  auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
250  auto max = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_INT_0));
251  auto sum = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_INT_1));
252 
253  ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst, max, sum);
254 
255  // Collapse window in Z dimension
256  Window window_collapsed = window.collapse_if_possible(IClKernel::window(), Window::DimZ);
257 
258  // Reconfigure window in case of parallel reduction
259  ParallelReductionInfo parallel_reduction_info = is_parallel_reduction(src->info()->dimension(0));
260  if(std::get<0>(parallel_reduction_info))
261  {
262  // Launch grid_size parallel work items
263  window_collapsed.set(Window::DimX, Window::Dimension(0, _grid_size, 1));
264  }
265 
266  // Get slices
267  Window slice = window_collapsed.first_slice_window_3D();
268  do
269  {
270  unsigned int idx = 0;
271  // Set inputs
272  add_3D_tensor_argument(idx, src, slice);
273  add_3D_tensor_argument(idx, max, slice);
274  add_3D_tensor_argument(idx, dst, slice);
275  add_3D_tensor_argument(idx, sum, slice);
276  enqueue(queue, *this, slice, lws_hint());
277  }
278  while(window_collapsed.slide_window_slice_3D(slice));
279 }
280 
282 {
284 }
285 
286 void ClLogits1DNormKernel::configure(const CLCompileContext &compile_context, const ITensorInfo &src, const ITensorInfo &sum, ITensorInfo &dst, const SoftmaxKernelInfo &info)
287 {
288  auto padding_info = get_padding_info({ &src, &dst, &sum });
289 
290  // Note: output should always have a scale of 1/256 and offset 0
291  const bool is_quantized_asymmetric = is_data_type_quantized_asymmetric(info.input_data_type);
292  const DataType output_data_type = info.input_data_type;
293  const QuantizationInfo allowed_quantization_info = get_softmax_output_quantization_info(info.input_data_type, info.is_log);
295 
296  // Output auto initialization if not yet initialized
297  auto_init_if_empty(dst, src.clone()->set_data_type(output_data_type).set_quantization_info(allowed_quantization_info));
298 
299  // Perform validation step
300  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_1DNorm(src, sum, dst, info));
301 
302  const auto is_signed_qasymm8 = is_data_type_quantized_asymmetric_signed(info.input_data_type);
303  const int min_value = is_signed_qasymm8 ? CL_SCHAR_MIN : 0;
304  const unsigned int vector_size = adjust_vec_size(16, src.dimension(0));
305 
306  // Set build options
307  CLBuildOptions build_opts;
308  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(info.input_data_type));
309  build_opts.add_option("-DMIN_VALUE=" + support::cpp11::to_string(min_value));
310  build_opts.add_option("-DVECTOR_SIZE=" + support::cpp11::to_string(vector_size));
311  build_opts.add_option("-DVECTOR_SIZE_LEFTOVER=" + support::cpp11::to_string(src.dimension(0) % vector_size));
312  build_opts.add_option_if(is_data_type_quantized_asymmetric_signed(info.input_data_type), "-DQASYMM8_SIGNED");
313  build_opts.add_options_if(is_quantized_asymmetric,
314  prepare_quantized_softmax_build_options(qinfo.scale, info.beta).options());
315  build_opts.add_option_if(info.is_log, "-DLOG_SOFTMAX");
316 
317  // Create kernel
318  std::string kernel_name = std::string("softmax_layer_norm") + (is_quantized_asymmetric ? "_quantized" : "");
319  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
320 
321  // Configure window
322  auto win = calculate_max_window(src, Steps(vector_size));
323  ICLKernel::configure_internal(win);
324 
326 }
327 
329 {
330  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_1DNorm(src, sum, dst, info));
331 
332  return Status{};
333 }
334 
335 void ClLogits1DNormKernel::run_op(ITensorPack &tensors, const Window &window, ::cl::CommandQueue &queue)
336 {
339 
340  auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
341  auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
342  auto sum = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_INT_0));
343 
344  ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst, sum);
345 
346  Window window_collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ);
347  Window slice = window_collapsed.first_slice_window_3D();
348 
349  do
350  {
351  Window sum_slice = slice;
352  sum_slice.set(Window::DimX, Window::Dimension(0, 1, 1));
353 
354  unsigned int idx = 0;
355  // Set inputs
356  add_3D_tensor_argument(idx, src, slice);
357  add_3D_tensor_argument(idx, sum, sum_slice);
358  add_3D_tensor_argument(idx, dst, slice);
359  enqueue(queue, *this, slice, lws_hint());
360  }
361  while(window_collapsed.slide_window_slice_3D(slice));
362 }
363 } // namespace kernels
364 } // namespace opencl
365 } // namespace arm_compute
void configure(const CLCompileContext &compile_context, const ITensorInfo &src, ITensorInfo &max, ITensorInfo &dst, ITensorInfo &sum, const SoftmaxKernelInfo &info)
Configure the kernel using the given information about tensors.
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
Definition: CLValidate.h:35
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void run_op(ITensorPack &tensors, const Window &window, ::cl::CommandQueue &queue) override
static Status validate(const ITensorInfo &src, const ITensorInfo &sum, const ITensorInfo &dst, const SoftmaxKernelInfo &info)
Static function to check if given info will lead to a valid configuration.
void run_op(ITensorPack &tensors, const Window &window, ::cl::CommandQueue &queue) override
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
Definition: ICLKernel.cpp:32
const StringSet & options() const
Gets the current options list set.
float beta
A scaling factor for the exponent with default value 1.0.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:318
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
std::string to_string(T &&value)
Convert integer and float values to string.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
static ParallelReductionInfo is_parallel_reduction(size_t size)
Checks if the given size is eligible for parallel reduction.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
QuantizationInfo get_softmax_output_quantization_info(DataType input_type, bool is_log)
Returns output quantization information for softmax layer.
Definition: Utils.cpp:467
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Quantization info when assuming per layer quantization.
Describe one of the image&#39;s dimensions with a start, end and step.
Definition: Window.h:77
Status class.
Definition: Error.h:52
Status calculate_quantized_multiplier_greater_than_one(float multiplier, int32_t *quantized_multiplier, int32_t *left_shift)
Calculate quantized representation of multiplier having value greater than one.
std::tuple< bool, unsigned int > ParallelReductionInfo
Info for whether a parallel reduction will be run and the vector size of the execution.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:214
SimpleTensor< float > src
Definition: DFT.cpp:155
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
static Status validate(const ITensorInfo &src, const ITensorInfo &max, const ITensorInfo &dst, const ITensorInfo &sum)
Static function to check if given info will lead to a valid configuration.
DataType dt
1 channel, 1 S32 per channel
void add_option(std::string option)
Adds option to the existing build option list.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
Definition: ITensorPack.cpp:54
Quantization information.
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
Definition: CLHelpers.cpp:391
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Definition: Window.inl:68
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1075
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
quantized, asymmetric fixed-point 8-bit number unsigned
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
DataType input_data_type
Input tensor data type.
UniformQuantizationInfo uniform() const
Return per layer quantization info.
bool is_log
Flag used to perform Log Softmax operation.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
Definition: CLHelpers.cpp:39
bool is_data_type_quantized_asymmetric_signed(DataType dt)
Check if a given data type is of asymmetric quantized signed type.
Definition: Utils.h:1022
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
Elementeise CL kernel type.
Definition: CLTypes.h:84
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:335
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
bool has_padding_changed(const std::unordered_map< const ITensorInfo *, PaddingSize > &padding_map)
Check if the previously stored padding info has changed after configuring a kernel.
Definition: Utils.cpp:533
CLCompileContext class.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1003
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Definition: ITensorPack.cpp:64
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:439
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
const QuantizationInfo qinfo
Definition: Im2Col.cpp:155
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:541
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:788
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo *> infos)
Stores padding information before configuring a kernel.
Definition: Utils.cpp:518
Tensor packing service.
Definition: ITensorPack.h:39
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
long lround(T value)
Round floating-point value with half value rounding away from zero and cast to long.
unsigned int adjust_vec_size(unsigned int vec_size, size_t dim0)
Returns the adjusted vector size in case it is less than the input&#39;s first dimension, getting rounded down to its closest valid vector size.
Definition: Utils.h:1171
void configure(const CLCompileContext &compile_context, const ITensorInfo &src, const ITensorInfo &sum, ITensorInfo &dst, const SoftmaxKernelInfo &info)
Set the input and output tensors.
quantized, asymmetric fixed-point 8-bit number signed
Descriptor used by the softmax kernels.
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:291
std::string kernel_name
DataType
Available data types.
Definition: Types.h:77
Describe a multidimensional execution window.
Definition: Window.h:39
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
Definition: Utils.h:961
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
void add_options_if(bool cond, const StringSet &options)
Appends given build options to the current&#39;s objects options if a given condition is true...