Compute Library
 19.11
Utils.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019 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  */
24 
26 
27 #include "arm_compute/core/Utils.h"
29 
30 #include <algorithm>
31 #include <cmath>
32 #include <cstdint>
33 #include <fstream>
34 #include <map>
35 #include <string>
36 
37 using namespace arm_compute;
38 #ifndef DOXYGEN_SKIP_THIS
40 {
41  static const std::string information =
42 #include "arm_compute_version.embed"
43  ;
44  return information;
45 }
46 #endif /* DOXYGEN_SKIP_THIS */
47 std::string arm_compute::read_file(const std::string &filename, bool binary)
48 {
49  std::string out;
50  std::ifstream fs;
51 
52 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
53  try
54  {
55 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
56  fs.exceptions(std::ifstream::failbit | std::ifstream::badbit);
57  std::ios_base::openmode mode = std::ios::in;
58 
59  if(binary)
60  {
61  mode |= std::ios::binary;
62  }
63 
64  fs.open(filename, mode);
65 
66  // Go to the end of the file
67  fs.seekg(0, std::ios::end);
68  // Reserve the memory required to store the file's content
69  out.reserve(fs.tellg());
70  // Go back to the beginning of the file
71  fs.seekg(0, std::ios::beg);
72  // Copy the content of the file
73  out.assign(std::istreambuf_iterator<char>(fs), std::istreambuf_iterator<char>());
74 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
75  }
76  catch(const std::ifstream::failure &e)
77  {
78  ARM_COMPUTE_ERROR_VAR("Accessing %s: %s", filename.c_str(), e.what());
79  }
80 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
81 
82  return out;
83 }
84 
85 const std::string &arm_compute::string_from_format(Format format)
86 {
87  static std::map<Format, const std::string> formats_map =
88  {
89  { Format::UNKNOWN, "UNKNOWN" },
90  { Format::U8, "U8" },
91  { Format::S16, "S16" },
92  { Format::U16, "U16" },
93  { Format::S32, "S32" },
94  { Format::U32, "U32" },
95  { Format::F16, "F16" },
96  { Format::F32, "F32" },
97  { Format::UV88, "UV88" },
98  { Format::RGB888, "RGB888" },
99  { Format::RGBA8888, "RGBA8888" },
100  { Format::YUV444, "YUV444" },
101  { Format::YUYV422, "YUYV422" },
102  { Format::NV12, "NV12" },
103  { Format::NV21, "NV21" },
104  { Format::IYUV, "IYUV" },
105  { Format::UYVY422, "UYVY422" }
106  };
107 
108  return formats_map[format];
109 }
110 
111 const std::string &arm_compute::string_from_channel(Channel channel)
112 {
113  static std::map<Channel, const std::string> channels_map =
114  {
115  { Channel::UNKNOWN, "UNKNOWN" },
116  { Channel::R, "R" },
117  { Channel::G, "G" },
118  { Channel::B, "B" },
119  { Channel::A, "A" },
120  { Channel::Y, "Y" },
121  { Channel::U, "U" },
122  { Channel::V, "V" },
123  { Channel::C0, "C0" },
124  { Channel::C1, "C1" },
125  { Channel::C2, "C2" },
126  { Channel::C3, "C3" }
127  };
128 
129  return channels_map[channel];
130 }
131 
133 {
134  static std::map<DataLayout, const std::string> dl_map =
135  {
136  { DataLayout::UNKNOWN, "UNKNOWN" },
137  { DataLayout::NCHW, "NCHW" },
138  { DataLayout::NHWC, "NHWC" },
139  };
140 
141  return dl_map[dl];
142 }
143 
145 {
146  static std::map<DataType, const std::string> dt_map =
147  {
148  { DataType::UNKNOWN, "UNKNOWN" },
149  { DataType::S8, "S8" },
150  { DataType::U8, "U8" },
151  { DataType::S16, "S16" },
152  { DataType::U16, "U16" },
153  { DataType::S32, "S32" },
154  { DataType::U32, "U32" },
155  { DataType::S64, "S64" },
156  { DataType::U64, "U64" },
157  { DataType::F16, "F16" },
158  { DataType::F32, "F32" },
159  { DataType::F64, "F64" },
160  { DataType::SIZET, "SIZET" },
161  { DataType::QSYMM8, "QSYMM8" },
162  { DataType::QSYMM8_PER_CHANNEL, "QSYMM8_PER_CHANNEL" },
163  { DataType::QASYMM8, "QASYMM8" },
164  { DataType::QASYMM8_SIGNED, "QASYMM8_SIGNED" },
165  { DataType::QSYMM16, "QSYMM16" },
166  { DataType::QASYMM16, "QASYMM16" },
167  };
168 
169  return dt_map[dt];
170 }
171 
173 {
174  static std::map<ActivationLayerInfo::ActivationFunction, const std::string> act_map =
175  {
189  };
190 
191  return act_map[act];
192 }
193 
195 {
196  static std::map<MatrixPattern, const std::string> pattern_map =
197  {
198  { MatrixPattern::BOX, "BOX" },
199  { MatrixPattern::CROSS, "CROSS" },
200  { MatrixPattern::DISK, "DISK" },
201  { MatrixPattern::OTHER, "OTHER" },
202  };
203 
204  return pattern_map[pattern];
205 }
206 
208 {
209  static std::map<NonLinearFilterFunction, const std::string> func_map =
210  {
211  { NonLinearFilterFunction::MAX, "MAX" },
212  { NonLinearFilterFunction::MEDIAN, "MEDIAN" },
213  { NonLinearFilterFunction::MIN, "MIN" },
214  };
215 
216  return func_map[function];
217 }
218 
220 {
221  static std::map<InterpolationPolicy, const std::string> interpolation_policy_map =
222  {
223  { InterpolationPolicy::AREA, "AREA" },
224  { InterpolationPolicy::BILINEAR, "BILINEAR" },
225  { InterpolationPolicy::NEAREST_NEIGHBOR, "NEAREST_NEIGHBOUR" },
226  };
227 
228  return interpolation_policy_map[policy];
229 }
230 
232 {
233  static std::map<BorderMode, const std::string> border_mode_map =
234  {
235  { BorderMode::UNDEFINED, "UNDEFINED" },
236  { BorderMode::CONSTANT, "CONSTANT" },
237  { BorderMode::REPLICATE, "REPLICATE" },
238  };
239 
240  return border_mode_map[border_mode];
241 }
242 
244 {
245  static std::map<NormType, const std::string> norm_type_map =
246  {
247  { NormType::IN_MAP_1D, "IN_MAP_1D" },
248  { NormType::IN_MAP_2D, "IN_MAP_2D" },
249  { NormType::CROSS_MAP, "CROSS_MAP" },
250  };
251 
252  return norm_type_map[type];
253 }
254 
256 {
257  static std::map<PoolingType, const std::string> pool_type_map =
258  {
259  { PoolingType::MAX, "MAX" },
260  { PoolingType::AVG, "AVG" },
261  { PoolingType::L2, "L2" },
262  };
263 
264  return pool_type_map[type];
265 }
266 
268 {
269  static std::map<GEMMLowpOutputStageType, const std::string> output_stage_map =
270  {
272  { GEMMLowpOutputStageType::QUANTIZE_DOWN, "quantize_down" },
273  { GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT, "quantize_down_fixedpoint" },
274  { GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT, "quantize_down_float" }
275  };
276 
277  return output_stage_map[output_stage];
278 }
279 
281 {
282  std::stringstream ss;
283  std::string converted_string;
284 
285  switch(data_type)
286  {
287  case DataType::U8:
288  case DataType::QASYMM8:
289  // Needs conversion to 32 bit, otherwise interpreted as ASCII values
290  ss << uint32_t(value.get<uint8_t>());
291  converted_string = ss.str();
292  break;
293  case DataType::S8:
296  // Needs conversion to 32 bit, otherwise interpreted as ASCII values
297  ss << int32_t(value.get<int8_t>());
298  converted_string = ss.str();
299  break;
300  case DataType::U16:
301  case DataType::QASYMM16:
302  ss << value.get<uint16_t>();
303  converted_string = ss.str();
304  break;
305  case DataType::S16:
306  case DataType::QSYMM16:
307  ss << value.get<int16_t>();
308  converted_string = ss.str();
309  break;
310  case DataType::U32:
311  ss << value.get<uint32_t>();
312  converted_string = ss.str();
313  break;
314  case DataType::S32:
315  ss << value.get<int32_t>();
316  converted_string = ss.str();
317  break;
318  case DataType::F32:
319  converted_string = float_to_string_with_full_precision(value.get<float>());
320  break;
321  case DataType::F16:
322  static_assert(sizeof(half) == 2, "Half must be 16 bit");
323  ss << value.get<half>();
324  converted_string = ss.str();
325  break;
326  default:
327  ARM_COMPUTE_ERROR("Not handled");
328  }
329 
330  return converted_string;
331 }
332 
333 std::string arm_compute::lower_string(const std::string &val)
334 {
335  std::string res = val;
336  std::transform(res.begin(), res.end(), res.begin(), ::tolower);
337  return res;
338 }
339 
341  const DimensionRoundingType &rounding_type)
342 {
343  const auto &strides = conv_info.stride();
344  ARM_COMPUTE_ERROR_ON_MSG((strides.first < 1 || strides.second < 1), "Stride values should be greater than or equal to 1.");
345 
348  const unsigned int in_width = input_shape[width_idx];
349  const unsigned int in_height = input_shape[height_idx];
350  const unsigned int kernel_width = weights_shape[width_idx];
351  const unsigned int kernel_height = weights_shape[height_idx];
352 
353  // Calculate output dimensions
354  const auto is_ceil = static_cast<unsigned int>(rounding_type == DimensionRoundingType::CEIL);
355  const unsigned int out_width = ((in_width - is_ceil) + strides.first - 1) / strides.first + is_ceil;
356  const unsigned int out_height = ((in_height - is_ceil) + strides.second - 1) / strides.second + is_ceil;
357 
358  // Calculate effective weights sizes
359  const int real_weight_width = (kernel_width - 1) * dilation.x() + 1;
360  const int real_weight_height = (kernel_height - 1) * dilation.y() + 1;
361 
362  // Calculate total pad
363  const int pad_width = std::max(0, static_cast<int>((out_width - 1) * strides.first + real_weight_width - in_width));
364  const int pad_height = std::max(0, static_cast<int>((out_height - 1) * strides.second + real_weight_height - in_height));
365 
366  // Calculate individual paddings
367  const unsigned int pad_left = pad_width / 2;
368  const unsigned int pad_top = pad_height / 2;
369  const unsigned int pad_right = pad_width - pad_left;
370  const unsigned int pad_bottom = pad_height - pad_top;
371 
372  PadStrideInfo same_info(strides.first, strides.second, pad_left, pad_right, pad_top, pad_bottom, rounding_type);
373 
374  // Check for correctness of predicted output shape against the one calculated using the generated info
375  const auto out_dims = scaled_dimensions(in_width, in_height, kernel_width, kernel_height, same_info, dilation);
376  ARM_COMPUTE_ERROR_ON(out_dims.first != out_width || out_dims.second != out_height);
377  ARM_COMPUTE_UNUSED(out_dims);
378 
379  return same_info;
380 }
381 
382 std::pair<unsigned int, unsigned int> arm_compute::deconvolution_output_dimensions(unsigned int in_width, unsigned int in_height,
383  unsigned int kernel_width, unsigned int kernel_height,
384  const PadStrideInfo &pad_stride_info)
385 {
386  const unsigned int pad_left = pad_stride_info.pad_left();
387  const unsigned int pad_top = pad_stride_info.pad_top();
388  const unsigned int pad_right = pad_stride_info.pad_right();
389  const unsigned int pad_bottom = pad_stride_info.pad_bottom();
390  const unsigned int stride_x = pad_stride_info.stride().first;
391  const unsigned int stride_y = pad_stride_info.stride().second;
392 
393  ARM_COMPUTE_ERROR_ON(in_width < 1 || in_height < 1);
394  ARM_COMPUTE_ERROR_ON(((in_width - 1) * stride_x + kernel_width) < (pad_left + pad_right));
395  ARM_COMPUTE_ERROR_ON(((in_height - 1) * stride_y + kernel_height) < (pad_top + pad_bottom));
396  const int w = stride_x * (in_width - 1) + kernel_width - (pad_left + pad_right);
397  const int h = stride_y * (in_height - 1) + kernel_height - (pad_top + pad_bottom);
398 
399  return std::make_pair<unsigned int, unsigned int>(w, h);
400 }
401 
402 std::pair<unsigned int, unsigned int> arm_compute::scaled_dimensions(unsigned int width, unsigned int height,
403  unsigned int kernel_width, unsigned int kernel_height,
404  const PadStrideInfo &pad_stride_info,
405  const Size2D &dilation)
406 {
407  const unsigned int pad_left = pad_stride_info.pad_left();
408  const unsigned int pad_top = pad_stride_info.pad_top();
409  const unsigned int pad_right = pad_stride_info.pad_right();
410  const unsigned int pad_bottom = pad_stride_info.pad_bottom();
411  const unsigned int stride_x = pad_stride_info.stride().first;
412  const unsigned int stride_y = pad_stride_info.stride().second;
413  unsigned int w = 0;
414  unsigned int h = 0;
415  switch(pad_stride_info.round())
416  {
418  w = static_cast<unsigned int>(std::floor((static_cast<float>(width + pad_left + pad_right - (dilation.x() * (kernel_width - 1) + 1)) / stride_x) + 1));
419  h = static_cast<unsigned int>(std::floor((static_cast<float>(height + pad_top + pad_bottom - (dilation.y() * (kernel_height - 1) + 1)) / stride_y) + 1));
420  break;
422  w = static_cast<unsigned int>(std::ceil((static_cast<float>(width + pad_left + pad_right - (dilation.x() * (kernel_width - 1) + 1)) / stride_x) + 1));
423  h = static_cast<unsigned int>(std::ceil((static_cast<float>(height + pad_top + pad_bottom - (dilation.y() * (kernel_height - 1) + 1)) / stride_y) + 1));
424  break;
425  default:
426  ARM_COMPUTE_ERROR("Unsupported rounding type");
427  }
428 
429  return std::make_pair(w, h);
430 }
431 
433 {
434  const bool is_arg_min_max = (op == ReductionOperation::ARG_IDX_MAX || op == ReductionOperation::ARG_IDX_MIN);
435  const bool is_min_max = (op == ReductionOperation::MAX || op == ReductionOperation::MIN);
436  const bool is_quantized_type = is_data_type_quantized(dt);
437  const bool is_first_dim = (axis == 0);
438 
439  return !is_first_dim || is_arg_min_max || is_min_max || is_quantized_type;
440 }
441 
442 #ifdef ARM_COMPUTE_ASSERTS_ENABLED
443 void arm_compute::print_consecutive_elements(std::ostream &s, DataType dt, const uint8_t *ptr, unsigned int n, int stream_width, const std::string &element_delim)
444 {
445  switch(dt)
446  {
447  case DataType::U8:
448  case DataType::QASYMM8:
449  print_consecutive_elements_impl<uint8_t>(s, ptr, n, stream_width, element_delim);
450  break;
451  case DataType::S8:
454  print_consecutive_elements_impl<int8_t>(s, reinterpret_cast<const int8_t *>(ptr), n, stream_width, element_delim);
455  break;
456  case DataType::U16:
457  case DataType::QASYMM16:
458  print_consecutive_elements_impl<uint16_t>(s, reinterpret_cast<const uint16_t *>(ptr), n, stream_width, element_delim);
459  break;
460  case DataType::S16:
461  case DataType::QSYMM16:
462  print_consecutive_elements_impl<int16_t>(s, reinterpret_cast<const int16_t *>(ptr), n, stream_width, element_delim);
463  break;
464  case DataType::U32:
465  print_consecutive_elements_impl<uint32_t>(s, reinterpret_cast<const uint32_t *>(ptr), n, stream_width, element_delim);
466  break;
467  case DataType::S32:
468  print_consecutive_elements_impl<int32_t>(s, reinterpret_cast<const int32_t *>(ptr), n, stream_width, element_delim);
469  break;
470  case DataType::F32:
471  print_consecutive_elements_impl<float>(s, reinterpret_cast<const float *>(ptr), n, stream_width, element_delim);
472  break;
473  case DataType::F16:
474  print_consecutive_elements_impl<half>(s, reinterpret_cast<const half *>(ptr), n, stream_width, element_delim);
475  break;
476  default:
477  ARM_COMPUTE_ERROR("Undefined element size for given data type");
478  }
479 }
480 
481 int arm_compute::max_consecutive_elements_display_width(std::ostream &s, DataType dt, const uint8_t *ptr, unsigned int n)
482 {
483  switch(dt)
484  {
485  case DataType::U8:
486  case DataType::QASYMM8:
487  return max_consecutive_elements_display_width_impl<uint8_t>(s, ptr, n);
488  case DataType::S8:
491  return max_consecutive_elements_display_width_impl<int8_t>(s, reinterpret_cast<const int8_t *>(ptr), n);
492  case DataType::U16:
493  case DataType::QASYMM16:
494  return max_consecutive_elements_display_width_impl<uint16_t>(s, reinterpret_cast<const uint16_t *>(ptr), n);
495  case DataType::S16:
496  case DataType::QSYMM16:
497  return max_consecutive_elements_display_width_impl<int16_t>(s, reinterpret_cast<const int16_t *>(ptr), n);
498  case DataType::U32:
499  return max_consecutive_elements_display_width_impl<uint32_t>(s, reinterpret_cast<const uint32_t *>(ptr), n);
500  case DataType::S32:
501  return max_consecutive_elements_display_width_impl<int32_t>(s, reinterpret_cast<const int32_t *>(ptr), n);
502  case DataType::F32:
503  return max_consecutive_elements_display_width_impl<float>(s, reinterpret_cast<const float *>(ptr), n);
504  case DataType::F16:
505  return max_consecutive_elements_display_width_impl<half>(s, reinterpret_cast<const half *>(ptr), n);
506  default:
507  ARM_COMPUTE_ERROR("Undefined element size for given data type");
508  }
509  return 0;
510 }
511 #endif /* ARM_COMPUTE_ASSERTS_ENABLED */
BorderMode
Methods available to handle borders.
Definition: Types.h:260
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1022
bool needs_serialized_reduction(ReductionOperation op, DataType dt, unsigned int axis)
Check if the given reduction operation should be handled in a serial way.
Definition: Utils.cpp:432
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte.
InterpolationPolicy
Interpolation method.
Definition: Types.h:365
SimpleTensor< float > w
Definition: DFT.cpp:156
Second channel (used by formats with unknown channel types).
Shape of a tensor.
Definition: TensorShape.h:39
const DataLayout data_layout
Definition: Im2Col.cpp:146
Quantize to uint8 using a fixed point multiplication.
DimensionRoundingType round() const
Get the rounding type.
Definition: Types.h:780
quantized, symmetric fixed-point 16-bit number
ReductionOperation
Available reduction operations.
Definition: Types.h:494
std::pair< unsigned int, unsigned int > scaled_dimensions(unsigned int width, unsigned int height, unsigned int kernel_width, unsigned int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode.
Definition: Utils.cpp:402
const std::string & string_from_matrix_pattern(MatrixPattern pattern)
Convert a matrix pattern into a string.
Definition: Utils.cpp:194
const std::string & string_from_channel(Channel channel)
Convert a channel identity into a string.
Definition: Utils.cpp:111
std::pair< unsigned int, unsigned int > deconvolution_output_dimensions(unsigned int in_width, unsigned int in_height, unsigned int kernel_width, unsigned int kernel_height, const PadStrideInfo &pad_stride_info)
Returns expected width and height of the deconvolution's output tensor.
Definition: Utils.cpp:382
Cr/V/Value channel.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 U8 per channel
void get(uint8_t &v) const
Interpret the pixel value as a U8.
Definition: PixelValue.h:218
half_float::half half
16-bit floating point type
Definition: Types.h:44
1 channel, 1 F32 per channel
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: Types.h:566
Unknown channel format.
Output values are defined by bilinear interpolation between the pixels.
#define ARM_COMPUTE_ERROR_VAR(msg,...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:346
std::string string_from_pixel_value(const PixelValue &value, const DataType data_type)
Convert a PixelValue to a string, represented through the specific data type.
Definition: Utils.cpp:280
#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
const std::string & string_from_activation_func(ActivationLayerInfo::ActivationFunction act)
Translates a given activation function to a string.
Definition: Utils.cpp:172
A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling.
quantized, asymmetric fixed-point 16-bit number
1 channel, 1 U16 per channel
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:769
Output values are defined to match the source pixel whose center is nearest to the sample position.
const std::string & string_from_gemmlowp_output_stage(GEMMLowpOutputStageType output_stage)
Translates a given GEMMLowp output stage to a string.
Definition: Utils.cpp:267
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:333
A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling.
Copyright (c) 2017-2019 ARM Limited.
ActivationFunction
Available activation functions.
Definition: Types.h:1551
1 channel, 1 F16 per channel
const std::string & string_from_norm_type(NormType type)
Translates a given normalization type to a string.
Definition: Utils.cpp:243
const std::string & string_from_border_mode(BorderMode border_mode)
Translates a given border mode policy to a string.
Definition: Utils.cpp:231
1 channel, 1 S32 per channel
signed 64-bit number
3 channels, 1 U8 per channel
std::string tolower(std::string string)
Convert string to lower case.
Definition: Utility.h:203
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:144
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
std::string read_file(const std::string &filename, bool binary)
Load an entire file in memory.
Definition: Utils.cpp:47
Third channel (used by formats with unknown channel types).
1 channel, 1 U32 per channel
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1099
Normalization applied within the same map in 1D region.
Channel
Available channels.
Definition: Types.h:460
Format
Image colour formats.
Definition: Types.h:52
quantized, asymmetric fixed-point 8-bit number unsigned
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:733
const std::string & string_from_interpolation_policy(InterpolationPolicy policy)
Translates a given interpolation policy to a string.
Definition: Utils.cpp:219
A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes.
Fourth channel (used by formats with unknown channel types).
unsigned int pad_right() const
Get the right padding.
Definition: Types.h:764
const std::string & string_from_non_linear_filter_function(NonLinearFilterFunction function)
Translates a given non linear function to a string.
Definition: Utils.cpp:207
Quantize to uint8 using a floating point multiplication.
Padding and stride information class.
Definition: Types.h:685
GEMMLowpOutputStageType
GEMMLowp output stage type.
Definition: Types.h:1867
Quantize to uint8 using an integer multiplication.
1 channel, 1 S16 per channel
Output values are determined by averaging the source pixels whose areas fall under the area of the de...
quantized, symmetric fixed-point 8-bit number
Num samples, channels, height, width.
quantized, symmetric per channel fixed-point 8-bit number
A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes.
4 channels, 1 U8 per channel
PoolingType
Available pooling types.
Definition: Types.h:573
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
Definition: Utils.cpp:132
Borders are left undefined.
Pixels outside the image are assumed to have the same value as the closest image pixel.
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
Num samples, height, width, channels.
2 channel, 1 U8 per channel
std::string build_information()
Returns the arm_compute library build information.
quantized, asymmetric fixed-point 8-bit number signed
64-bit floating-point number
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:327
unsigned int pad_bottom() const
Get the bottom padding.
Definition: Types.h:774
A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes.
unsigned 64-bit number
DataType
Available data types.
Definition: Types.h:74
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:759
DataLayout
[DataLayout enum definition]
Definition: Types.h:116
const std::string & string_from_pooling_type(PoolingType type)
Translates a given pooling type to a string.
Definition: Utils.cpp:255
NormType
The normalization type used for the normalization layer.
Definition: Types.h:532
signed 8-bit number
MatrixPattern
Available matrix patterns.
Definition: Types.h:477
Normalization applied cross maps.
Any other matrix pattern.
NonLinearFilterFunction
Available non linear functions.
Definition: Types.h:486
Normalization applied within the same map in 2D region.
PadStrideInfo calculate_same_pad(TensorShape input_shape, TensorShape weights_shape, PadStrideInfo conv_info, DataLayout data_layout=DataLayout::NCHW, const Size2D &dilation=Size2D(1u, 1u), const DimensionRoundingType &rounding_type=DimensionRoundingType::FLOOR)
Calculate padding requirements in case of SAME padding.
Definition: Utils.cpp:340
const std::string & string_from_format(Format format)
Convert a tensor format into a string.
Definition: Utils.cpp:85