23.11
|
Go to the documentation of this file.
24 #ifndef ARM_COMPUTE_UTILS_H
25 #define ARM_COMPUTE_UTILS_H
35 #include <type_traits>
36 #include <unordered_map>
51 class ActivationLayerInfo;
60 std::string
read_file(
const std::string &filename,
bool binary);
71 const auto old_dim = utility::make_array<Dimensions<T>::num_max_dimensions>(dimensions.
begin(), dimensions.
end());
74 T dimension_val = old_dim[i];
75 dimensions.
set(perm[i], dimension_val);
91 TensorShape weights_shape,
94 const Size2D &dilation = Size2D(1u, 1u),
108 unsigned int in_height,
109 unsigned int kernel_width,
110 unsigned int kernel_height,
111 const PadStrideInfo &pad_stride_info);
128 const PadStrideInfo &pad_stride_info,
129 const Size2D &dilation = Size2D(1
U, 1
U));
142 int width,
int height,
int kernel_width,
int kernel_height,
const PadStrideInfo &pad_stride_info);
163 const Pooling3dLayerInfo &pool3d_info);
194 UniformQuantizationInfo oq_info);
271 std::unordered_map<const ITensorInfo *, PaddingSize>
get_padding_info(std::initializer_list<const ITensorInfo *> infos);
278 std::unordered_map<const ITensorInfo *, PaddingSize>
get_padding_info(std::initializer_list<const ITensor *> tensors);
285 bool has_padding_changed(
const std::unordered_map<const ITensorInfo *, PaddingSize> &padding_map);
298 return size_t(std::ceil((
end - start) /
step));
301 #ifdef ARM_COMPUTE_ASSERTS_ENABLED
310 template <
typename T>
311 void print_consecutive_elements_impl(
312 std::ostream &s,
const T *ptr,
unsigned int n,
int stream_width = 0,
const std::string &element_delim =
" ")
314 using print_type =
typename std::conditional<std::is_floating_point<T>::value, T,
int>
::type;
315 std::ios stream_status(
nullptr);
316 stream_status.copyfmt(s);
318 for (
unsigned int i = 0; i < n; ++i)
321 if (stream_width != 0)
323 s.width(stream_width);
329 s << std::right << static_cast<T>(ptr[i]) << element_delim;
334 s << std::right << float(ptr[i]) << element_delim;
338 s << std::right << static_cast<print_type>(ptr[i]) << element_delim;
343 s.copyfmt(stream_status);
354 template <
typename T>
355 int max_consecutive_elements_display_width_impl(std::ostream &s,
const T *ptr,
unsigned int n)
357 using print_type =
typename std::conditional<std::is_floating_point<T>::value, T,
int>
::type;
360 for (
unsigned int i = 0; i < n; ++i)
362 std::stringstream
ss;
368 ss << static_cast<T>(ptr[i]);
377 ss << static_cast<print_type>(ptr[i]);
380 max_width = std::max<int>(max_width,
ss.str().size());
394 void print_consecutive_elements(std::ostream &s,
399 const std::string &element_delim =
" ");
410 int max_consecutive_elements_display_width(std::ostream &s,
DataType dt,
const uint8_t *ptr,
unsigned int n);
@ NCHW
Num samples, channels, height, width.
decltype(strategy::transforms) typedef type
const std::string & string_from_pooling_type(PoolingType type)
Translates a given pooling type to a string.
bool is_pool_3d_region_entirely_outside_input(const Pooling3dLayerInfo &info)
Check if the 3d pool region is entirely outside the input tensor.
void set(size_t dimension, T value, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
DataLayout
[DataLayout enum definition]
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.
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.
Padding information for 3D operations like Conv3d.
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.
std::pair< int32_t, int32_t > get_quantized_activation_min_max(const ActivationLayerInfo &act_info, DataType data_type, UniformQuantizationInfo oq_info)
Returns a pair of minimum and maximum values for a quantized activation.
void permute_strides(Dimensions< T > &dimensions, const PermutationVector &perm)
Permutes the given dimensions according the permutation vector.
bool is_symmetric(const Padding3D &info)
Check if the 3D padding is symmetric i.e.
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, 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.
const std::string & string_from_border_mode(BorderMode border_mode)
Translates a given border mode policy to a string.
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
const std::string & string_from_channel(Channel channel)
Convert a channel identity into a string.
ReductionOperation
Available reduction operations.
std::string read_file(const std::string &filename, bool binary)
Load an entire file in memory.
std::pair< int, int > scaled_dimensions_signed(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info)
Returns calculated width and height of output scaled tensor depending on dimensions rounding mode.
constexpr auto data_layout
const std::string & string_from_gemmlowp_output_stage(GEMMLowpOutputStageType output_stage)
Translates a given GEMMLowp output stage to a string.
const OutputStage & output_stage
Strides of an item in bytes.
half_float::half half
16-bit floating point type
QuantizationInfo get_softmax_output_quantization_info(DataType input_type, bool is_log)
Returns output quantization information for softmax layer.
std::stringstream ss(mlgo_str)
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
arm_compute::bfloat16 bfloat16
const std::string & string_from_norm_type(NormType type)
Translates a given normalization type to a string.
PoolingType
Available pooling types.
std::array< T, num_max_dimensions >::iterator begin()
Returns a read/write iterator that points to the first element in the dimension array.
Channel
Available channels.
GEMMLowpOutputStageType
GEMMLowp output stage type.
TensorShape input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
Copyright (c) 2017-2023 Arm Limited.
std::tuple< int, int, int > scaled_3d_dimensions_signed(int width, int height, int depth, int kernel_width, int kernel_height, int kernel_depth, const Pooling3dLayerInfo &pool3d_info)
Returns calculated width, height and depth of output scaled tensor depending on dimensions rounding m...
bool is_pool_region_entirely_outside_input(const PoolingLayerInfo &info)
Check if the pool region is entirely outside the input tensor.
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.
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.
void end(TokenStream &in, bool &valid)
BorderMode
Methods available to handle borders.
std::array< T, num_max_dimensions >::iterator end()
Returns a read/write iterator that points one past the last element in the dimension array.
NormType
The normalization type used for the normalization layer.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
bool needs_serialized_reduction(ReductionOperation op, DataType dt, unsigned int axis)
Check if the given reduction operation should be handled in a serial way.
Dimensions with dimensionality.
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
DataType
Available data types.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo * > infos)
Stores padding information before configuring a kernel.