diff options
author | Jan Eilers <jan.eilers@arm.com> | 2021-09-07 12:46:15 +0100 |
---|---|---|
committer | Jan Eilers <jan.eilers@arm.com> | 2021-09-13 10:05:00 +0100 |
commit | 284b5d19c8cf446b7eec16ea560c544ac39008c1 (patch) | |
tree | 8a4d34db3fff091bacd15b004b9c6e6e4b8248ba /tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp | |
parent | 65d5d2ddf77c69e76643e40440aa986defe6d0d7 (diff) | |
download | armnn-284b5d19c8cf446b7eec16ea560c544ac39008c1.tar.gz |
Add 'do-not-print-output' option to ExNet
Signed-off-by: Jan Eilers <jan.eilers@arm.com>
Change-Id: I10fb010ee8d3f813d2264cefb526f352e30d7046
Diffstat (limited to 'tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp')
-rw-r--r-- | tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp b/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp index 0906c1cf3f..da3188c1e7 100644 --- a/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp +++ b/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp @@ -116,19 +116,26 @@ std::vector<std::string> ParseStringList(const std::string& inputString, const c TensorPrinter::TensorPrinter(const std::string& binding, const armnn::TensorInfo& info, const std::string& outputTensorFile, - bool dequantizeOutput) + bool dequantizeOutput, + const bool printToConsole) : m_OutputBinding(binding) , m_Scale(info.GetQuantizationScale()) , m_Offset(info.GetQuantizationOffset()) , m_OutputTensorFile(outputTensorFile) - , m_DequantizeOutput(dequantizeOutput) {} + , m_DequantizeOutput(dequantizeOutput) + , m_PrintToConsole(printToConsole) {} void TensorPrinter::operator()(const std::vector<float>& values) { - ForEachValue(values, [](float value) + if (m_PrintToConsole) { - printf("%f ", value); - }); + std::cout << m_OutputBinding << ": "; + ForEachValue(values, [](float value) + { + printf("%f ", value); + }); + printf("\n"); + } WriteToFile(values); } @@ -142,9 +149,19 @@ void TensorPrinter::operator()(const std::vector<uint8_t>& values) ForEachValue(values, [&scale, &offset, &dequantizedValues](uint8_t value) { auto dequantizedValue = armnn::Dequantize(value, scale, offset); - printf("%f ", dequantizedValue); dequantizedValues.push_back(dequantizedValue); }); + + if (m_PrintToConsole) + { + std::cout << m_OutputBinding << ": "; + ForEachValue(dequantizedValues, [](float value) + { + printf("%f ", value); + }); + printf("\n"); + } + WriteToFile(dequantizedValues); } else @@ -156,31 +173,47 @@ void TensorPrinter::operator()(const std::vector<uint8_t>& values) void TensorPrinter::operator()(const std::vector<int8_t>& values) { - ForEachValue(values, [](int8_t value) + if (m_PrintToConsole) { - printf("%d ", value); - }); + std::cout << m_OutputBinding << ": "; + ForEachValue(values, [](int8_t value) + { + printf("%d ", value); + }); + printf("\n"); + } WriteToFile(values); } void TensorPrinter::operator()(const std::vector<int>& values) { - ForEachValue(values, [](int value) + if (m_PrintToConsole) { - printf("%d ", value); - }); + std::cout << m_OutputBinding << ": "; + ForEachValue(values, [](int value) + { + printf("%d ", value); + }); + printf("\n"); + } WriteToFile(values); } template<typename Container, typename Delegate> void TensorPrinter::ForEachValue(const Container& c, Delegate delegate) { - std::cout << m_OutputBinding << ": "; + if (m_PrintToConsole) + { + std::cout << m_OutputBinding << ": "; + } for (const auto& value : c) { delegate(value); } - printf("\n"); + if (m_PrintToConsole) + { + printf("\n"); + } } template<typename T> |