MCPcopy Create free account
hub / github.com/ARM-software/armnn / decodeOutput

Method decodeOutput

samples/KeywordSpotting/src/Decoder.cpp:8–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "Decoder.hpp"
7
8std::pair<int, float> kws::Decoder::decodeOutput(std::vector<int8_t>& modelOutput)
9{
10
11 std::vector<float> dequantisedOutput;
12 //Normalise vector values into new vector
13 for (auto& value : modelOutput)
14 {
15 float normalisedModelOutput = this->quantisationScale * (static_cast<float >(value) -
16 static_cast<float >(this->quantisationOffset));
17 dequantisedOutput.push_back(normalisedModelOutput);
18 }
19
20 //Get largest value in modelOutput
21 const std::vector<float>::iterator& maxElementIterator = std::max_element(dequantisedOutput.begin(),
22 dequantisedOutput.end());
23 //Find the labelMapIndex of the largest value which corresponds to a key in a label map
24 int labelMapIndex = static_cast<int>(std::distance(dequantisedOutput.begin(), maxElementIterator));
25
26 //Round to two DP
27 float maxModelOutputProbability = std::roundf((*maxElementIterator) * 100) / 100;
28
29 return std::make_pair(labelMapIndex, maxModelOutputProbability);
30
31}
32
33
34

Callers 2

DecoderTest.cppFile · 0.80
PostProcessingMethod · 0.80

Calls 4

roundfFunction · 0.85
push_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected