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

Method ProcessResult

tests/YoloInferenceTest.hpp:32–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 virtual TestCaseResult ProcessResult(const InferenceTestOptions& options) override
33 {
34 armnn::IgnoreUnused(options);
35
36 const std::vector<float>& output = mapbox::util::get<std::vector<float>>(this->GetOutputs()[0]);
37 ARMNN_ASSERT(output.size() == YoloOutputSize);
38
39 constexpr unsigned int gridSize = 7;
40 constexpr unsigned int numClasses = 20;
41 constexpr unsigned int numScales = 2;
42
43 const float* outputPtr = output.data();
44
45 // Range 0-980. Class probabilities. 7x7x20
46 vector<vector<vector<float>>> classProbabilities(gridSize, vector<vector<float>>(gridSize,
47 vector<float>(numClasses)));
48 for (unsigned int y = 0; y < gridSize; ++y)
49 {
50 for (unsigned int x = 0; x < gridSize; ++x)
51 {
52 for (unsigned int c = 0; c < numClasses; ++c)
53 {
54 classProbabilities[y][x][c] = *outputPtr++;
55 }
56 }
57 }
58
59 // Range 980-1078. Scales. 7x7x2
60 vector<vector<vector<float>>> scales(gridSize, vector<vector<float>>(gridSize, vector<float>(numScales)));
61 for (unsigned int y = 0; y < gridSize; ++y)
62 {
63 for (unsigned int x = 0; x < gridSize; ++x)
64 {
65 for (unsigned int s = 0; s < numScales; ++s)
66 {
67 scales[y][x][s] = *outputPtr++;
68 }
69 }
70 }
71
72 // Range 1078-1469. Bounding boxes. 7x7x2x4
73 constexpr float imageWidthAsFloat = static_cast<float>(YoloImageWidth);
74 constexpr float imageHeightAsFloat = static_cast<float>(YoloImageHeight);
75
76 vector<vector<vector<vector<float>>>> boxes(gridSize, vector<vector<vector<float>>>
77 (gridSize, vector<vector<float>>(numScales, vector<float>(4))));
78 for (unsigned int y = 0; y < gridSize; ++y)
79 {
80 for (unsigned int x = 0; x < gridSize; ++x)
81 {
82 for (unsigned int s = 0; s < numScales; ++s)
83 {
84 float bx = *outputPtr++;
85 float by = *outputPtr++;
86 float bw = *outputPtr++;
87 float bh = *outputPtr++;
88
89 boxes[y][x][s][0] = ((bx + static_cast<float>(x)) / 7.0f) * imageWidthAsFloat;

Callers 1

InferenceTestFunction · 0.45

Calls 9

GetTestCaseIdMethod · 0.80
IgnoreUnusedFunction · 0.50
GetOutputsMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
reserveMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected