arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
Matteo Martincigh | e5b8eb9 | 2019-11-28 15:45:42 +0000 | [diff] [blame] | 7 | #include <armnn/backends/IBackendInternal.hpp> |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 8 | |
| 9 | namespace armnn |
| 10 | { |
| 11 | |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 12 | // add new capabilities here.. |
| 13 | const BackendCapabilities gpuAccCapabilities("GpuAcc", |
| 14 | { |
| 15 | {"NonConstWeights", false}, |
Jan Eilers | 15fcc7e | 2021-07-14 13:50:15 +0100 | [diff] [blame] | 16 | {"AsyncExecution", false}, |
| 17 | {"ProtectedContentAllocation", true} |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 18 | }); |
Sadik Armagan | aede8ca | 2021-03-31 16:12:13 +0100 | [diff] [blame] | 19 | |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 20 | class ClBackend : public IBackendInternal |
| 21 | { |
| 22 | public: |
Jan Eilers | 15fcc7e | 2021-07-14 13:50:15 +0100 | [diff] [blame] | 23 | ClBackend() : m_EnableCustomAllocator(false) {}; |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 24 | ~ClBackend() = default; |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 25 | |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 26 | static const BackendId& GetIdStatic(); |
| 27 | const BackendId& GetId() const override { return GetIdStatic(); } |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 28 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 29 | IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override; |
| 30 | |
| 31 | IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory( |
| 32 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) const override; |
| 33 | |
Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +0100 | [diff] [blame] | 34 | IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory( |
| 35 | TensorHandleFactoryRegistry& registry) const override; |
| 36 | |
Narumol Prangnawarat | e5f0b24 | 2021-05-07 17:52:36 +0100 | [diff] [blame] | 37 | IWorkloadFactoryPtr CreateWorkloadFactory(const IMemoryManagerSharedPtr& memoryManager, |
| 38 | const ModelOptions& modelOptions) const override; |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 39 | |
| 40 | IWorkloadFactoryPtr CreateWorkloadFactory(class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry, |
| 41 | const ModelOptions& modelOptions) const override; |
| 42 | |
Narumol Prangnawarat | e5f0b24 | 2021-05-07 17:52:36 +0100 | [diff] [blame] | 43 | IWorkloadFactoryPtr CreateWorkloadFactory(class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry, |
| 44 | const ModelOptions& modelOptions, |
| 45 | MemorySourceFlags inputFlags, |
| 46 | MemorySourceFlags outputFlags) const override; |
| 47 | |
Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +0100 | [diff] [blame] | 48 | std::vector<ITensorHandleFactory::FactoryId> GetHandleFactoryPreferences() const override; |
| 49 | |
| 50 | void RegisterTensorHandleFactories(TensorHandleFactoryRegistry& registry) override; |
| 51 | |
Narumol Prangnawarat | e5f0b24 | 2021-05-07 17:52:36 +0100 | [diff] [blame] | 52 | void RegisterTensorHandleFactories(TensorHandleFactoryRegistry& registry, |
| 53 | MemorySourceFlags inputFlags, |
| 54 | MemorySourceFlags outputFlags) override; |
| 55 | |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 56 | IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions&) const override; |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 57 | IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext( |
| 58 | const IRuntime::CreationOptions&, IBackendProfilingPtr& backendProfiling) override; |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 59 | |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 60 | IBackendInternal::Optimizations GetOptimizations() const override; |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 61 | IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override; |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 62 | IBackendInternal::ILayerSupportSharedPtr GetLayerSupport(const ModelOptions& modelOptions) const override; |
Matteo Martincigh | adddddb | 2019-01-24 14:06:23 +0000 | [diff] [blame] | 63 | |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 64 | OptimizationViews OptimizeSubgraphView(const SubgraphView& subgraph, |
| 65 | const ModelOptions& modelOptions) const override; |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 66 | |
| 67 | IBackendInternal::IBackendSpecificModelContextPtr CreateBackendSpecificModelContext( |
| 68 | const ModelOptions& modelOptions) const override; |
Sadik Armagan | aede8ca | 2021-03-31 16:12:13 +0100 | [diff] [blame] | 69 | |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 70 | BackendCapabilities GetCapabilities() const override |
| 71 | { |
| 72 | return gpuAccCapabilities; |
| 73 | }; |
Jan Eilers | 15fcc7e | 2021-07-14 13:50:15 +0100 | [diff] [blame] | 74 | |
| 75 | virtual bool UseCustomMemoryAllocator(armnn::Optional<std::string&> errMsg) override |
| 76 | { |
| 77 | IgnoreUnused(errMsg); |
| 78 | |
| 79 | // Set flag to signal the backend to use a custom memory allocator |
| 80 | m_EnableCustomAllocator = true; |
| 81 | |
| 82 | return m_EnableCustomAllocator; |
| 83 | } |
| 84 | |
| 85 | bool m_EnableCustomAllocator; |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 86 | }; |
| 87 | |
Matteo Martincigh | adddddb | 2019-01-24 14:06:23 +0000 | [diff] [blame] | 88 | } // namespace armnn |