arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 1 | // |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 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 | { |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 11 | // add new capabilities here.. |
| 12 | const BackendCapabilities cpuRefCapabilities("CpuRef", |
| 13 | { |
| 14 | {"NonConstWeights", true}, |
Matthew Sloyan | 81beae3 | 2021-07-13 19:46:11 +0100 | [diff] [blame] | 15 | {"AsyncExecution", true}, |
Finn Williams | dbf5f31 | 2021-08-26 11:08:01 +0100 | [diff] [blame] | 16 | {"ProtectedContentAllocation", false}, |
| 17 | {"ConstantTensorsAsInputs", true}, |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 18 | {"PreImportIOTensors", true}, |
Finn Williams | b1aad42 | 2021-10-28 19:07:32 +0100 | [diff] [blame] | 19 | {"ExternallyManagedMemory", true}, |
Sadik Armagan | b8a26d8 | 2021-10-04 15:13:11 +0100 | [diff] [blame] | 20 | {"MultiAxisPacking", false}, |
| 21 | {"SingleAxisPacking", true} |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 22 | }); |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 23 | |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 24 | const std::set<armnn::BackendCapability> oldCpuRefCapabilities { |
| 25 | armnn::BackendCapability::NonConstWeights, |
Sadik Armagan | f0a6dec | 2021-03-25 07:46:55 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 28 | |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 29 | class RefBackend : public IBackendInternal |
| 30 | { |
| 31 | public: |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 32 | RefBackend() = default; |
| 33 | ~RefBackend() = default; |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 34 | |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 35 | static const BackendId& GetIdStatic(); |
| 36 | const BackendId& GetId() const override { return GetIdStatic(); } |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 37 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 38 | IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override; |
| 39 | |
| 40 | IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory( |
| 41 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) const override; |
| 42 | |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 43 | IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory( |
| 44 | class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry) const override; |
| 45 | |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 46 | IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions&) const override; |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 47 | |
Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 48 | IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext( |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 49 | const IRuntime::CreationOptions& creationOptions, IBackendProfilingPtr& backendProfiling) override; |
Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 50 | |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 51 | IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override; |
Matteo Martincigh | adddddb | 2019-01-24 14:06:23 +0000 | [diff] [blame] | 52 | |
Matteo Martincigh | c3ba50e | 2019-05-22 14:28:16 +0100 | [diff] [blame] | 53 | OptimizationViews OptimizeSubgraphView(const SubgraphView& subgraph) const override; |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 54 | |
| 55 | std::vector<ITensorHandleFactory::FactoryId> GetHandleFactoryPreferences() const override; |
| 56 | |
| 57 | void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry& registry) override; |
Sadik Armagan | f0a6dec | 2021-03-25 07:46:55 +0000 | [diff] [blame] | 58 | |
Finn Williams | b9af86e | 2021-05-26 18:38:12 +0100 | [diff] [blame] | 59 | BackendCapabilities GetCapabilities() const override |
| 60 | { |
| 61 | return cpuRefCapabilities; |
| 62 | }; |
Francis Murtagh | e8d7ccb | 2021-10-14 17:30:24 +0100 | [diff] [blame] | 63 | |
| 64 | std::unique_ptr<ICustomAllocator> GetDefaultAllocator() const override; |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 65 | |
| 66 | ExecutionData CreateExecutionData(WorkingMemDescriptor& workingMemDescriptor) const override; |
| 67 | |
| 68 | void UpdateExecutionData(ExecutionData& executionData, WorkingMemDescriptor& workingMemDescriptor) const override; |
arovir01 | 4424b0a | 2018-10-04 10:46:04 +0100 | [diff] [blame] | 69 | }; |
| 70 | |
Matteo Martincigh | adddddb | 2019-01-24 14:06:23 +0000 | [diff] [blame] | 71 | } // namespace armnn |