ArmNN
 21.02
TensorPrinter Struct Reference

#include <NetworkExecutionUtils.hpp>

Public Member Functions

 TensorPrinter (const std::string &binding, const armnn::TensorInfo &info, const std::string &outputTensorFile, bool dequantizeOutput)
 
void operator() (const std::vector< float > &values)
 
void operator() (const std::vector< uint8_t > &values)
 
void operator() (const std::vector< int > &values)
 

Detailed Description

Definition at line 24 of file NetworkExecutionUtils.hpp.

Constructor & Destructor Documentation

◆ TensorPrinter()

TensorPrinter ( const std::string &  binding,
const armnn::TensorInfo info,
const std::string &  outputTensorFile,
bool  dequantizeOutput 
)

Definition at line 92 of file NetworkExecutionUtils.cpp.

96  : m_OutputBinding(binding)
97  , m_Scale(info.GetQuantizationScale())
98  , m_Offset(info.GetQuantizationOffset())
99  , m_OutputTensorFile(outputTensorFile)
100  , m_DequantizeOutput(dequantizeOutput) {}
int32_t GetQuantizationOffset() const
Definition: Tensor.cpp:469
float GetQuantizationScale() const
Definition: Tensor.cpp:452

Member Function Documentation

◆ operator()() [1/3]

void operator() ( const std::vector< float > &  values)

Definition at line 102 of file NetworkExecutionUtils.cpp.

Referenced by operator()().

103 {
104  ForEachValue(values, [](float value)
105  {
106  printf("%f ", value);
107  });
108  WriteToFile(values);
109 }

◆ operator()() [2/3]

void operator() ( const std::vector< uint8_t > &  values)

Definition at line 111 of file NetworkExecutionUtils.cpp.

References armnn::Dequantize(), and operator()().

112 {
113  if(m_DequantizeOutput)
114  {
115  auto& scale = m_Scale;
116  auto& offset = m_Offset;
117  std::vector<float> dequantizedValues;
118  ForEachValue(values, [&scale, &offset, &dequantizedValues](uint8_t value)
119  {
120  auto dequantizedValue = armnn::Dequantize(value, scale, offset);
121  printf("%f ", dequantizedValue);
122  dequantizedValues.push_back(dequantizedValue);
123  });
124  WriteToFile(dequantizedValues);
125  }
126  else
127  {
128  const std::vector<int> intValues(values.begin(), values.end());
129  operator()(intValues);
130  }
131 }
float Dequantize(QuantizedType value, float scale, int32_t offset)
Dequantize an 8-bit data type into a floating point data type.
Definition: TypesUtils.cpp:46
void operator()(const std::vector< float > &values)

◆ operator()() [3/3]

void operator() ( const std::vector< int > &  values)

Definition at line 133 of file NetworkExecutionUtils.cpp.

References ARMNN_LOG.

134 {
135  ForEachValue(values, [](int value)
136  {
137  printf("%d ", value);
138  });
139  WriteToFile(values);
140 }

The documentation for this struct was generated from the following files: