From b1ba1e33f2b03b211f561123559c24517c0e5865 Mon Sep 17 00:00:00 2001 From: ramelg01 Date: Sat, 25 Sep 2021 11:53:26 +0100 Subject: FIX: seg fault when printing TensorInfo's quantization info per channel Resolves: COMPMID-4818 Signed-off-by: Ramy Elgammal Change-Id: I2ac4b84181a1b432aa34e22b9ffa9a1c882a32aa Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6319 Tested-by: Arm Jenkins Reviewed-by: Pablo Marquez Tello Comments-Addressed: Arm Jenkins --- utils/TypePrinter.h | 105 +++++++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 47 deletions(-) (limited to 'utils/TypePrinter.h') diff --git a/utils/TypePrinter.h b/utils/TypePrinter.h index c3641028a6..23df2dc20c 100644 --- a/utils/TypePrinter.h +++ b/utils/TypePrinter.h @@ -67,6 +67,45 @@ std::string to_string_if_not_null(T *arg) } } +/** Formatted output of a vector of objects. + * + * @param[out] os Output stream + * @param[in] args Vector of objects to print + * + * @return Modified output stream. + */ +template +inline ::std::ostream &operator<<(::std::ostream &os, const std::vector &args) +{ + const size_t max_print_size = 5U; + + os << "["; + bool first = true; + size_t i; + for(i = 0; i < args.size(); ++i) + { + if(i == max_print_size) + { + break; + } + if(first) + { + first = false; + } + else + { + os << ", "; + } + os << args[i]; + } + if(i < args.size()) + { + os << ", ..."; + } + os << "]"; + return os; +} + /** Formatted output of the Dimensions type. * * @param[out] os Output stream. @@ -1037,25 +1076,16 @@ inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info) if(is_data_type_quantized(data_type)) { - const QuantizationInfo qinfo = info->quantization_info(); - os << "QuantizationInfo="; - if(is_data_type_quantized_per_channel(data_type)) - { - os << "["; - const auto scales = qinfo.scale(); - const auto offsets = qinfo.offset(); - os << "(" << scales[0] << ", " << offsets[0] << ")"; - for(size_t i = 1; i < scales.size(); ++i) - { - os << ",(" << scales[i] << ", " << offsets[i] << ")"; - } - os << "]"; - } - else - { - os << "(" << qinfo.uniform().scale << ", " - << qinfo.uniform().offset << ")"; - } + const QuantizationInfo qinfo = info->quantization_info(); + const auto scales = qinfo.scale(); + const auto offsets = qinfo.offset(); + + os << "QuantizationInfo={" + << "scales.size=" << scales.size() + << ", scale(s)=" << scales << ", "; + + os << "offsets.size=" << offsets.size() + << ", offset(s)=" << offsets << "}"; } return os; } @@ -1773,9 +1803,18 @@ inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op case ElementWiseUnary::LOG: os << "LOG"; break; + case ElementWiseUnary::SIN: + os << "SIN"; + break; + case ElementWiseUnary::ABS: + os << "ABS"; + break; case ElementWiseUnary::ROUND: os << "ROUND"; break; + case ElementWiseUnary::LOGICAL_NOT: + os << "LOGICAL_NOT"; + break; default: ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); } @@ -2179,34 +2218,6 @@ inline std::string to_string(const DetectionWindow &detection_window) return str.str(); } -/** Formatted output of a vector of objects. - * - * @param[out] os Output stream - * @param[in] args Vector of objects to print - * - * @return Modified output stream. - */ -template -inline ::std::ostream &operator<<(::std::ostream &os, const std::vector &args) -{ - os << "["; - bool first = true; - for(auto &arg : args) - { - if(first) - { - first = false; - } - else - { - os << ", "; - } - os << arg; - } - os << "]"; - return os; -} - /** Formatted output of @ref PriorBoxLayerInfo. * * @param[out] os Output stream. -- cgit v1.2.1