aboutsummaryrefslogtreecommitdiff
path: root/utils/TypePrinter.h
diff options
context:
space:
mode:
authorramelg01 <ramy.elgammal@arm.com>2021-09-25 11:53:26 +0100
committerPablo Marquez Tello <pablo.tello@arm.com>2021-09-29 06:46:59 +0000
commitb1ba1e33f2b03b211f561123559c24517c0e5865 (patch)
treec74c2b9ba5152547175d71db460e7bdf6d887f72 /utils/TypePrinter.h
parent2e53f17f4f3c9179455c05d49a47a236067e00c0 (diff)
downloadComputeLibrary-b1ba1e33f2b03b211f561123559c24517c0e5865.tar.gz
FIX: seg fault when printing TensorInfo's quantization info per channel
Resolves: COMPMID-4818 Signed-off-by: Ramy Elgammal <ramy.elgammal@arm.com> Change-Id: I2ac4b84181a1b432aa34e22b9ffa9a1c882a32aa Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6319 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'utils/TypePrinter.h')
-rw-r--r--utils/TypePrinter.h105
1 files changed, 58 insertions, 47 deletions
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 <typename T>
+inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &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 <typename T>
-inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &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.