blob: 4e8dade7dc10f6f5d20c592f705e75525feae7f3 [file] [log] [blame]
Anthony Barbier979dc4f2018-03-07 09:27:48 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2016-2019 Arm Limited.
Anthony Barbier979dc4f2018-03-07 09:27:48 +00003 *
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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef VALIDATE_EXAMPLE_H
25#define VALIDATE_EXAMPLE_H
Anthony Barbier979dc4f2018-03-07 09:27:48 +000026
27#include "utils/Utils.h"
28namespace arm_compute
29{
30namespace test
31{
32namespace framework
33{
34class Printer;
35} // namespace framework
36} // namespace test
37namespace utils
38{
39/** Abstract ValidateExample class.
40 *
41 * All examples with a validation stage have to inherit from this class.
42 */
Anthony Barbier9fb0cac2018-04-20 15:46:21 +010043class ValidateExample
Anthony Barbier979dc4f2018-03-07 09:27:48 +000044{
45public:
Anthony Barbier9fb0cac2018-04-20 15:46:21 +010046 /** Setup the example.
47 *
48 * @param[in] argc Argument count.
49 * @param[in] argv Argument values.
50 */
Anthony Barbiere88b9bb2018-07-12 13:26:27 +010051 virtual bool do_setup(int argc, char **argv)
52 {
Michalis Spyrou6bff1952019-10-02 17:22:11 +010053 ARM_COMPUTE_UNUSED(argc, argv);
Anthony Barbiere88b9bb2018-07-12 13:26:27 +010054 return true;
55 };
Anthony Barbier9fb0cac2018-04-20 15:46:21 +010056 /** Run the example. */
57 virtual void do_run() {};
Anthony Barbier979dc4f2018-03-07 09:27:48 +000058 /** Run reference implementation and validate against the target output
59 */
60 virtual void do_validate()
61 {
62 }
Anthony Barbier9fb0cac2018-04-20 15:46:21 +010063 /** Teardown the example. */
64 virtual void do_teardown() {};
Anthony Barbier979dc4f2018-03-07 09:27:48 +000065 /** Print the example parameters
66 *
67 * @param[in,out] printer Printer to use to print the parameters
68 */
69 virtual void print_parameters(test::framework::Printer &printer)
70 {
Michalis Spyrou6bff1952019-10-02 17:22:11 +010071 ARM_COMPUTE_UNUSED(printer);
Anthony Barbier979dc4f2018-03-07 09:27:48 +000072 }
73
74 /** Default destructor */
75 virtual ~ValidateExample() = default;
76};
77/** Run an example and handle the potential exceptions it throws
78 *
79 * @param[in] argc Number of command line arguments
80 * @param[in] argv Command line arguments
81 * @param[in] example Example to run
82 */
Anthony Barbier9fb0cac2018-04-20 15:46:21 +010083int run_example(int argc, char **argv, std::unique_ptr<ValidateExample> example);
Anthony Barbier979dc4f2018-03-07 09:27:48 +000084
85} // namespace utils
86} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000087#endif /* VALIDATE_EXAMPLE_H */