26 #define BENCHMARK_EXAMPLES 56 std::unique_ptr<AssetsLibrary>
library;
57 static constexpr uint32_t fixed_seed = 1;
62 static std::unique_ptr<ValidateExample> g_example =
nullptr;
63 static std::vector<char *> g_example_argv = {};
67 std::string command_line(
int argc,
char **argv)
70 for(
int i = 0; i < argc; i++)
77 template <
bool val
idate>
81 ExampleTest() =
default;
82 void do_setup()
override 85 _is_setup = g_example->do_setup(g_example_argv.size(), &g_example_argv[0]);
87 void do_run()
override 94 void do_teardown()
override 100 g_example->do_validate();
102 g_example->do_teardown();
108 bool _is_setup{
false };
112 int run_example(
int argc,
char **argv, std::unique_ptr<ValidateExample> example)
117 example_args->
set_help(
"Arguments to pass to the example separated by commas (e.g: arg0,arg1,arg2)");
119 seed->set_help(
"Global seed for random number generation");
121 validate->set_help(
"Enable / disable output validation (0/1)");
125 parser.
parse(argc, argv);
133 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
134 g_example = std::move(example);
135 g_example_argv.clear();
136 g_example_argv.emplace_back(argv[0]);
137 for(
auto &arg : example_args->value())
139 g_example_argv.emplace_back(const_cast<char *>(arg.c_str()));
142 library = std::make_unique<AssetsLibrary>(
"." , seed->value());
143 fixed_library = std::make_unique<AssetsLibrary>(
".", fixed_seed);
147 for(
auto &p : printers)
149 p->print_global_header();
153 #ifdef ARM_COMPUTE_CL 164 for(
auto &p : printers)
167 p->print_entry(
"CommandLine", command_line(argc, argv));
169 #ifdef ARM_COMPUTE_CL 176 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
180 g_example->print_parameters(*p);
189 framework.
init(fconfig);
191 for(
auto &p : printers)
208 bool success = framework.
run();
211 for(
auto &p : printers)
213 p->print_global_footer();
217 return (success ? 0 : 1);
Framework configuration structure.
arm_compute::utils::ToggleOption * help
Show help option.
int run_example(int argc, char **argv, std::unique_ptr< ValidateExample > example)
Run an example and handle the potential exceptions it throws.
int num_iterations
Number of iterations per test.
static CLScheduler & get()
Access the scheduler singleton.
void default_init_with_context(cl::Device &device, cl::Context &ctx, ICLTuner *cl_tuner=nullptr, CLGEMMHeuristicsHandle *gemm_h=nullptr)
Initialises the scheduler with context and device provided by the user.
std::string to_string(T &&value)
Convert integer and float values to string.
void set_throw_errors(bool throw_errors)
Set whether errors are caught or thrown by the framework.
const std::vector< T > & value() const
Get the values of the option.
void add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status)
Add a test case to the framework.
std::stringstream ss(mlgo_str)
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
std::tuple< cl::Context, cl::Device, cl_int > create_opencl_context_and_device()
This function creates an OpenCL context and a device.
Class to parse command line arguments.
Copyright (c) 2017-2021 Arm Limited.
Implementation of an option that accepts any number of values.
static Framework & get()
Access to the singleton.
T * add_option(const std::string &name, As &&... args)
Function to add a new option to the parser.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
LogLevel log_level
Verbosity of the output.
bool run()
Run all enabled test cases.
void parse(int argc, char **argv)
Parses the command line arguments and updates the options accordingly.
std::vector< framework::InstrumentsDescription > instruments
Instrument types that will be used for benchmarking.
std::vector< std::unique_ptr< Printer > > create_printers()
Create the printers based on parsed command line options.
std::unique_ptr< AssetsLibrary > library
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
const T & value() const
Get the option value.
Abstract test case class.
Helper class to statically begin and end a test suite.
arm_compute::utils::SimpleOption< int > * iterations
Number of iterations option.
arm_compute::utils::EnumListOption< InstrumentsDescription > * instruments
Instruments option.
arm_compute::utils::EnumOption< LogLevel > * log_level
Logging level option.
std::string build_information()
Returns the arm_compute library build information.
Interface to enqueue GLES kernels and get/set the GLES CommandQueue.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
void add_printer(Printer *printer)
Set the printer used for the output of test results.
bool is_set() const
Has a value been assigned to the option?
void print_help(const std::string &program_name) const
Prints a help message for all configured options.
const T & value() const
Get the selected value.
Common command line options used to configure the framework.
Implementation of an option that accepts a single value.
void set_help(std::string help)
Set the help message for the option.
void init(const FrameworkConfig &config)
Init the framework.
Status validate(const ITensorInfo *scores_in, const ITensorInfo *boxes_in, const ITensorInfo *batch_splits_in, const ITensorInfo *scores_out, const ITensorInfo *boxes_out, const ITensorInfo *classes, const ITensorInfo *batch_splits_out, const ITensorInfo *keeps, const ITensorInfo *keeps_size, const BoxNMSLimitInfo info)
bool opencl_is_available()
Check if OpenCL is available.
std::unique_ptr< AssetsLibrary > fixed_library
arm_compute::utils::ToggleOption * throw_errors
Throw errors option.