xref: /aosp_15_r20/external/ComputeLibrary/tests/validate_examples/ValidateExample.h (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1 /*
2  * Copyright (c) 2016-2019 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 #ifndef VALIDATE_EXAMPLE_H
25 #define VALIDATE_EXAMPLE_H
26 
27 #include "utils/Utils.h"
28 namespace arm_compute
29 {
30 namespace test
31 {
32 namespace framework
33 {
34 class Printer;
35 } // namespace framework
36 } // namespace test
37 namespace utils
38 {
39 /** Abstract ValidateExample class.
40  *
41  * All examples with a validation stage have to inherit from this class.
42  */
43 class ValidateExample
44 {
45 public:
46     /** Setup the example.
47      *
48      * @param[in] argc Argument count.
49      * @param[in] argv Argument values.
50      */
do_setup(int argc,char ** argv)51     virtual bool do_setup(int argc, char **argv)
52     {
53         ARM_COMPUTE_UNUSED(argc, argv);
54         return true;
55     };
56     /** Run the example. */
do_run()57     virtual void do_run() {};
58     /** Run reference implementation and validate against the target output
59      */
do_validate()60     virtual void do_validate()
61     {
62     }
63     /** Teardown the example. */
do_teardown()64     virtual void do_teardown() {};
65     /** Print the example parameters
66      *
67      * @param[in,out] printer Printer to use to print the parameters
68      */
print_parameters(test::framework::Printer & printer)69     virtual void print_parameters(test::framework::Printer &printer)
70     {
71         ARM_COMPUTE_UNUSED(printer);
72     }
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  */
83 int run_example(int argc, char **argv, std::unique_ptr<ValidateExample> example);
84 
85 } // namespace utils
86 } // namespace arm_compute
87 #endif /* VALIDATE_EXAMPLE_H */
88