aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Lamberti <derek.lamberti@arm.com>2019-05-14 16:55:25 +0100
committerDerek Lamberti <derek.lamberti@arm.com>2019-05-14 16:55:43 +0100
commitda47048a4ec5c7deaa29ff0313c42163993119de (patch)
tree6c4093b270d2a823549bc9bf384f79443f7a320a
parentfc598e15ff30bc375c95c9536d4a56662d867926 (diff)
downloadarmnn-da47048a4ec5c7deaa29ff0313c42163993119de.tar.gz
IVGCVSW-3001 Dequantize the output prior to printing
Change-Id: Ibd5fb4ad102aec1f71ab99402a3e3a08b04b926b Signed-off-by: Derek Lamberti <derek.lamberti@arm.com>
-rw-r--r--tests/ExecuteNetwork/ExecuteNetwork.cpp65
1 files changed, 55 insertions, 10 deletions
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index 1de22ed5d0..8ca69d8292 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -191,6 +191,57 @@ void RemoveDuplicateDevices(std::vector<armnn::BackendId>& computeDevices)
computeDevices.end());
}
+struct TensorPrinter : public boost::static_visitor<>
+{
+ TensorPrinter(const std::string& binding, const armnn::TensorInfo& info)
+ : m_OutputBinding(binding)
+ , m_Scale(info.GetQuantizationScale())
+ , m_Offset(info.GetQuantizationOffset())
+ {}
+
+ void operator()(const std::vector<float>& values)
+ {
+ ForEachValue(values, [](float value){
+ printf("%f ", value);
+ });
+ }
+
+ void operator()(const std::vector<uint8_t>& values)
+ {
+ auto& scale = m_Scale;
+ auto& offset = m_Offset;
+ ForEachValue(values, [&scale, &offset](uint8_t value)
+ {
+ printf("%f ", armnn::Dequantize(value, scale, offset));
+ });
+ }
+
+ void operator()(const std::vector<int>& values)
+ {
+ ForEachValue(values, [](int value)
+ {
+ printf("%d ", value);
+ });
+ }
+
+private:
+ template<typename Container, typename Delegate>
+ void ForEachValue(const Container& c, Delegate delegate)
+ {
+ std::cout << m_OutputBinding << ": ";
+ for (const auto& value : c)
+ {
+ delegate(value);
+ }
+ printf("\n");
+ }
+
+ std::string m_OutputBinding;
+ float m_Scale=0.0f;
+ int m_Offset=0;
+};
+
+
} // namespace
template<typename TParser, typename TDataType>
@@ -299,18 +350,12 @@ int MainImpl(const char* modelPath,
auto inference_duration = model.Run(inputDataContainers, outputDataContainers);
// Print output tensors
+ const auto& infosOut = model.GetOutputBindingInfos();
for (size_t i = 0; i < numOutputs; i++)
{
- boost::apply_visitor([&](auto&& value)
- {
- std::cout << params.m_OutputBindings[i] << ": ";
- for (size_t i = 0; i < value.size(); ++i)
- {
- printf("%f ", static_cast<float>(value[i]));
- }
- printf("\n");
- },
- outputDataContainers[i]);
+ const armnn::TensorInfo& infoOut = infosOut[i].second;
+ TensorPrinter printer(params.m_OutputBindings[i], infoOut);
+ boost::apply_visitor(printer, outputDataContainers[i]);
}
BOOST_LOG_TRIVIAL(info) << "\nInference time: " << std::setprecision(2)