blob: 4079ab25b98c8056c3d3477be4ed13fe959086c3 [file] [log] [blame]
Georgios Pinitas12833d02019-07-25 13:31:10 +01001/*
2 * Copyright (c) 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 __ARM_COMPUTE_TEST_PARAMETERS_LIBRARY_H__
25#define __ARM_COMPUTE_TEST_PARAMETERS_LIBRARY_H__
26
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 */
33#ifdef ARM_COMPUTE_GC
34#include "arm_compute/runtime/GLES_COMPUTE/GCTensor.h"
35#endif /* ARM_COMPUTE_GC */
Georgios Pinitas12833d02019-07-25 13:31:10 +010036
37#include <memory>
38
39namespace arm_compute
40{
41namespace test
42{
43// Return type trait helper
44template <class T>
45struct ContextType
46{
47 using type = void;
48};
49template <>
50struct ContextType<Tensor>
51{
52 using type = IRuntimeContext;
53};
54
Pablo Tellodb8485a2019-09-24 11:03:47 +010055#if ARM_COMPUTE_CL
56template <>
57struct ContextType<CLTensor>
58{
59 using type = CLRuntimeContext;
60};
61#endif /* ARM_COMPUTE_CL */
62
63#ifdef ARM_COMPUTE_GC
64template <>
65struct ContextType<GCTensor>
66{
67 using type = IRuntimeContext;
68};
69#endif /* ARM_COMPUTE_GC */
70
Georgios Pinitas12833d02019-07-25 13:31:10 +010071/** Class that contains all the global parameters used by the tests */
72class ParametersLibrary final
73{
74public:
75 /** Default constructor */
76 ParametersLibrary() = default;
77 /** Set cpu context to be used by the tests
78 *
79 * @param[in] cpu_ctx CPU context to use
80 */
81 void set_cpu_ctx(std::unique_ptr<IRuntimeContext> cpu_ctx);
Pablo Tellodb8485a2019-09-24 11:03:47 +010082 /** Set gpu context to be used by the tests
83 *
84 * @param[in] gpu_ctx GPU context to use
85 */
86 void set_gpu_ctx(std::unique_ptr<IRuntimeContext> gpu_ctx);
Georgios Pinitas12833d02019-07-25 13:31:10 +010087 /** Get context given a tensor type
88 *
89 * @tparam TensorType
90 *
91 * @return Pointer to the context
92 */
93 template <typename TensorType>
94 typename ContextType<TensorType>::type *get_ctx()
95 {
96 return nullptr;
97 }
98
99private:
100 std::unique_ptr<IRuntimeContext> _cpu_ctx{ nullptr };
Pablo Tellodb8485a2019-09-24 11:03:47 +0100101 std::unique_ptr<IRuntimeContext> _gpu_ctx{ nullptr };
Georgios Pinitas12833d02019-07-25 13:31:10 +0100102};
103} // namespace test
104} // namespace arm_compute
105#endif //__ARM_COMPUTE_TEST_PARAMETERS_LIBRARY_H__