Compute Library
 23.08
ValidateExample.h
Go to the documentation of this file.
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  */
44 {
45 public:
46  /** Setup the example.
47  *
48  * @param[in] argc Argument count.
49  * @param[in] argv Argument values.
50  */
51  virtual bool do_setup(int argc, char **argv)
52  {
53  ARM_COMPUTE_UNUSED(argc, argv);
54  return true;
55  };
56  /** Run the example. */
57  virtual void do_run() {};
58  /** Run reference implementation and validate against the target output
59  */
60  virtual void do_validate()
61  {
62  }
63  /** Teardown the example. */
64  virtual void do_teardown() {};
65  /** Print the example parameters
66  *
67  * @param[in,out] printer Printer to use to print the parameters
68  */
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 */
arm_compute::utils::ValidateExample
Abstract ValidateExample class.
Definition: ValidateExample.h:43
arm_compute::utils::ValidateExample::do_validate
virtual void do_validate()
Run reference implementation and validate against the target output.
Definition: ValidateExample.h:60
arm_compute::utils::ValidateExample::do_run
virtual void do_run()
Run the example.
Definition: ValidateExample.h:57
arm_compute::test::framework::Printer
Abstract printer class used by the Framework to present output.
Definition: Printer.h:43
ARM_COMPUTE_UNUSED
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
arm_compute::utils::ValidateExample::do_teardown
virtual void do_teardown()
Teardown the example.
Definition: ValidateExample.h:64
arm_compute::utils::ValidateExample::do_setup
virtual bool do_setup(int argc, char **argv)
Setup the example.
Definition: ValidateExample.h:51
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
arm_compute::utils::ValidateExample::~ValidateExample
virtual ~ValidateExample()=default
Default destructor.
arm_compute::utils::ValidateExample::print_parameters
virtual void print_parameters(test::framework::Printer &printer)
Print the example parameters.
Definition: ValidateExample.h:69
arm_compute::utils::run_example
int run_example(int argc, char **argv, std::unique_ptr< Example > example)
Run an example and handle the potential exceptions it throws.
Definition: RunExample.cpp:95