blob: 6ec6885159d414f009762ccf74272d0dcdcc41f2 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#define BOOST_TEST_ALTERNATIVE_INIT_API
25
26#include "Globals.h"
27#include "TensorLibrary.h"
28#include "Utils.h"
29#include "ValidationProgramOptions.h"
30#include "ValidationUserConfiguration.h"
Moritz Pflanzerd0ae8b82017-06-29 14:51:57 +010031#include "support/ToolchainSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032
33#include "arm_compute/runtime/Scheduler.h"
34
35#include "boost_wrapper.h"
36
37#include <iostream>
38#include <memory>
39#include <random>
40
41using namespace arm_compute::test;
42using namespace arm_compute::test::validation;
43
44namespace arm_compute
45{
46namespace test
47{
48ValidationUserConfiguration user_config;
49std::unique_ptr<TensorLibrary> library;
50} // namespace test
51} // namespace arm_compute
52
53struct GlobalFixture
54{
55 GlobalFixture()
56 {
57 if(user_config.seed.is_set())
58 {
Moritz Pflanzerd0ae8b82017-06-29 14:51:57 +010059 library = arm_compute::support::cpp14::make_unique<TensorLibrary>(user_config.path.get(), user_config.seed);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010060 }
61 else
62 {
Moritz Pflanzerd0ae8b82017-06-29 14:51:57 +010063 library = arm_compute::support::cpp14::make_unique<TensorLibrary>(user_config.path.get());
Anthony Barbier6ff3b192017-09-04 18:44:23 +010064 }
65
Georgios Pinitase5f8fd62017-06-23 18:03:44 +010066 std::cout << "Seed: " << library->seed() << "\n";
Anthony Barbier6ff3b192017-09-04 18:44:23 +010067 }
68};
69
70BOOST_GLOBAL_FIXTURE(GlobalFixture);
71
72bool init_unit_test()
73{
74 boost::unit_test::framework::master_test_suite().p_name.value = "Compute Library Validation Tests";
75
76 ValidationProgramOptions options;
77
78 int &argc = boost::unit_test::framework::master_test_suite().argc;
79 char **argv = boost::unit_test::framework::master_test_suite().argv;
80
81 try
82 {
83 options.parse_commandline(argc, argv);
84
85 if(options.wants_help())
86 {
87 std::cout << "Usage: " << argv[0] << " [options] PATH\n";
88 std::cout << options.get_help() << "\n";
89 return false;
90 }
91
92 user_config = ValidationUserConfiguration(options);
93 }
94 catch(const boost::program_options::required_option &err)
95 {
96 std::cerr << "Error: " << err.what() << "\n";
97 std::cout << "\nUsage: " << argv[0] << " [options] PATH\n";
98 std::cout << options.get_help() << "\n";
99 return false;
100 }
101
102 std::cout << "Using " << user_config.threads << " CPU " << (user_config.threads == 1 ? "thread" : "threads") << "\n";
103 arm_compute::Scheduler::get().set_num_threads(user_config.threads);
104 return true;
105}