ArmNN
 22.08
ExecuteNetwork.cpp File Reference

Go to the source code of this file.

Functions

std::unique_ptr< IExecutorBuildExecutor (ProgramOptions &programOptions)
 
int main (int argc, const char *argv[])
 

Function Documentation

◆ BuildExecutor()

std::unique_ptr<IExecutor> BuildExecutor ( ProgramOptions programOptions)

Definition at line 14 of file ExecuteNetwork.cpp.

References ARMNN_LOG, ExecuteNetworkParams::ArmNNTfLiteDelegate, ProgramOptions::m_ExNetParams, ProgramOptions::m_RuntimeOptions, ExecuteNetworkParams::m_TfLiteExecutor, and ExecuteNetworkParams::TfliteInterpreter.

Referenced by main().

15 {
18  {
19 #if defined(ARMNN_TFLITE_DELEGATE)
20  return std::make_unique<TfLiteExecutor>(programOptions.m_ExNetParams);
21 #else
22  ARMNN_LOG(fatal) << "Not built with Arm NN Tensorflow-Lite delegate support.";
23  return nullptr;
24 #endif
25  }
26  else
27  {
28  return std::make_unique<ArmNNExecutor>(programOptions.m_ExNetParams, programOptions.m_RuntimeOptions);
29  }
30 }
ExecuteNetworkParams m_ExNetParams
armnn::IRuntime::CreationOptions m_RuntimeOptions
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Definition at line 33 of file ExecuteNetwork.cpp.

References ARMNN_LOG, BuildExecutor(), armnn::ConfigureLogging(), armnn::Debug, armnn::Info, ExecuteNetworkParams::m_CompareWithTflite, ExecuteNetworkParams::m_ComparisonComputeDevices, ExecuteNetworkParams::m_ComputeDevices, ProgramOptions::m_ExNetParams, ExecuteNetworkParams::m_TfLiteExecutor, ProgramOptions::ParseOptions(), and ExecuteNetworkParams::TfliteInterpreter.

34 {
35  // Configures logging for both the ARMNN library and this test program.
36 #ifdef NDEBUG
38 #else
40 #endif
41  armnn::ConfigureLogging(true, true, level);
42 
43 
44  // Get ExecuteNetwork parameters and runtime options from command line
45  // This might throw an InvalidArgumentException if the user provided invalid inputs
46  ProgramOptions programOptions;
47  try
48  {
49  programOptions.ParseOptions(argc, argv);
50  }
51  catch (const std::exception& e)
52  {
53  ARMNN_LOG(fatal) << e.what();
54  return EXIT_FAILURE;
55  }
56 
57  std::vector<const void*> outputResults;
58 
59  auto executor = BuildExecutor(programOptions);
60  if (!executor)
61  {
62  return EXIT_FAILURE;
63  }
64 
65  executor->PrintNetworkInfo();
66  outputResults = executor->Execute();
67 
68  if (!programOptions.m_ExNetParams.m_ComparisonComputeDevices.empty() ||
69  programOptions.m_ExNetParams.m_CompareWithTflite)
70  {
71  ExecuteNetworkParams comparisonParams = programOptions.m_ExNetParams;
72  comparisonParams.m_ComputeDevices = programOptions.m_ExNetParams.m_ComparisonComputeDevices;
73 
74  if (programOptions.m_ExNetParams.m_CompareWithTflite)
75  {
77  }
78 
79  auto comparisonExecutor = BuildExecutor(programOptions);
80 
81  if (!comparisonExecutor)
82  {
83  return EXIT_FAILURE;
84  }
85 
86  comparisonExecutor->PrintNetworkInfo();
87  comparisonExecutor->Execute();
88 
89  comparisonExecutor->CompareAndPrintResult(outputResults);
90  }
91 }
ExecuteNetworkParams m_ExNetParams
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
Configures the logging behaviour of the ARMNN library.
Definition: Utils.cpp:18
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205
std::vector< armnn::BackendId > m_ComparisonComputeDevices
std::vector< armnn::BackendId > m_ComputeDevices
std::unique_ptr< IExecutor > BuildExecutor(ProgramOptions &programOptions)
Holds all parameters necessary to execute a network Check ExecuteNetworkProgramOptions.cpp for a description of each parameter.
void ParseOptions(int ac, const char *av[])
Parses program options from the command line or another source and stores the values in member variab...
Holds and parses program options for the ExecuteNetwork application.
LogSeverity
Definition: Utils.hpp:14