blob: 22be0002ee3462e6307a0cc80045ff502018de66 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
giuros01edc21e42018-11-16 14:45:31 +00002 * Copyright (c) 2016-2019 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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 */
Jaroslaw Rzepecki0a878ae2017-11-22 17:16:39 +000024
Isabella Gottardi6a914402019-01-30 15:45:42 +000025#include "arm_compute/core/Helpers.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Isabella Gottardi6a914402019-01-30 15:45:42 +000027#include "arm_compute/core/Utils.h"
Jaroslaw Rzepecki0a878ae2017-11-22 17:16:39 +000028#include "support/ToolchainSupport.h"
29
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030#include <algorithm>
31#include <cmath>
32#include <cstdint>
33#include <fstream>
34#include <map>
35#include <string>
36
37using namespace arm_compute;
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +000038#ifndef DOXYGEN_SKIP_THIS
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039std::string arm_compute::build_information()
40{
41 static const std::string information =
42#include "arm_compute_version.embed"
43 ;
44 return information;
45}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +000046#endif /* DOXYGEN_SKIP_THIS */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047std::string arm_compute::read_file(const std::string &filename, bool binary)
48{
49 std::string out;
50 std::ifstream fs;
51
Michalis Spyrou323ce0f2018-11-30 16:30:43 +000052#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
Anthony Barbier6ff3b192017-09-04 18:44:23 +010053 try
54 {
Michalis Spyrou323ce0f2018-11-30 16:30:43 +000055#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010056 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>());
Michalis Spyrou323ce0f2018-11-30 16:30:43 +000074#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
Anthony Barbier6ff3b192017-09-04 18:44:23 +010075 }
76 catch(const std::ifstream::failure &e)
77 {
78 ARM_COMPUTE_ERROR("Accessing %s: %s", filename.c_str(), e.what());
79 }
Michalis Spyrou323ce0f2018-11-30 16:30:43 +000080#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010081
82 return out;
83}
84
85const 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
111const 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
Michele Di Giorgiobf3c6622018-03-08 11:52:27 +0000132const std::string &arm_compute::string_from_data_layout(DataLayout dl)
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
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100144const std::string &arm_compute::string_from_data_type(DataType dt)
145{
146 static std::map<DataType, const std::string> dt_map =
147 {
148 { DataType::UNKNOWN, "UNKNOWN" },
149 { DataType::S8, "S8" },
150 { DataType::U8, "U8" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100151 { DataType::S16, "S16" },
152 { DataType::U16, "U16" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100153 { 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" },
Isabella Gottardi01a214a2018-04-09 16:00:52 +0100161 { DataType::QASYMM8, "QASYMM8" },
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100162 { DataType::QSYMM16, "QSYMM16" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100163 };
164
165 return dt_map[dt];
166}
167
168const std::string &arm_compute::string_from_activation_func(ActivationLayerInfo::ActivationFunction act)
169{
170 static std::map<ActivationLayerInfo::ActivationFunction, const std::string> act_map =
171 {
172 { ActivationLayerInfo::ActivationFunction::ABS, "ABS" },
173 { ActivationLayerInfo::ActivationFunction::LINEAR, "LINEAR" },
174 { ActivationLayerInfo::ActivationFunction::LOGISTIC, "LOGISTIC" },
175 { ActivationLayerInfo::ActivationFunction::RELU, "RELU" },
176 { ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, "BRELU" },
Georgios Pinitas64ebe5b2017-09-01 17:44:24 +0100177 { ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, "LU_BRELU" },
Georgios Pinitas579c0492017-07-12 16:12:12 +0100178 { ActivationLayerInfo::ActivationFunction::LEAKY_RELU, "LRELU" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100179 { ActivationLayerInfo::ActivationFunction::SOFT_RELU, "SRELU" },
180 { ActivationLayerInfo::ActivationFunction::SQRT, "SQRT" },
181 { ActivationLayerInfo::ActivationFunction::SQUARE, "SQUARE" },
182 { ActivationLayerInfo::ActivationFunction::TANH, "TANH" },
Usama Arif6a98a6e2019-05-10 17:07:27 +0100183 { ActivationLayerInfo::ActivationFunction::IDENTITY, "IDENTITY" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184 };
185
186 return act_map[act];
187}
188
189const std::string &arm_compute::string_from_matrix_pattern(MatrixPattern pattern)
190{
191 static std::map<MatrixPattern, const std::string> pattern_map =
192 {
193 { MatrixPattern::BOX, "BOX" },
194 { MatrixPattern::CROSS, "CROSS" },
195 { MatrixPattern::DISK, "DISK" },
196 { MatrixPattern::OTHER, "OTHER" },
197 };
198
199 return pattern_map[pattern];
200}
201
202const std::string &arm_compute::string_from_non_linear_filter_function(NonLinearFilterFunction function)
203{
204 static std::map<NonLinearFilterFunction, const std::string> func_map =
205 {
206 { NonLinearFilterFunction::MAX, "MAX" },
207 { NonLinearFilterFunction::MEDIAN, "MEDIAN" },
208 { NonLinearFilterFunction::MIN, "MIN" },
209 };
210
211 return func_map[function];
212}
213
214const std::string &arm_compute::string_from_interpolation_policy(InterpolationPolicy policy)
215{
216 static std::map<InterpolationPolicy, const std::string> interpolation_policy_map =
217 {
218 { InterpolationPolicy::AREA, "AREA" },
219 { InterpolationPolicy::BILINEAR, "BILINEAR" },
220 { InterpolationPolicy::NEAREST_NEIGHBOR, "NEAREST_NEIGHBOUR" },
221 };
222
223 return interpolation_policy_map[policy];
224}
225
226const std::string &arm_compute::string_from_border_mode(BorderMode border_mode)
227{
228 static std::map<BorderMode, const std::string> border_mode_map =
229 {
230 { BorderMode::UNDEFINED, "UNDEFINED" },
231 { BorderMode::CONSTANT, "CONSTANT" },
232 { BorderMode::REPLICATE, "REPLICATE" },
233 };
234
235 return border_mode_map[border_mode];
236}
237
238const std::string &arm_compute::string_from_norm_type(NormType type)
239{
240 static std::map<NormType, const std::string> norm_type_map =
241 {
242 { NormType::IN_MAP_1D, "IN_MAP_1D" },
243 { NormType::IN_MAP_2D, "IN_MAP_2D" },
244 { NormType::CROSS_MAP, "CROSS_MAP" },
245 };
246
247 return norm_type_map[type];
248}
249
Georgios Pinitascdf51452017-08-31 14:21:36 +0100250const std::string &arm_compute::string_from_pooling_type(PoolingType type)
251{
252 static std::map<PoolingType, const std::string> pool_type_map =
253 {
254 { PoolingType::MAX, "MAX" },
255 { PoolingType::AVG, "AVG" },
256 { PoolingType::L2, "L2" },
257 };
258
259 return pool_type_map[type];
260}
261
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100262const std::string &arm_compute::string_from_gemmlowp_output_stage(GEMMLowpOutputStageType output_stage)
263{
264 static std::map<GEMMLowpOutputStageType, const std::string> output_stage_map =
265 {
266 { GEMMLowpOutputStageType::NONE, "" },
267 { GEMMLowpOutputStageType::QUANTIZE_DOWN, "quantize_down" },
268 { GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT, "quantize_down_fixedpoint" },
269 { GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT, "quantize_down_float" }
270 };
271
272 return output_stage_map[output_stage];
273}
274
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100275std::string arm_compute::string_from_pixel_value(const PixelValue &value, const DataType data_type)
276{
277 std::stringstream ss;
278 std::string converted_string;
279
280 switch(data_type)
281 {
282 case DataType::U8:
283 case DataType::QASYMM8:
284 // Needs conversion to 32 bit, otherwise interpreted as ASCII values
285 ss << uint32_t(value.get<uint8_t>());
286 converted_string = ss.str();
287 break;
288 case DataType::S8:
289 // Needs conversion to 32 bit, otherwise interpreted as ASCII values
290 ss << int32_t(value.get<int8_t>());
291 converted_string = ss.str();
292 break;
293 case DataType::U16:
294 ss << value.get<uint16_t>();
295 converted_string = ss.str();
296 break;
297 case DataType::S16:
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100298 case DataType::QSYMM16:
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100299 ss << value.get<int16_t>();
300 converted_string = ss.str();
301 break;
302 case DataType::U32:
303 ss << value.get<uint32_t>();
304 converted_string = ss.str();
305 break;
306 case DataType::S32:
307 ss << value.get<int32_t>();
308 converted_string = ss.str();
309 break;
310 case DataType::F32:
311 converted_string = float_to_string_with_full_precision(value.get<float>());
312 break;
313 case DataType::F16:
314 static_assert(sizeof(half) == 2, "Half must be 16 bit");
315 ss << value.get<half>();
316 converted_string = ss.str();
317 break;
318 default:
319 ARM_COMPUTE_ERROR("Not handled");
320 }
321
322 return converted_string;
323}
324
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100325std::string arm_compute::lower_string(const std::string &val)
326{
327 std::string res = val;
328 std::transform(res.begin(), res.end(), res.begin(), ::tolower);
329 return res;
330}
331
Pablo Tello01bbacb2019-04-30 10:32:42 +0100332PadStrideInfo arm_compute::calculate_same_pad(TensorShape input_shape, TensorShape weights_shape, PadStrideInfo conv_info, DataLayout data_layout, const Size2D &dilation)
Georgios Pinitas4074c992018-01-30 18:13:46 +0000333{
Isabella Gottardi6a914402019-01-30 15:45:42 +0000334 const unsigned int width_idx = arm_compute::get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
335 const unsigned int height_idx = arm_compute::get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
336 const auto &strides = conv_info.stride();
337 const int out_width = std::ceil(float(input_shape[width_idx]) / float(strides.first));
338 const int out_height = std::ceil(float(input_shape[height_idx]) / float(strides.second));
Pablo Tello01bbacb2019-04-30 10:32:42 +0100339 const int pad_width = (out_width - 1) * strides.first + (weights_shape[width_idx] + (dilation.x() - 1) * (weights_shape[width_idx] - 1) - input_shape[width_idx]);
340 const int pad_height = (out_height - 1) * strides.second + (weights_shape[height_idx] + (dilation.y() - 1) * (weights_shape[height_idx] - 1) - input_shape[height_idx]);
Isabella Gottardi6a914402019-01-30 15:45:42 +0000341 const int same_pad_left = pad_width / 2;
342 const int same_pad_top = pad_height / 2;
343 const int same_pad_right = pad_width - same_pad_left;
344 const int same_pad_bottom = pad_height - same_pad_top;
Georgios Pinitas4074c992018-01-30 18:13:46 +0000345
Pablo Tello01bbacb2019-04-30 10:32:42 +0100346 return { static_cast<unsigned int>(strides.first),
347 static_cast<unsigned int>(strides.second),
348 static_cast<unsigned int>(same_pad_left),
349 static_cast<unsigned int>(same_pad_right),
350 static_cast<unsigned int>(same_pad_top),
351 static_cast<unsigned int>(same_pad_bottom),
352 DimensionRoundingType::CEIL };
Georgios Pinitas4074c992018-01-30 18:13:46 +0000353}
354
Pablo Tello01bbacb2019-04-30 10:32:42 +0100355std::pair<unsigned int, unsigned int> arm_compute::deconvolution_output_dimensions(
Pablo Tellof5f34bb2017-08-22 13:34:13 +0100356 unsigned int in_width, unsigned int in_height, unsigned int kernel_width, unsigned int kernel_height, unsigned int padx, unsigned int pady,
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +0100357 unsigned int stride_x, unsigned int stride_y)
Pablo Tellof5f34bb2017-08-22 13:34:13 +0100358{
359 ARM_COMPUTE_ERROR_ON(in_width < 1 || in_height < 1);
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +0100360 ARM_COMPUTE_ERROR_ON(((in_width - 1) * stride_x + kernel_width) < 2 * padx);
361 ARM_COMPUTE_ERROR_ON(((in_height - 1) * stride_y + kernel_height) < 2 * pady);
362 const int w = stride_x * (in_width - 1) + kernel_width - 2 * padx;
363 const int h = stride_y * (in_height - 1) + kernel_height - 2 * pady;
364
Pablo Tellof5f34bb2017-08-22 13:34:13 +0100365 return std::make_pair<unsigned int, unsigned int>(w, h);
366}
367
Pablo Tello01bbacb2019-04-30 10:32:42 +0100368std::pair<unsigned int, unsigned int> arm_compute::scaled_dimensions(unsigned int width, unsigned int height,
369 unsigned int kernel_width, unsigned int kernel_height,
370 const PadStrideInfo &pad_stride_info,
371 const Size2D &dilation)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100372{
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100373 const unsigned int pad_left = pad_stride_info.pad_left();
374 const unsigned int pad_top = pad_stride_info.pad_top();
375 const unsigned int pad_right = pad_stride_info.pad_right();
376 const unsigned int pad_bottom = pad_stride_info.pad_bottom();
377 const unsigned int stride_x = pad_stride_info.stride().first;
378 const unsigned int stride_y = pad_stride_info.stride().second;
379 unsigned int w = 0;
380 unsigned int h = 0;
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100381 switch(pad_stride_info.round())
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100382 {
383 case DimensionRoundingType::FLOOR:
Alex Gilday7da29b62018-03-23 14:16:00 +0000384 w = static_cast<unsigned int>(std::floor((static_cast<float>(width + pad_left + pad_right - (dilation.x() * (kernel_width - 1) + 1)) / stride_x) + 1));
385 h = static_cast<unsigned int>(std::floor((static_cast<float>(height + pad_top + pad_bottom - (dilation.y() * (kernel_height - 1) + 1)) / stride_y) + 1));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100386 break;
387 case DimensionRoundingType::CEIL:
Alex Gilday7da29b62018-03-23 14:16:00 +0000388 w = static_cast<unsigned int>(std::ceil((static_cast<float>(width + pad_left + pad_right - (dilation.x() * (kernel_width - 1) + 1)) / stride_x) + 1));
389 h = static_cast<unsigned int>(std::ceil((static_cast<float>(height + pad_top + pad_bottom - (dilation.y() * (kernel_height - 1) + 1)) / stride_y) + 1));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100390 break;
391 default:
392 ARM_COMPUTE_ERROR("Unsupported rounding type");
393 }
394
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100395 return std::make_pair(w, h);
396}
397
giuros01edc21e42018-11-16 14:45:31 +0000398#ifdef ARM_COMPUTE_ASSERTS_ENABLED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100399void 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)
400{
401 switch(dt)
402 {
Georgios Pinitas55186712018-01-08 17:37:12 +0000403 case DataType::QASYMM8:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100404 case DataType::U8:
405 print_consecutive_elements_impl<uint8_t>(s, ptr, n, stream_width, element_delim);
406 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100407 case DataType::S8:
408 print_consecutive_elements_impl<int8_t>(s, reinterpret_cast<const int8_t *>(ptr), n, stream_width, element_delim);
409 break;
410 case DataType::U16:
411 print_consecutive_elements_impl<uint16_t>(s, reinterpret_cast<const uint16_t *>(ptr), n, stream_width, element_delim);
412 break;
413 case DataType::S16:
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100414 case DataType::QSYMM16:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100415 print_consecutive_elements_impl<int16_t>(s, reinterpret_cast<const int16_t *>(ptr), n, stream_width, element_delim);
416 break;
417 case DataType::U32:
418 print_consecutive_elements_impl<uint32_t>(s, reinterpret_cast<const uint32_t *>(ptr), n, stream_width, element_delim);
419 break;
420 case DataType::S32:
421 print_consecutive_elements_impl<int32_t>(s, reinterpret_cast<const int32_t *>(ptr), n, stream_width, element_delim);
422 break;
423 case DataType::F32:
424 print_consecutive_elements_impl<float>(s, reinterpret_cast<const float *>(ptr), n, stream_width, element_delim);
425 break;
426 case DataType::F16:
Anthony Barbier7068f992017-10-26 15:23:08 +0100427 print_consecutive_elements_impl<half>(s, reinterpret_cast<const half *>(ptr), n, stream_width, element_delim);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100428 break;
429 default:
430 ARM_COMPUTE_ERROR("Undefined element size for given data type");
431 }
432}
433
434int arm_compute::max_consecutive_elements_display_width(std::ostream &s, DataType dt, const uint8_t *ptr, unsigned int n)
435{
436 switch(dt)
437 {
Georgios Pinitas55186712018-01-08 17:37:12 +0000438 case DataType::QASYMM8:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100439 case DataType::U8:
440 return max_consecutive_elements_display_width_impl<uint8_t>(s, ptr, n);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100441 case DataType::S8:
442 return max_consecutive_elements_display_width_impl<int8_t>(s, reinterpret_cast<const int8_t *>(ptr), n);
443 case DataType::U16:
444 return max_consecutive_elements_display_width_impl<uint16_t>(s, reinterpret_cast<const uint16_t *>(ptr), n);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100445 case DataType::S16:
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100446 case DataType::QSYMM16:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100447 return max_consecutive_elements_display_width_impl<int16_t>(s, reinterpret_cast<const int16_t *>(ptr), n);
448 case DataType::U32:
449 return max_consecutive_elements_display_width_impl<uint32_t>(s, reinterpret_cast<const uint32_t *>(ptr), n);
450 case DataType::S32:
451 return max_consecutive_elements_display_width_impl<int32_t>(s, reinterpret_cast<const int32_t *>(ptr), n);
452 case DataType::F32:
453 return max_consecutive_elements_display_width_impl<float>(s, reinterpret_cast<const float *>(ptr), n);
454 case DataType::F16:
Anthony Barbier7068f992017-10-26 15:23:08 +0100455 return max_consecutive_elements_display_width_impl<half>(s, reinterpret_cast<const half *>(ptr), n);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100456 default:
457 ARM_COMPUTE_ERROR("Undefined element size for given data type");
458 }
Georgios Pinitas3faea252017-10-30 14:13:50 +0000459 return 0;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100460}
giuros01edc21e42018-11-16 14:45:31 +0000461#endif /* ARM_COMPUTE_ASSERTS_ENABLED */