diff options
author | Ferran Balaguer <ferran.balaguer@arm.com> | 2019-02-08 17:09:55 +0000 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-02-11 08:48:53 +0000 |
commit | c602f29d57f34b6bf0805d379b2174667d8bf52f (patch) | |
tree | 50cdc475ec8732575c0cf2c56d4ced770215c4a2 /tests/InferenceTest.inl | |
parent | 9c5d33a26ebc4be391ae4da9de584be2e453c78f (diff) | |
download | armnn-c602f29d57f34b6bf0805d379b2174667d8bf52f.tar.gz |
IVGCVSW-2529 DeepSpeech v1 test
Change-Id: Ieb99ac1aa347cee4b28b831753855c4614220648
Diffstat (limited to 'tests/InferenceTest.inl')
-rw-r--r-- | tests/InferenceTest.inl | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/tests/InferenceTest.inl b/tests/InferenceTest.inl index 07a20d5a13..538720bd83 100644 --- a/tests/InferenceTest.inl +++ b/tests/InferenceTest.inl @@ -28,6 +28,7 @@ namespace armnn namespace test { +using TContainer = boost::variant<std::vector<float>, std::vector<int>, std::vector<unsigned char>>; template <typename TTestCaseDatabase, typename TModel> ClassifierTestCase<TTestCaseDatabase, TModel>::ClassifierTestCase( @@ -39,7 +40,8 @@ ClassifierTestCase<TTestCaseDatabase, TModel>::ClassifierTestCase( unsigned int testCaseId, unsigned int label, std::vector<typename TModel::DataType> modelInput) - : InferenceModelTestCase<TModel>(model, testCaseId, { std::move(modelInput) }, { model.GetOutputSize() }) + : InferenceModelTestCase<TModel>( + model, testCaseId, std::vector<TContainer>{ modelInput }, { model.GetOutputSize() }) , m_Label(label) , m_QuantizationParams(model.GetQuantizationParams()) , m_NumInferencesRef(numInferencesRef) @@ -58,21 +60,26 @@ TestCaseResult ClassifierTestCase<TTestCaseDatabase, TModel>::ProcessResult(cons std::map<float,int> resultMap; { int index = 0; - for (const auto & o : output) - { - 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)); - } - } + + boost::apply_visitor([&](auto&& value) + { + for (const auto & o : value) + { + 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)); + } + } + }, + output); } { @@ -86,8 +93,13 @@ TestCaseResult ClassifierTestCase<TTestCaseDatabase, TModel>::ProcessResult(cons } } - const unsigned int prediction = boost::numeric_cast<unsigned int>( - std::distance(output.begin(), std::max_element(output.begin(), output.end()))); + unsigned int prediction = 0; + boost::apply_visitor([&](auto&& value) + { + prediction = boost::numeric_cast<unsigned int>( + std::distance(value.begin(), std::max_element(value.begin(), value.end()))); + }, + output); // If we're just running the defaultTestCaseIds, each one must be classified correctly. if (params.m_IterationCount == 0 && prediction != m_Label) |