Georgios Pinitas | 12833d0 | 2019-07-25 13:31:10 +0100 | [diff] [blame] | 1 | /* |
| 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 Tello | db8485a | 2019-09-24 11:03:47 +0100 | [diff] [blame^] | 29 | #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 Pinitas | 12833d0 | 2019-07-25 13:31:10 +0100 | [diff] [blame] | 36 | |
| 37 | #include <memory> |
| 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace test |
| 42 | { |
| 43 | // Return type trait helper |
| 44 | template <class T> |
| 45 | struct ContextType |
| 46 | { |
| 47 | using type = void; |
| 48 | }; |
| 49 | template <> |
| 50 | struct ContextType<Tensor> |
| 51 | { |
| 52 | using type = IRuntimeContext; |
| 53 | }; |
| 54 | |
Pablo Tello | db8485a | 2019-09-24 11:03:47 +0100 | [diff] [blame^] | 55 | #if ARM_COMPUTE_CL |
| 56 | template <> |
| 57 | struct ContextType<CLTensor> |
| 58 | { |
| 59 | using type = CLRuntimeContext; |
| 60 | }; |
| 61 | #endif /* ARM_COMPUTE_CL */ |
| 62 | |
| 63 | #ifdef ARM_COMPUTE_GC |
| 64 | template <> |
| 65 | struct ContextType<GCTensor> |
| 66 | { |
| 67 | using type = IRuntimeContext; |
| 68 | }; |
| 69 | #endif /* ARM_COMPUTE_GC */ |
| 70 | |
Georgios Pinitas | 12833d0 | 2019-07-25 13:31:10 +0100 | [diff] [blame] | 71 | /** Class that contains all the global parameters used by the tests */ |
| 72 | class ParametersLibrary final |
| 73 | { |
| 74 | public: |
| 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 Tello | db8485a | 2019-09-24 11:03:47 +0100 | [diff] [blame^] | 82 | /** 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 Pinitas | 12833d0 | 2019-07-25 13:31:10 +0100 | [diff] [blame] | 87 | /** 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 | |
| 99 | private: |
| 100 | std::unique_ptr<IRuntimeContext> _cpu_ctx{ nullptr }; |
Pablo Tello | db8485a | 2019-09-24 11:03:47 +0100 | [diff] [blame^] | 101 | std::unique_ptr<IRuntimeContext> _gpu_ctx{ nullptr }; |
Georgios Pinitas | 12833d0 | 2019-07-25 13:31:10 +0100 | [diff] [blame] | 102 | }; |
| 103 | } // namespace test |
| 104 | } // namespace arm_compute |
| 105 | #endif //__ARM_COMPUTE_TEST_PARAMETERS_LIBRARY_H__ |