2 * Copyright (c) 2017 ARM Limited.
4 * SPDX-License-Identifier: MIT
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:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
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
24 #ifndef __ARM_COMPUTE_TEST_TYPE_PRINTER_H__
25 #define __ARM_COMPUTE_TEST_TYPE_PRINTER_H__
27 #include "arm_compute/core/Dimensions.h"
28 #include "arm_compute/core/Error.h"
29 #include "arm_compute/core/Types.h"
37 /** Formatted output of the Dimensions type. */
39 inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
41 if(dimensions.num_dimensions() > 0)
45 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
47 os << "x" << dimensions[d];
54 /** Formatted output of the NonLinearFilterFunction type. */
55 inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
59 case NonLinearFilterFunction::MAX:
62 case NonLinearFilterFunction::MEDIAN:
65 case NonLinearFilterFunction::MIN:
69 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
75 inline std::string to_string(const NonLinearFilterFunction &function)
77 std::stringstream str;
82 /** Formatted output of the MatrixPattern type. */
83 inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
87 case MatrixPattern::BOX:
90 case MatrixPattern::CROSS:
93 case MatrixPattern::DISK:
96 case MatrixPattern::OTHER:
100 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
106 inline std::string to_string(const MatrixPattern &pattern)
108 std::stringstream str;
113 /** Formatted output of the RoundingPolicy type. */
114 inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
116 switch(rounding_policy)
118 case RoundingPolicy::TO_ZERO:
121 case RoundingPolicy::TO_NEAREST_UP:
122 os << "TO_NEAREST_UP";
124 case RoundingPolicy::TO_NEAREST_EVEN:
125 os << "TO_NEAREST_EVEN";
128 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
134 /** Formatted output of the WeightsInfo type. */
135 inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
137 os << weights_info.are_reshaped() << ";";
138 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
143 /** Formatted output of the ROIPoolingInfo type. */
144 inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
146 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
150 /** Formatted output of the activation function type. */
151 inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
155 case ActivationLayerInfo::ActivationFunction::ABS:
158 case ActivationLayerInfo::ActivationFunction::LINEAR:
161 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
164 case ActivationLayerInfo::ActivationFunction::RELU:
167 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
168 os << "BOUNDED_RELU";
170 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
173 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
176 case ActivationLayerInfo::ActivationFunction::SQRT:
179 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
180 os << "LU_BOUNDED_RELU";
181 case ActivationLayerInfo::ActivationFunction::SQUARE:
184 case ActivationLayerInfo::ActivationFunction::TANH:
188 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
194 inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
196 std::stringstream str;
197 str << info.activation();
201 inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
203 std::stringstream str;
208 /** Formatted output of the NormType type. */
209 inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
213 case NormType::CROSS_MAP:
216 case NormType::IN_MAP_1D:
219 case NormType::IN_MAP_2D:
223 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
229 inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
231 std::stringstream str;
236 /** Formatted output of the PoolingType type. */
237 inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
241 case PoolingType::AVG:
244 case PoolingType::MAX:
247 case PoolingType::L2:
251 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
257 /** Formatted output of @ref PoolingLayerInfo. */
258 inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
260 os << info.pool_type();
265 /** Formatted output of the DataType type. */
266 inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
270 case DataType::UNKNOWN:
312 case DataType::SIZET:
316 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
322 inline std::string to_string(const arm_compute::DataType &data_type)
324 std::stringstream str;
329 /** Formatted output of the Format type. */
330 inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
334 case Format::UNKNOWN:
364 case Format::RGBA8888:
370 case Format::YUYV422:
382 case Format::UYVY422:
386 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
392 inline std::string to_string(const Format &format)
394 std::stringstream str;
399 /** Formatted output of the Channel type. */
400 inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
404 case Channel::UNKNOWN:
441 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
447 /** Formatted output of the BorderMode type. */
448 inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
452 case BorderMode::UNDEFINED:
455 case BorderMode::CONSTANT:
458 case BorderMode::REPLICATE:
462 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
468 /** Formatted output of the BorderSize type. */
469 inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
471 os << border.top << ","
472 << border.right << ","
473 << border.bottom << ","
479 /** Formatted output of the InterpolationPolicy type. */
480 inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
484 case InterpolationPolicy::NEAREST_NEIGHBOR:
485 os << "NEAREST_NEIGHBOR";
487 case InterpolationPolicy::BILINEAR:
490 case InterpolationPolicy::AREA:
494 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
500 template <typename T>
501 inline std::string to_string(const Dimensions<T> &dimensions)
503 std::stringstream str;
508 /** Formatted output of the TensorShape type. */
509 inline std::string to_string(const TensorShape &shape)
511 std::stringstream str;
516 /** Formatted output of the Rectangle type. */
517 inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
519 os << rect.width << "x" << rect.height;
520 os << "+" << rect.x << "+" << rect.y;
525 /** Formatted output of the PadStridInfo type. */
526 inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
528 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
530 os << pad_stride_info.pad().first << "," << pad_stride_info.pad().second;
535 inline std::string to_string(const PadStrideInfo &pad_stride_info)
537 std::stringstream str;
538 str << pad_stride_info;
542 inline std::string to_string(const BorderMode &mode)
544 std::stringstream str;
549 inline std::string to_string(const InterpolationPolicy &policy)
551 std::stringstream str;
556 /** Formatted output of the ConversionPolicy type. */
557 inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
561 case ConvertPolicy::WRAP:
564 case ConvertPolicy::SATURATE:
568 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
574 inline std::string to_string(const ConvertPolicy &policy)
576 std::stringstream str;
581 /** Formatted output of the Reduction Operations. */
582 inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
586 case ReductionOperation::SUM_SQUARE:
590 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
596 inline std::string to_string(const ReductionOperation &op)
598 std::stringstream str;
603 inline std::string to_string(const NormType &type)
605 std::stringstream str;
610 inline std::string to_string(const PoolingType &type)
612 std::stringstream str;
617 inline std::string to_string(const PoolingLayerInfo &info)
619 std::stringstream str;
620 str << info.pool_type();
624 /** Formatted output of the KeyPoint type. */
625 inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
627 os << "{x=" << point.x << ","
628 << "y=" << point.y << ","
629 << "strength=" << point.strength << ","
630 << "scale=" << point.scale << ","
631 << "orientation=" << point.orientation << ","
632 << "tracking_status=" << point.tracking_status << ","
633 << "error=" << point.error << "}";
637 } // namespace arm_compute
638 #endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */