blob: d3677726ad63e3b4a7ad316f59dea78e26bb86c8 [file] [log] [blame]
Georgios Pinitas12833d02019-07-25 13:31:10 +01001/*
Manuel Bottiniceaa0bf2021-02-16 15:15:19 +00002 * Copyright (c) 2019-2021 Arm Limited.
Georgios Pinitas12833d02019-07-25 13:31:10 +01003 *
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 ARM_COMPUTE_TEST_PARAMETERS_LIBRARY_H
25#define ARM_COMPUTE_TEST_PARAMETERS_LIBRARY_H
Georgios Pinitas12833d02019-07-25 13:31:10 +010026
27#include "arm_compute/runtime/IRuntimeContext.h"
28#include "arm_compute/runtime/Tensor.h"
Pablo Tellodb8485a2019-09-24 11:03:47 +010029#if ARM_COMPUTE_CL
30#include "arm_compute/runtime/CL/CLRuntimeContext.h"
31#include "arm_compute/runtime/CL/CLTensor.h"
32#endif /* ARM_COMPUTE_CL */
Georgios Pinitas12833d02019-07-25 13:31:10 +010033
34#include <memory>
35
36namespace arm_compute
37{
38namespace test
39{
40// Return type trait helper
41template <class T>
42struct ContextType
43{
44 using type = void;
45};
46template <>
47struct ContextType<Tensor>
48{
49 using type = IRuntimeContext;
50};
51
Pablo Tellodb8485a2019-09-24 11:03:47 +010052#if ARM_COMPUTE_CL
53template <>
54struct ContextType<CLTensor>
55{
56 using type = CLRuntimeContext;
57};
58#endif /* ARM_COMPUTE_CL */
59
Georgios Pinitas12833d02019-07-25 13:31:10 +010060/** Class that contains all the global parameters used by the tests */
61class ParametersLibrary final
62{
63public:
64 /** Default constructor */
65 ParametersLibrary() = default;
66 /** Set cpu context to be used by the tests
67 *
68 * @param[in] cpu_ctx CPU context to use
69 */
70 void set_cpu_ctx(std::unique_ptr<IRuntimeContext> cpu_ctx);
Pablo Tellodb8485a2019-09-24 11:03:47 +010071 /** Set gpu context to be used by the tests
72 *
Georgios Pinitas7ae80a92019-10-25 18:25:17 +010073 * @param[in] cl_ctx GPU context to use
Pablo Tellodb8485a2019-09-24 11:03:47 +010074 */
Georgios Pinitas7ae80a92019-10-25 18:25:17 +010075 void set_cl_ctx(std::unique_ptr<IRuntimeContext> cl_ctx);
76 /** Set gpu context to be used by the tests
77 *
78 * @param[in] gc_ctx GPU context to use
79 */
80 void set_gc_ctx(std::unique_ptr<IRuntimeContext> gc_ctx);
Georgios Pinitas12833d02019-07-25 13:31:10 +010081 /** Get context given a tensor type
82 *
83 * @tparam TensorType
84 *
85 * @return Pointer to the context
86 */
87 template <typename TensorType>
88 typename ContextType<TensorType>::type *get_ctx()
89 {
90 return nullptr;
91 }
92
93private:
94 std::unique_ptr<IRuntimeContext> _cpu_ctx{ nullptr };
Georgios Pinitas7ae80a92019-10-25 18:25:17 +010095 std::unique_ptr<IRuntimeContext> _cl_ctx{ nullptr };
96 std::unique_ptr<IRuntimeContext> _gc_ctx{ nullptr };
Georgios Pinitas12833d02019-07-25 13:31:10 +010097};
98} // namespace test
99} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000100#endif //ARM_COMPUTE_TEST_PARAMETERS_LIBRARY_H