From 549b9600a6eaf0727fa084465a75f173edf8f381 Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Tue, 24 May 2022 11:32:07 +0100 Subject: Update 22.05 Doxygen Docs after updates to main Readme Signed-off-by: Nikhil Raj Change-Id: I56711772406a41ff81fa136a5fb6c59c9b9cf504 --- ...assarmnn_1_1test_1_1_classifier_test_case.xhtml | 272 +++++++++++++++++++++ 1 file changed, 272 insertions(+) create mode 100644 22.05/classarmnn_1_1test_1_1_classifier_test_case.xhtml (limited to '22.05/classarmnn_1_1test_1_1_classifier_test_case.xhtml') diff --git a/22.05/classarmnn_1_1test_1_1_classifier_test_case.xhtml b/22.05/classarmnn_1_1test_1_1_classifier_test_case.xhtml new file mode 100644 index 0000000000..57c4f737cd --- /dev/null +++ b/22.05/classarmnn_1_1test_1_1_classifier_test_case.xhtml @@ -0,0 +1,272 @@ + + + + + + + + + + + + + +ArmNN: ClassifierTestCase< TTestCaseDatabase, TModel > Class Template Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  22.05 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
ClassifierTestCase< TTestCaseDatabase, TModel > Class Template Reference
+
+
+ +

#include <InferenceTest.hpp>

+
+Inheritance diagram for ClassifierTestCase< TTestCaseDatabase, TModel >:
+
+
+ + +InferenceModelTestCase< TModel > +IInferenceTestCase + +
+ + + + + + + + + + + + + + +

+Public Member Functions

 ClassifierTestCase (int &numInferencesRef, int &numCorrectInferencesRef, const std::vector< unsigned int > &validationPredictions, std::vector< unsigned int > *validationPredictionsOut, TModel &model, unsigned int testCaseId, unsigned int label, std::vector< typename TModel::DataType > modelInput)
 
virtual TestCaseResult ProcessResult (const InferenceTestOptions &params) override
 
- Public Member Functions inherited from InferenceModelTestCase< TModel >
 InferenceModelTestCase (TModel &model, unsigned int testCaseId, const std::vector< armnnUtils::TContainer > &inputs, const std::vector< unsigned int > &outputSizes)
 
virtual void Run () override
 
- Public Member Functions inherited from IInferenceTestCase
virtual ~IInferenceTestCase ()
 
+ + + + + + +

+Additional Inherited Members

- Protected Member Functions inherited from InferenceModelTestCase< TModel >
unsigned int GetTestCaseId () const
 
const std::vector< armnnUtils::TContainer > & GetOutputs () const
 
+

Detailed Description

+

template<typename TTestCaseDatabase, typename TModel>
+class armnn::test::ClassifierTestCase< TTestCaseDatabase, TModel >

+ + +

Definition at line 151 of file InferenceTest.hpp.

+

Constructor & Destructor Documentation

+ +

◆ ClassifierTestCase()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClassifierTestCase (int & numInferencesRef,
int & numCorrectInferencesRef,
const std::vector< unsigned int > & validationPredictions,
std::vector< unsigned int > * validationPredictionsOut,
TModel & model,
unsigned int testCaseId,
unsigned int label,
std::vector< typename TModel::DataType > modelInput 
)
+
+ +

Definition at line 33 of file InferenceTest.inl.

+ +

References ARMNN_ASSERT_MSG, armnn::Dequantize, and armnn::IgnoreUnused().

+
43  model, testCaseId, std::vector<armnnUtils::TContainer>{ modelInput }, { model.GetOutputSize() })
44  , m_Label(label)
45  , m_QuantizationParams(model.GetQuantizationParams())
46  , m_NumInferencesRef(numInferencesRef)
47  , m_NumCorrectInferencesRef(numCorrectInferencesRef)
48  , m_ValidationPredictions(validationPredictions)
49  , m_ValidationPredictionsOut(validationPredictionsOut)
50 {
51 }
+
+
+
+

Member Function Documentation

+ +

◆ ProcessResult()

+ +
+
+ + + + + +
+ + + + + + + + +
TestCaseResult ProcessResult (const InferenceTestOptionsparams)
+
+overridevirtual
+
+ +

Implements IInferenceTestCase.

+ +

Definition at line 124 of file InferenceTest.inl.

+ +

References ARMNN_LOG, armnn::error, armnn::test::Failed, InferenceModelTestCase< TModel >::GetOutputs(), InferenceModelTestCase< TModel >::GetTestCaseId(), armnn::info, InferenceTestOptions::m_IterationCount, armnn::numeric_cast(), and armnn::test::Ok.

+
125 {
126  auto& output = this->GetOutputs()[0];
127  const auto testCaseId = this->GetTestCaseId();
128 
129  ClassifierResultProcessor resultProcessor(m_QuantizationParams.first, m_QuantizationParams.second);
130  mapbox::util::apply_visitor(resultProcessor, output);
131 
132  ARMNN_LOG(info) << "= Prediction values for test #" << testCaseId;
133  auto it = resultProcessor.GetResultMap().rbegin();
134  for (int i=0; i<5 && it != resultProcessor.GetResultMap().rend(); ++i)
135  {
136  ARMNN_LOG(info) << "Top(" << (i+1) << ") prediction is " << it->second <<
137  " with value: " << (it->first);
138  ++it;
139  }
140 
141  unsigned int prediction = 0;
142  mapbox::util::apply_visitor([&](auto&& value)
143  {
144  prediction = armnn::numeric_cast<unsigned int>(
145  std::distance(value.begin(), std::max_element(value.begin(), value.end())));
146  },
147  output);
148 
149  // If we're just running the defaultTestCaseIds, each one must be classified correctly.
150  if (params.m_IterationCount == 0 && prediction != m_Label)
151  {
152  ARMNN_LOG(error) << "Prediction for test case " << testCaseId << " (" << prediction << ")" <<
153  " is incorrect (should be " << m_Label << ")";
154  return TestCaseResult::Failed;
155  }
156 
157  // If a validation file was provided as input, it checks that the prediction matches.
158  if (!m_ValidationPredictions.empty() && prediction != m_ValidationPredictions[testCaseId])
159  {
160  ARMNN_LOG(error) << "Prediction for test case " << testCaseId << " (" << prediction << ")" <<
161  " doesn't match the prediction in the validation file (" << m_ValidationPredictions[testCaseId] << ")";
162  return TestCaseResult::Failed;
163  }
164 
165  // If a validation file was requested as output, it stores the predictions.
166  if (m_ValidationPredictionsOut)
167  {
168  m_ValidationPredictionsOut->push_back(prediction);
169  }
170 
171  // Updates accuracy stats.
172  m_NumInferencesRef++;
173  if (prediction == m_Label)
174  {
175  m_NumCorrectInferencesRef++;
176  }
177 
178  return TestCaseResult::Ok;
179 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205
+
const std::vector< armnnUtils::TContainer > & GetOutputs() const
+ + + +
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
+
The test completed without any errors.
+
+
+
+
The documentation for this class was generated from the following files: +
+
+ + + + -- cgit v1.2.1