blob: 06d674644b9ac05294ab3b6812608de191f47915 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2016, 2017 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#ifndef __ARM_COMPUTE_UTILS_H__
25#define __ARM_COMPUTE_UTILS_H__
26
27#include "arm_compute/core/Error.h"
28#include "arm_compute/core/Types.h"
29
30#include <algorithm>
31#include <cstdint>
32#include <cstdlib>
33#include <numeric>
34#include <sstream>
35#include <string>
36#include <type_traits>
37#include <utility>
steniu017ce53c62017-09-29 14:55:00 +010038#include <vector>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039
40namespace arm_compute
41{
42/** Computes the smallest number larger or equal to value that is a multiple of divisor. */
43template <typename S, typename T>
44inline auto ceil_to_multiple(S value, T divisor) -> decltype(((value + divisor - 1) / divisor) * divisor)
45{
46 ARM_COMPUTE_ERROR_ON(value < 0 || divisor <= 0);
47 return ((value + divisor - 1) / divisor) * divisor;
48}
49
50/** Computes the largest number smaller or equal to value that is a multiple of divisor. */
51template <typename S, typename T>
52inline auto floor_to_multiple(S value, T divisor) -> decltype((value / divisor) * divisor)
53{
54 ARM_COMPUTE_ERROR_ON(value < 0 || divisor <= 0);
55 return (value / divisor) * divisor;
56}
57
58/** Calculate the rounded up quotient of val / m. */
59template <typename S, typename T>
60constexpr auto DIV_CEIL(S val, T m) -> decltype((val + m - 1) / m)
61{
62 return (val + m - 1) / m;
63}
64
65/** Returns the arm_compute library build information
66 *
67 * Contains the version number and the build options used to build the library
68 *
69 * @return The arm_compute library build information
70 */
71std::string build_information();
72
73/** Load an entire file in memory
74 *
75 * @param[in] filename Name of the file to read.
76 * @param[in] binary Is it a binary file ?
77 *
78 * @return The content of the file.
79 */
80std::string read_file(const std::string &filename, bool binary);
81
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082/** The size in bytes of the data type
83 *
84 * @param[in] data_type Input data type
85 *
86 * @return The size in bytes of the data type
87 */
88inline size_t data_size_from_type(DataType data_type)
89{
90 switch(data_type)
91 {
92 case DataType::U8:
93 case DataType::S8:
94 case DataType::QS8:
95 return 1;
96 case DataType::U16:
97 case DataType::S16:
98 case DataType::F16:
99 case DataType::QS16:
100 return 2;
101 case DataType::F32:
102 case DataType::U32:
103 case DataType::S32:
Pablo Tellof87cc7f2017-07-26 10:28:40 +0100104 case DataType::QS32:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100105 return 4;
106 case DataType::F64:
107 case DataType::U64:
108 case DataType::S64:
109 return 8;
110 case DataType::SIZET:
111 return sizeof(size_t);
112 default:
113 ARM_COMPUTE_ERROR("Invalid data type");
114 return 0;
115 }
116}
117
118/** The size in bytes of the pixel format
119 *
120 * @param[in] format Input format
121 *
122 * @return The size in bytes of the pixel format
123 */
124inline size_t pixel_size_from_format(Format format)
125{
126 switch(format)
127 {
128 case Format::U8:
129 return 1;
130 case Format::U16:
131 case Format::S16:
132 case Format::F16:
133 case Format::UV88:
134 case Format::YUYV422:
135 case Format::UYVY422:
136 return 2;
137 case Format::RGB888:
138 return 3;
139 case Format::RGBA8888:
140 return 4;
141 case Format::U32:
142 case Format::S32:
143 case Format::F32:
144 return 4;
145 //Doesn't make sense for planar formats:
146 case Format::NV12:
147 case Format::NV21:
148 case Format::IYUV:
149 case Format::YUV444:
150 default:
151 ARM_COMPUTE_ERROR("Undefined pixel size for given format");
152 return 0;
153 }
154}
155
156/** The size in bytes of the data type
157 *
158 * @param[in] dt Input data type
159 *
160 * @return The size in bytes of the data type
161 */
162inline size_t element_size_from_data_type(DataType dt)
163{
164 switch(dt)
165 {
166 case DataType::S8:
167 case DataType::U8:
168 case DataType::QS8:
169 return 1;
170 case DataType::U16:
171 case DataType::S16:
172 case DataType::QS16:
173 case DataType::F16:
174 return 2;
175 case DataType::U32:
176 case DataType::S32:
177 case DataType::F32:
Pablo Tellof87cc7f2017-07-26 10:28:40 +0100178 case DataType::QS32:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100179 return 4;
180 default:
181 ARM_COMPUTE_ERROR("Undefined element size for given data type");
182 return 0;
183 }
184}
185
186/** Return the data type used by a given single-planar pixel format
187 *
188 * @param[in] format Input format
189 *
190 * @return The size in bytes of the pixel format
191 */
192inline DataType data_type_from_format(Format format)
193{
194 switch(format)
195 {
196 case Format::U8:
197 case Format::UV88:
198 case Format::RGB888:
199 case Format::RGBA8888:
200 case Format::YUYV422:
201 case Format::UYVY422:
202 return DataType::U8;
203 case Format::U16:
204 return DataType::U16;
205 case Format::S16:
206 return DataType::S16;
207 case Format::U32:
208 return DataType::U32;
209 case Format::S32:
210 return DataType::S32;
211 case Format::F16:
212 return DataType::F16;
213 case Format::F32:
214 return DataType::F32;
215 //Doesn't make sense for planar formats:
216 case Format::NV12:
217 case Format::NV21:
218 case Format::IYUV:
219 case Format::YUV444:
220 default:
221 ARM_COMPUTE_ERROR("Not supported data_type for given format");
222 return DataType::UNKNOWN;
223 }
224}
225
226/** Return the plane index of a given channel given an input format.
227 *
228 * @param[in] format Input format
229 * @param[in] channel Input channel
230 *
231 * @return The plane index of the specific channel of the specific format
232 */
233inline int plane_idx_from_channel(Format format, Channel channel)
234{
235 switch(format)
236 {
237 case Format::NV12:
238 case Format::NV21:
239 {
240 switch(channel)
241 {
242 case Channel::Y:
243 return 0;
244 case Channel::U:
245 case Channel::V:
246 return 1;
247 default:
248 ARM_COMPUTE_ERROR("Not supported channel");
249 return 0;
250 }
251 }
252 case Format::IYUV:
253 case Format::YUV444:
254 {
255 switch(channel)
256 {
257 case Channel::Y:
258 return 0;
259 case Channel::U:
260 return 1;
261 case Channel::V:
262 return 2;
263 default:
264 ARM_COMPUTE_ERROR("Not supported channel");
265 return 0;
266 }
267 }
268 default:
269 ARM_COMPUTE_ERROR("Not supported format");
270 return 0;
271 }
272}
273
274/** Return the number of planes for a given format
275 *
276 * @param[in] format Input format
277 *
278 * @return The number of planes for a given image format.
279 */
280inline size_t num_planes_from_format(Format format)
281{
282 switch(format)
283 {
284 case Format::U8:
285 case Format::S16:
286 case Format::U16:
287 case Format::S32:
288 case Format::U32:
289 case Format::F16:
290 case Format::F32:
291 case Format::RGB888:
292 case Format::RGBA8888:
293 case Format::YUYV422:
294 case Format::UYVY422:
295 return 1;
296 case Format::NV12:
297 case Format::NV21:
298 return 2;
299 case Format::IYUV:
300 case Format::YUV444:
301 return 3;
302 default:
303 ARM_COMPUTE_ERROR("Not supported format");
304 return 0;
305 }
306}
307
308/** Return the number of channels for a given single-planar pixel format
309 *
310 * @param[in] format Input format
311 *
312 * @return The number of channels for a given image format.
313 */
314inline size_t num_channels_from_format(Format format)
315{
316 switch(format)
317 {
318 case Format::U8:
319 case Format::U16:
320 case Format::S16:
321 case Format::U32:
322 case Format::S32:
323 case Format::F16:
324 case Format::F32:
325 return 1;
326 // Because the U and V channels are subsampled
327 // these formats appear like having only 2 channels:
328 case Format::YUYV422:
329 case Format::UYVY422:
330 return 2;
331 case Format::UV88:
332 return 2;
333 case Format::RGB888:
334 return 3;
335 case Format::RGBA8888:
336 return 4;
337 //Doesn't make sense for planar formats:
338 case Format::NV12:
339 case Format::NV21:
340 case Format::IYUV:
341 case Format::YUV444:
342 default:
343 return 0;
344 }
345}
346
347/** Separate a 2D convolution into two 1D convolutions
348*
349* @param[in] conv 2D convolution
350* @param[out] conv_col 1D vertical convolution
351* @param[out] conv_row 1D horizontal convolution
352* @param[in] size Size of the 2D convolution
353*
354* @return true if the separation was successful
355*/
356inline bool separate_matrix(const int16_t *conv, int16_t *conv_col, int16_t *conv_row, uint8_t size)
357{
358 int32_t min_col = -1;
359 int16_t min_col_val = -1;
360
361 for(int32_t i = 0; i < size; ++i)
362 {
363 if(conv[i] != 0 && (min_col < 0 || abs(min_col_val) > abs(conv[i])))
364 {
365 min_col = i;
366 min_col_val = conv[i];
367 }
368 }
369
370 if(min_col < 0)
371 {
372 return false;
373 }
374
375 for(uint32_t j = 0; j < size; ++j)
376 {
377 conv_col[j] = conv[min_col + j * size];
378 }
379
380 for(uint32_t i = 0; i < size; i++)
381 {
382 if(static_cast<int>(i) == min_col)
383 {
384 conv_row[i] = 1;
385 }
386 else
387 {
388 int16_t coeff = conv[i] / conv[min_col];
389
390 for(uint32_t j = 1; j < size; ++j)
391 {
392 if(conv[i + j * size] != (conv_col[j] * coeff))
393 {
394 return false;
395 }
396 }
397
398 conv_row[i] = coeff;
399 }
400 }
401
402 return true;
403}
404
405/** Calculate the scale of the given square matrix
406 *
407 * The scale is the absolute value of the sum of all the coefficients in the matrix.
408 *
409 * @note If the coefficients add up to 0 then the scale is set to 1.
410 *
411 * @param[in] matrix Matrix coefficients
412 * @param[in] matrix_size Number of elements per side of the square matrix. (Number of coefficients = matrix_size * matrix_size).
413 *
414 * @return The absolute value of the sum of the coefficients if they don't add up to 0, otherwise 1.
415 */
416inline uint32_t calculate_matrix_scale(const int16_t *matrix, unsigned int matrix_size)
417{
418 const size_t size = matrix_size * matrix_size;
419
420 return std::max(1, std::abs(std::accumulate(matrix, matrix + size, 0)));
421}
422
steniu017ce53c62017-09-29 14:55:00 +0100423/** Calculate the output shapes of the depth concatenate function.
424 *
425 * @param[in] inputs_vector The vector that stores all the pointers to input.
426 *
427 * @return the output shape
428 */
429template <typename T>
430TensorShape calculate_depth_concatenate_shape(const std::vector<T *> &inputs_vector)
431{
432 TensorShape out_shape = inputs_vector[0]->info()->tensor_shape();
433
434 size_t max_x = 0;
435 size_t max_y = 0;
436 size_t depth = 0;
437
438 for(const auto &tensor : inputs_vector)
439 {
440 ARM_COMPUTE_ERROR_ON(tensor == nullptr);
441 const TensorShape shape = tensor->info()->tensor_shape();
442 max_x = std::max(shape.x(), max_x);
443 max_y = std::max(shape.y(), max_y);
444 depth += shape.z();
445 }
446
447 out_shape.set(0, max_x);
448 out_shape.set(1, max_y);
449 out_shape.set(2, depth);
450
451 return out_shape;
452}
453
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100454/** Calculate accurary required by the horizontal and vertical convolution computations
455 *
456 * @param[in] conv_col Pointer to the vertical vector of the separated convolution filter
457 * @param[in] conv_row Pointer to the horizontal vector of the convolution filter
458 * @param[in] size Number of elements per vector of the separated matrix
459 *
460 * @return The return type is a pair. The first element of the pair is the biggest data type needed for the first stage. The second
461 * element of the pair is the biggest data type needed for the second stage.
462 */
463inline std::pair<DataType, DataType> data_type_for_convolution(const int16_t *conv_col, const int16_t *conv_row, size_t size)
464{
465 DataType first_stage = DataType::UNKNOWN;
466 DataType second_stage = DataType::UNKNOWN;
467
468 auto gez = [](const int16_t &v)
469 {
470 return v >= 0;
471 };
472
473 auto accu_neg = [](const int &first, const int &second)
474 {
475 return first + (second < 0 ? second : 0);
476 };
477
478 auto accu_pos = [](const int &first, const int &second)
479 {
480 return first + (second > 0 ? second : 0);
481 };
482
483 const bool only_positive_coefficients = std::all_of(conv_row, conv_row + size, gez) && std::all_of(conv_col, conv_col + size, gez);
484
485 if(only_positive_coefficients)
486 {
487 const int max_row_value = std::accumulate(conv_row, conv_row + size, 0) * UINT8_MAX;
488 const int max_value = std::accumulate(conv_col, conv_col + size, 0) * max_row_value;
489
490 first_stage = (max_row_value <= UINT16_MAX) ? DataType::U16 : DataType::S32;
491
492 second_stage = (max_value <= UINT16_MAX) ? DataType::U16 : DataType::S32;
493 }
494 else
495 {
496 const int min_row_value = std::accumulate(conv_row, conv_row + size, 0, accu_neg) * UINT8_MAX;
497 const int max_row_value = std::accumulate(conv_row, conv_row + size, 0, accu_pos) * UINT8_MAX;
498 const int neg_coeffs_sum = std::accumulate(conv_col, conv_col + size, 0, accu_neg);
499 const int pos_coeffs_sum = std::accumulate(conv_col, conv_col + size, 0, accu_pos);
500 const int min_value = neg_coeffs_sum * max_row_value + pos_coeffs_sum * min_row_value;
501 const int max_value = neg_coeffs_sum * min_row_value + pos_coeffs_sum * max_row_value;
502
503 first_stage = ((INT16_MIN <= min_row_value) && (max_row_value <= INT16_MAX)) ? DataType::S16 : DataType::S32;
504
505 second_stage = ((INT16_MIN <= min_value) && (max_value <= INT16_MAX)) ? DataType::S16 : DataType::S32;
506 }
507
508 return std::make_pair(first_stage, second_stage);
509}
510
511/** Calculate the accuracy required by the squared convolution calculation.
512 *
513 *
514 * @param[in] conv Pointer to the squared convolution matrix
515 * @param[in] size The total size of the convolution matrix
516 *
517 * @return The return is the biggest data type needed to do the convolution
518 */
519inline DataType data_type_for_convolution_matrix(const int16_t *conv, size_t size)
520{
521 auto gez = [](const int16_t v)
522 {
523 return v >= 0;
524 };
525
526 const bool only_positive_coefficients = std::all_of(conv, conv + size, gez);
527
528 if(only_positive_coefficients)
529 {
530 const int max_conv_value = std::accumulate(conv, conv + size, 0) * UINT8_MAX;
531 if(max_conv_value <= UINT16_MAX)
532 {
533 return DataType::U16;
534 }
535 else
536 {
537 return DataType::S32;
538 }
539 }
540 else
541 {
542 const int min_value = std::accumulate(conv, conv + size, 0, [](int a, int b)
543 {
544 return b < 0 ? a + b : a;
545 })
546 * UINT8_MAX;
547
548 const int max_value = std::accumulate(conv, conv + size, 0, [](int a, int b)
549 {
550 return b > 0 ? a + b : a;
551 })
552 * UINT8_MAX;
553
554 if((INT16_MIN <= min_value) && (INT16_MAX >= max_value))
555 {
556 return DataType::S16;
557 }
558 else
559 {
560 return DataType::S32;
561 }
562 }
563}
564
565/** Returns expected width and height of output scaled tensor depending on dimensions rounding mode.
566 *
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100567 * @param[in] width Width of input tensor (Number of columns)
568 * @param[in] height Height of input tensor (Number of rows)
569 * @param[in] kernel_width Kernel width.
570 * @param[in] kernel_height Kernel height.
571 * @param[in] pad_stride_info Pad and stride information.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100572 *
573 * @return A pair with the new width in the first position and the new height in the second.
574 */
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100575const std::pair<unsigned int, unsigned int> scaled_dimensions(unsigned int width, unsigned int height,
576 unsigned int kernel_width, unsigned int kernel_height,
577 const PadStrideInfo &pad_stride_info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100578
579/** Convert a tensor format into a string.
580 *
581 * @param[in] format @ref Format to be translated to string.
582 *
583 * @return The string describing the format.
584 */
585const std::string &string_from_format(Format format);
586
587/** Convert a channel identity into a string.
588 *
589 * @param[in] channel @ref Channel to be translated to string.
590 *
591 * @return The string describing the channel.
592 */
593const std::string &string_from_channel(Channel channel);
594
595/** Convert a data type identity into a string.
596 *
597 * @param[in] dt @ref DataType to be translated to string.
598 *
599 * @return The string describing the data type.
600 */
601const std::string &string_from_data_type(DataType dt);
602/** Convert a matrix pattern into a string.
603 *
604 * @param[in] pattern @ref MatrixPattern to be translated to string.
605 *
606 * @return The string describing the matrix pattern.
607 */
608const std::string &string_from_matrix_pattern(MatrixPattern pattern);
609/** Translates a given activation function to a string.
610 *
611 * @param[in] act @ref ActivationLayerInfo::ActivationFunction to be translated to string.
612 *
613 * @return The string describing the activation function.
614 */
615const std::string &string_from_activation_func(ActivationLayerInfo::ActivationFunction act);
616/** Translates a given non linear function to a string.
617 *
618 * @param[in] function @ref NonLinearFilterFunction to be translated to string.
619 *
620 * @return The string describing the non linear function.
621 */
622const std::string &string_from_non_linear_filter_function(NonLinearFilterFunction function);
623/** Translates a given interpolation policy to a string.
624 *
625 * @param[in] policy @ref InterpolationPolicy to be translated to string.
626 *
627 * @return The string describing the interpolation policy.
628 */
629const std::string &string_from_interpolation_policy(InterpolationPolicy policy);
630/** Translates a given border mode policy to a string.
631 *
632 * @param[in] border_mode @ref BorderMode to be translated to string.
633 *
634 * @return The string describing the border mode.
635 */
636const std::string &string_from_border_mode(BorderMode border_mode);
637/** Translates a given normalization type to a string.
638 *
639 * @param[in] type @ref NormType to be translated to string.
640 *
641 * @return The string describing the normalization type.
642 */
643const std::string &string_from_norm_type(NormType type);
Georgios Pinitascdf51452017-08-31 14:21:36 +0100644/** Translates a given pooling type to a string.
645 *
646 * @param[in] type @ref PoolingType to be translated to string.
647 *
648 * @return The string describing the pooling type.
649 */
650const std::string &string_from_pooling_type(PoolingType type);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100651/** Lower a given string.
652 *
653 * @param[in] val Given string to lower.
654 *
655 * @return The lowered string
656 */
657std::string lower_string(const std::string &val);
658
659/** Check if a given data type is of floating point type
660 *
661 * @param[in] dt Input data type.
662 *
663 * @return True if data type is of floating point type, else false.
664 */
665inline bool is_data_type_float(DataType dt)
666{
667 switch(dt)
668 {
669 case DataType::F16:
670 case DataType::F32:
671 return true;
672 default:
673 return false;
674 }
675}
676
677/** Check if a given data type is of fixed point type
678 *
679 * @param[in] dt Input data type.
680 *
681 * @return True if data type is of fixed point type, else false.
682 */
683inline bool is_data_type_fixed_point(DataType dt)
684{
685 switch(dt)
686 {
687 case DataType::QS8:
688 case DataType::QS16:
Pablo Tellof87cc7f2017-07-26 10:28:40 +0100689 case DataType::QS32:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100690 return true;
691 default:
692 return false;
693 }
694}
695
Georgios Pinitas89010962017-08-04 14:58:27 +0100696/** Create a string with the float in full precision.
697 *
698 * @param val Floating point value
699 *
700 * @return String with the floating point value.
701 */
702inline std::string float_to_string_with_full_precision(float val)
703{
704 std::stringstream ss;
705 ss.precision(std::numeric_limits<float>::digits10 + 1);
706 ss << val;
707 return ss.str();
708}
709
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100710/** Print consecutive elements to an output stream.
711 *
712 * @param[out] s Output stream to print the elements to.
713 * @param[in] ptr Pointer to print the elements from.
714 * @param[in] n Number of elements to print.
715 * @param[in] stream_width (Optional) Width of the stream. If set to 0 the element's width is used. Defaults to 0.
716 * @param[in] element_delim (Optional) Delimeter among the consecutive elements. Defaults to space delimeter
717 */
718template <typename T>
719void print_consecutive_elements_impl(std::ostream &s, const T *ptr, unsigned int n, int stream_width = 0, const std::string &element_delim = " ")
720{
721 using print_type = typename std::conditional<std::is_floating_point<T>::value, T, int>::type;
722
723 for(unsigned int i = 0; i < n; ++i)
724 {
725 // Set stream width as it is not a "sticky" stream manipulator
726 if(stream_width != 0)
727 {
728 s.width(stream_width);
729 }
730 s << std::right << static_cast<print_type>(ptr[i]) << element_delim;
731 }
732}
733
734/** Identify the maximum width of n consecutive elements.
735 *
736 * @param[in] s The output stream which will be used to print the elements. Used to extract the stream format.
737 * @param[in] ptr Pointer to the elements.
738 * @param[in] n Number of elements.
739 *
740 * @return The maximum width of the elements.
741 */
742template <typename T>
743int max_consecutive_elements_display_width_impl(std::ostream &s, const T *ptr, unsigned int n)
744{
745 using print_type = typename std::conditional<std::is_floating_point<T>::value, T, int>::type;
746
747 int max_width = -1;
748 for(unsigned int i = 0; i < n; ++i)
749 {
750 std::stringstream ss;
751 ss.copyfmt(s);
752 ss << static_cast<print_type>(ptr[i]);
753 max_width = std::max<int>(max_width, ss.str().size());
754 }
755 return max_width;
756}
757
758/** Print consecutive elements to an output stream.
759 *
760 * @param[out] s Output stream to print the elements to.
761 * @param[in] dt Data type of the elements
762 * @param[in] ptr Pointer to print the elements from.
763 * @param[in] n Number of elements to print.
764 * @param[in] stream_width (Optional) Width of the stream. If set to 0 the element's width is used. Defaults to 0.
765 * @param[in] element_delim (Optional) Delimeter among the consecutive elements. Defaults to space delimeter
766 */
767void print_consecutive_elements(std::ostream &s, DataType dt, const uint8_t *ptr, unsigned int n, int stream_width, const std::string &element_delim = " ");
768
769/** Identify the maximum width of n consecutive elements.
770 *
771 * @param[in] s Output stream to print the elements to.
772 * @param[in] dt Data type of the elements
773 * @param[in] ptr Pointer to print the elements from.
774 * @param[in] n Number of elements to print.
775 *
776 * @return The maximum width of the elements.
777 */
778int max_consecutive_elements_display_width(std::ostream &s, DataType dt, const uint8_t *ptr, unsigned int n);
779}
780#endif /*__ARM_COMPUTE_UTILS_H__ */