David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 7 | #include <armnn/Types.hpp> |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 8 | #include <armnn/IRuntime.hpp> |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 9 | |
Derek Lamberti | ff05cc5 | 2019-04-26 13:05:17 +0100 | [diff] [blame] | 10 | #include <ISubgraphViewConverter.hpp> |
| 11 | #include <SubgraphView.hpp> |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 12 | |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 13 | #include <vector> |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 14 | |
| 15 | namespace armnn |
| 16 | { |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 17 | class IWorkloadFactory; |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 18 | class IBackendContext; |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 19 | class IMemoryManager; |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 20 | class Optimization; |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 21 | class ILayerSupport; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 22 | |
| 23 | class IBackendInternal : public IBackend |
| 24 | { |
| 25 | protected: |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 26 | // Creation must be done through a specific |
| 27 | // backend interface. |
David Beck | 6b779f0 | 2018-10-09 17:20:21 +0100 | [diff] [blame] | 28 | IBackendInternal() = default; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 29 | |
| 30 | public: |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 31 | // Allow backends created by the factory function |
| 32 | // to be destroyed through IBackendInternal. |
| 33 | ~IBackendInternal() override = default; |
| 34 | |
| 35 | using IWorkloadFactoryPtr = std::unique_ptr<IWorkloadFactory>; |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 36 | using IBackendContextPtr = std::unique_ptr<IBackendContext>; |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 37 | using OptimizationPtr = std::unique_ptr<Optimization>; |
| 38 | using Optimizations = std::vector<OptimizationPtr>; |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 39 | using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>; |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 40 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 41 | using IMemoryManagerUniquePtr = std::unique_ptr<IMemoryManager>; |
| 42 | using IMemoryManagerSharedPtr = std::shared_ptr<IMemoryManager>; |
| 43 | |
Derek Lamberti | ff05cc5 | 2019-04-26 13:05:17 +0100 | [diff] [blame] | 44 | using ISubgraphViewConverterPtr = std::unique_ptr<ISubgraphViewConverter>; |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 45 | |
Derek Lamberti | ff05cc5 | 2019-04-26 13:05:17 +0100 | [diff] [blame] | 46 | using SubgraphViewUniquePtr = std::unique_ptr<SubgraphView>; |
Matteo Martincigh | adddddb | 2019-01-24 14:06:23 +0000 | [diff] [blame] | 47 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 48 | virtual IMemoryManagerUniquePtr CreateMemoryManager() const = 0; |
| 49 | |
| 50 | virtual IWorkloadFactoryPtr CreateWorkloadFactory( |
| 51 | const IMemoryManagerSharedPtr& memoryManager = nullptr) const = 0; |
| 52 | |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 53 | virtual IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions&) const = 0; |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 54 | |
Derek Lamberti | ff05cc5 | 2019-04-26 13:05:17 +0100 | [diff] [blame] | 55 | virtual ISubgraphViewConverterPtr CreateSubgraphViewConverter(const std::shared_ptr<SubgraphView>& subgraph) |
| 56 | const = 0; |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 57 | |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 58 | virtual Optimizations GetOptimizations() const = 0; |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 59 | virtual ILayerSupportSharedPtr GetLayerSupport() const = 0; |
Matteo Martincigh | adddddb | 2019-01-24 14:06:23 +0000 | [diff] [blame] | 60 | |
Derek Lamberti | ff05cc5 | 2019-04-26 13:05:17 +0100 | [diff] [blame] | 61 | virtual SubgraphViewUniquePtr OptimizeSubgraphView(const SubgraphView& subgraph, bool& optimizationAttempted) |
| 62 | const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 63 | }; |
| 64 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 65 | using IBackendInternalUniquePtr = std::unique_ptr<IBackendInternal>; |
| 66 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 67 | } // namespace armnn |