blob: e9ebd0db8e461c7f091f41b7269d5fe6e3f431b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
//
// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "ExecuteNetworkProgramOptions.hpp"
#include "ArmNNExecutor.hpp"
#if defined(ARMNN_TFLITE_DELEGATE)
#include "TfliteExecutor.hpp"
#endif
#include <armnn/Logging.hpp>
std::unique_ptr<IExecutor> BuildExecutor(ProgramOptions& programOptions)
{
if (programOptions.m_ExNetParams.m_TfLiteExecutor == ExecuteNetworkParams::TfLiteExecutor::ArmNNTfLiteDelegate ||
programOptions.m_ExNetParams.m_TfLiteExecutor == ExecuteNetworkParams::TfLiteExecutor::TfliteInterpreter)
{
#if defined(ARMNN_TFLITE_DELEGATE)
return std::make_unique<TfLiteExecutor>(programOptions.m_ExNetParams);
#else
ARMNN_LOG(fatal) << "Not built with Arm NN Tensorflow-Lite delegate support.";
return nullptr;
#endif
}
else
{
return std::make_unique<ArmNNExecutor>(programOptions.m_ExNetParams, programOptions.m_RuntimeOptions);
}
}
// MAIN
int main(int argc, const char* argv[])
{
// Configures logging for both the ARMNN library and this test program.
#ifdef NDEBUG
armnn::LogSeverity level = armnn::LogSeverity::Info;
#else
armnn::LogSeverity level = armnn::LogSeverity::Debug;
#endif
armnn::ConfigureLogging(true, true, level);
// Get ExecuteNetwork parameters and runtime options from command line
// This might throw an InvalidArgumentException if the user provided invalid inputs
ProgramOptions programOptions;
try
{
programOptions.ParseOptions(argc, argv);
}
catch (const std::exception& e)
{
ARMNN_LOG(fatal) << e.what();
return EXIT_FAILURE;
}
std::vector<const void*> outputResults;
auto executor = BuildExecutor(programOptions);
if (!executor)
{
return EXIT_FAILURE;
}
executor->PrintNetworkInfo();
outputResults = executor->Execute();
if (!programOptions.m_ExNetParams.m_ComparisonComputeDevices.empty() ||
programOptions.m_ExNetParams.m_CompareWithTflite)
{
ExecuteNetworkParams comparisonParams = programOptions.m_ExNetParams;
comparisonParams.m_ComputeDevices = programOptions.m_ExNetParams.m_ComparisonComputeDevices;
if (programOptions.m_ExNetParams.m_CompareWithTflite)
{
comparisonParams.m_TfLiteExecutor = ExecuteNetworkParams::TfLiteExecutor::TfliteInterpreter;
}
auto comparisonExecutor = BuildExecutor(programOptions);
if (!comparisonExecutor)
{
return EXIT_FAILURE;
}
comparisonExecutor->PrintNetworkInfo();
comparisonExecutor->Execute();
comparisonExecutor->CompareAndPrintResult(outputResults);
}
}
|