Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | fc8978f | 2020-08-06 11:30:46 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Matteo Martincigh | e5b8eb9 | 2019-11-28 15:45:42 +0000 | [diff] [blame] | 8 | #include <armnn/backends/IBackendInternal.hpp> |
| 9 | #include <armnn/backends/IMemoryManager.hpp> |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 10 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 11 | #include <backendsCommon/test/WorkloadFactoryHelper.hpp> |
| 12 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 13 | #include <cl/ClBackend.hpp> |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 14 | #include <cl/ClWorkloadFactory.hpp> |
Teresa Charlin | fc8978f | 2020-08-06 11:30:46 +0100 | [diff] [blame] | 15 | #include <cl/ClTensorHandleFactory.hpp> |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 16 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 17 | namespace |
| 18 | { |
| 19 | |
| 20 | template<> |
| 21 | struct WorkloadFactoryHelper<armnn::ClWorkloadFactory> |
| 22 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 23 | static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 24 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 25 | armnn::ClBackend backend; |
| 26 | return backend.CreateMemoryManager(); |
| 27 | } |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 28 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 29 | static armnn::ClWorkloadFactory GetFactory( |
| 30 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 31 | { |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 32 | return armnn::ClWorkloadFactory(armnn::PolymorphicPointerDowncast<armnn::ClMemoryManager>(memoryManager)); |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 33 | } |
Teresa Charlin | fc8978f | 2020-08-06 11:30:46 +0100 | [diff] [blame] | 34 | |
| 35 | static armnn::ClTensorHandleFactory GetTensorHandleFactory( |
| 36 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) |
| 37 | { |
| 38 | |
| 39 | return armnn::ClTensorHandleFactory(armnn::PolymorphicPointerDowncast<armnn::ClMemoryManager>(memoryManager)); |
| 40 | } |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | using ClWorkloadFactoryHelper = WorkloadFactoryHelper<armnn::ClWorkloadFactory>; |
| 44 | |
| 45 | } // anonymous namespace |