Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClBackend.hpp" |
| 7 | |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 8 | #include <armnn/BackendRegistry.hpp> |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 9 | |
| 10 | namespace |
| 11 | { |
| 12 | |
| 13 | using namespace armnn; |
| 14 | |
| 15 | static BackendRegistry::StaticRegistryInitializer g_RegisterHelper |
| 16 | { |
| 17 | BackendRegistryInstance(), |
| 18 | ClBackend::GetIdStatic(), |
| 19 | []() |
| 20 | { |
Jan Eilers | c1c872f | 2021-07-22 13:17:04 +0100 | [diff] [blame] | 21 | // Check if we have a CustomMemoryAllocator associated with the backend |
| 22 | // and if so register it with the backend. |
| 23 | auto customAllocators = BackendRegistryInstance().GetAllocators(); |
| 24 | auto allocatorIterator = customAllocators.find(ClBackend::GetIdStatic()); |
| 25 | if (allocatorIterator != customAllocators.end()) |
| 26 | { |
| 27 | return IBackendInternalUniquePtr(new ClBackend(allocatorIterator->second)); |
| 28 | } |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 29 | return IBackendInternalUniquePtr(new ClBackend); |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | } // Anonymous namespace |