aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/InferenceTest.inl13
-rw-r--r--tests/TfLiteVGG16Quantized-Armnn/TfLiteVGG16Quantized-Armnn.cpp1
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/InferenceTest.inl b/tests/InferenceTest.inl
index 5e858f06d3..7ce017c6cd 100644
--- a/tests/InferenceTest.inl
+++ b/tests/InferenceTest.inl
@@ -60,7 +60,18 @@ TestCaseResult ClassifierTestCase<TTestCaseDatabase, TModel>::ProcessResult(cons
int index = 0;
for (const auto & o : output)
{
- resultMap[ToFloat<typename TModel::DataType>::Convert(o, m_QuantizationParams)] = index++;
+ float prob = ToFloat<typename TModel::DataType>::Convert(o, m_QuantizationParams);
+ int classification = index++;
+
+ // Take the first class with each probability
+ // This avoids strange results when looping over batched results produced
+ // with identical test data.
+ std::map<float, int>::iterator lb = resultMap.lower_bound(prob);
+ if (lb == resultMap.end() ||
+ !resultMap.key_comp()(prob, lb->first)) {
+ // If the key is not already in the map, insert it.
+ resultMap.insert(lb, std::map<float, int>::value_type(prob, classification));
+ }
}
}
diff --git a/tests/TfLiteVGG16Quantized-Armnn/TfLiteVGG16Quantized-Armnn.cpp b/tests/TfLiteVGG16Quantized-Armnn/TfLiteVGG16Quantized-Armnn.cpp
index 1313d2d01a..acaabe4487 100644
--- a/tests/TfLiteVGG16Quantized-Armnn/TfLiteVGG16Quantized-Armnn.cpp
+++ b/tests/TfLiteVGG16Quantized-Armnn/TfLiteVGG16Quantized-Armnn.cpp
@@ -16,7 +16,6 @@ int main(int argc, char* argv[])
// Coverity fix: The following code may throw an exception of type std::length_error.
std::vector<ImageSet> imageSet =
{
- // Class number in probability print out offset by 1000 due to batch size fix
{"Dog.jpg", 669},
{"Cat.jpg", 669},
{"shark.jpg", 669},