23.08
|
Go to the documentation of this file.
24 #include "utils/Utils.h"
26 #define BENCHMARK_EXAMPLES
53 std::unique_ptr<AssetsLibrary>
library;
54 static constexpr uint32_t fixed_seed = 1;
59 static std::unique_ptr<ValidateExample> g_example =
nullptr;
60 static std::vector<char *> g_example_argv = {};
64 std::string command_line(
int argc,
char **argv)
67 for(
int i = 0; i < argc; i++)
74 template <
bool val
idate>
78 ExampleTest() =
default;
79 void do_setup()
override
82 _is_setup = g_example->do_setup(g_example_argv.size(), &g_example_argv[0]);
84 void do_run()
override
91 void do_teardown()
override
97 g_example->do_validate();
99 g_example->do_teardown();
105 bool _is_setup{
false };
109 int run_example(
int argc,
char **argv, std::unique_ptr<ValidateExample> example)
114 example_args->
set_help(
"Arguments to pass to the example separated by commas (e.g: arg0,arg1,arg2)");
116 seed->set_help(
"Global seed for random number generation");
118 validate->set_help(
"Enable / disable output validation (0/1)");
126 parser.print_help(argv[0]);
130 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
131 g_example = std::move(example);
132 g_example_argv.clear();
133 g_example_argv.emplace_back(argv[0]);
134 for(
auto &arg : example_args->value())
136 g_example_argv.emplace_back(
const_cast<char *
>(arg.c_str()));
139 library = std::make_unique<AssetsLibrary>(
"." , seed->value());
140 fixed_library = std::make_unique<AssetsLibrary>(
".", fixed_seed);
144 for(
auto &p : printers)
146 p->print_global_header();
150 #ifdef ARM_COMPUTE_CL
154 for(
auto &arg : example_args->value())
156 if(arg.find(
"--target=clvk") != std::string::npos)
170 for(
auto &p : printers)
173 p->print_entry(
"CommandLine", command_line(argc, argv));
175 #ifdef ARM_COMPUTE_CL
182 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
186 g_example->print_parameters(*p);
195 framework.
init(fconfig);
197 for(
auto &p : printers)
214 bool success = framework.
run();
217 for(
auto &p : printers)
219 p->print_global_footer();
223 return (success ? 0 : 1);
std::string to_string(T &&value)
Convert integer and float values to string.
bool opencl_is_available()
Check if OpenCL is available.
Framework configuration structure.
Common command line options used to configure the framework.
int num_iterations
Number of iterations per test.
int run_example(int argc, char **argv, std::unique_ptr< ValidateExample > example)
Run an example and handle the potential exceptions it throws.
void add_printer(Printer *printer)
Set the printer used for the output of test results.
std::tuple< cl::Context, cl::Device, cl_int > create_opencl_context_and_device(CLBackendType cl_backend_type)
This function creates an OpenCL context and a device.
void add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status)
Add a test case to the framework.
arm_compute::utils::ToggleOption * help
Show help option.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
LogLevel log_level
Verbosity of the output.
Implementation of an option that accepts any number of values.
std::vector< std::unique_ptr< Printer > > create_printers()
Create the printers based on parsed command line options.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Class to parse command line arguments.
const std::vector< T > & value() const
Get the values of the option.
std::stringstream ss(mlgo_str)
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
void set_throw_errors(bool throw_errors)
Set whether errors are caught or thrown by the framework.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
std::vector< framework::InstrumentsDescription > instruments
Instrument types that will be used for benchmarking.
bool run()
Run all enabled test cases.
bool is_set() const
Has a value been assigned to the option?
const T & value() const
Get the selected value.
static Framework & get()
Access to the singleton.
std::unique_ptr< AssetsLibrary > fixed_library
static CLScheduler & get()
Access the scheduler singleton.
CLBackendType
List the possible OpenCL backends.
void set_help(std::string help)
Set the help message for the option.
std::unique_ptr< AssetsLibrary > library
Helper class to statically begin and end a test suite.
Abstract test case class.
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.
@ Native
OpenCL native backend.
std::string build_information()
Returns the arm_compute library build information.
arm_compute::utils::SimpleOption< int > * iterations
Number of iterations option.
const T & value() const
Get the option value.
arm_compute::utils::EnumListOption< InstrumentsDescription > * instruments
Instruments option.
Copyright (c) 2017-2023 Arm Limited.
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)
arm_compute::utils::EnumOption< LogLevel > * log_level
Logging level option.
void init(const FrameworkConfig &config)
Init the framework.
arm_compute::utils::ToggleOption * throw_errors
Throw errors option.
Implementation of an option that accepts a single value.