Compute Library
 19.08
Utils.h File Reference
#include "arm_compute/core/Error.h"
#include "arm_compute/core/PixelValue.h"
#include "arm_compute/core/Rounding.h"
#include "arm_compute/core/Types.h"
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

 arm_compute
 Copyright (c) 2017-2018 ARM Limited.
 

Functions

template<typename S , typename T >
constexpr auto DIV_CEIL (S val, T m) -> decltype((val+m - 1)/m)
 Calculate the rounded up quotient of val / m. More...
 
template<typename S , typename T >
auto ceil_to_multiple (S value, T divisor) -> decltype(((value+divisor - 1)/divisor) *divisor)
 Computes the smallest number larger or equal to value that is a multiple of divisor. More...
 
template<typename S , typename T >
auto floor_to_multiple (S value, T divisor) -> decltype((value/divisor) *divisor)
 Computes the largest number smaller or equal to value that is a multiple of divisor. More...
 
std::string build_information ()
 Returns the arm_compute library build information. More...
 
std::string read_file (const std::string &filename, bool binary)
 Load an entire file in memory. More...
 
size_t data_size_from_type (DataType data_type)
 The size in bytes of the data type. More...
 
size_t pixel_size_from_format (Format format)
 The size in bytes of the pixel format. More...
 
size_t element_size_from_data_type (DataType dt)
 The size in bytes of the data type. More...
 
DataType data_type_from_format (Format format)
 Return the data type used by a given single-planar pixel format. More...
 
int plane_idx_from_channel (Format format, Channel channel)
 Return the plane index of a given channel given an input format. More...
 
int channel_idx_from_format (Format format, Channel channel)
 Return the channel index of a given channel given an input format. More...
 
size_t num_planes_from_format (Format format)
 Return the number of planes for a given format. More...
 
size_t num_channels_from_format (Format format)
 Return the number of channels for a given single-planar pixel format. More...
 
DataType get_promoted_data_type (DataType dt)
 Return the promoted data type of a given data type. More...
 
bool has_format_horizontal_subsampling (Format format)
 Return true if the given format has horizontal subsampling. More...
 
bool has_format_vertical_subsampling (Format format)
 Return true if the given format has vertical subsampling. More...
 
bool separate_matrix (const int16_t *conv, int16_t *conv_col, int16_t *conv_row, uint8_t size)
 Separate a 2D convolution into two 1D convolutions. More...
 
uint32_t calculate_matrix_scale (const int16_t *matrix, unsigned int matrix_size)
 Calculate the scale of the given square matrix. More...
 
TensorShape adjust_odd_shape (const TensorShape &shape, Format format)
 Adjust tensor shape size if width or height are odd for a given multi-planar format. More...
 
TensorShape calculate_subsampled_shape (const TensorShape &shape, Format format, Channel channel=Channel::UNKNOWN)
 Calculate subsampled shape for a given format and channel. More...
 
std::pair< DataType, DataType > data_type_for_convolution (const int16_t *conv_col, const int16_t *conv_row, size_t size)
 Calculate accurary required by the horizontal and vertical convolution computations. More...
 
DataType data_type_for_convolution_matrix (const int16_t *conv, size_t size)
 Calculate the accuracy required by the squared convolution calculation. More...
 
template<typename T >
void permute_strides (Dimensions< T > &dimensions, const PermutationVector &perm)
 Permutes the given dimensions according the permutation vector. More...
 
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. More...
 
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, unsigned int padx, unsigned int pady, unsigned int stride_x, unsigned int stride_y)
 Returns expected width and height of the deconvolution's output tensor. More...
 
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. More...
 
const std::string & string_from_format (Format format)
 Convert a tensor format into a string. More...
 
const std::string & string_from_channel (Channel channel)
 Convert a channel identity into a string. More...
 
const std::string & string_from_data_layout (DataLayout dl)
 Convert a data layout identity into a string. More...
 
const std::string & string_from_data_type (DataType dt)
 Convert a data type identity into a string. More...
 
const std::string & string_from_matrix_pattern (MatrixPattern pattern)
 Convert a matrix pattern into a string. More...
 
const std::string & string_from_activation_func (ActivationLayerInfo::ActivationFunction act)
 Translates a given activation function to a string. More...
 
const std::string & string_from_non_linear_filter_function (NonLinearFilterFunction function)
 Translates a given non linear function to a string. More...
 
const std::string & string_from_interpolation_policy (InterpolationPolicy policy)
 Translates a given interpolation policy to a string. More...
 
const std::string & string_from_border_mode (BorderMode border_mode)
 Translates a given border mode policy to a string. More...
 
const std::string & string_from_norm_type (NormType type)
 Translates a given normalization type to a string. More...
 
const std::string & string_from_pooling_type (PoolingType type)
 Translates a given pooling type to a string. More...
 
const std::string & string_from_gemmlowp_output_stage (GEMMLowpOutputStageType output_stage)
 Translates a given GEMMLowp output stage to a string. More...
 
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. More...
 
std::string lower_string (const std::string &val)
 Lower a given string. More...
 
bool is_data_type_float (DataType dt)
 Check if a given data type is of floating point type. More...
 
bool is_data_type_quantized (DataType dt)
 Check if a given data type is of quantized type. More...
 
bool is_data_type_quantized_asymmetric (DataType dt)
 Check if a given data type is of asymmetric quantized type. More...
 
bool is_data_type_quantized_symmetric (DataType dt)
 Check if a given data type is of symmetric quantized type. More...
 
std::string float_to_string_with_full_precision (float val)
 Create a string with the float in full precision. More...
 
size_t num_of_elements_in_range (const float start, const float end, const float step)
 Returns the number of elements required to go from start to end with the wanted step. More...
 
template<typename T >
bool check_value_range (T val, DataType dt, QuantizationInfo qinfo=QuantizationInfo())
 Returns true if the value can be represented by the given data type. More...