Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 2 | // Copyright © 2017-2023 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 7 | #include "RefMemoryManager.hpp" |
| 8 | |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 9 | #include <armnn/Optional.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 10 | #include <armnn/backends/WorkloadFactory.hpp> |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 11 | #include <armnn/utility/IgnoreUnused.hpp> |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 12 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | template <typename QueueDescriptorType> |
| 18 | constexpr bool IsOperationQueueDescriptor(const QueueDescriptorType&) { return true; } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 19 | template <> |
| 20 | constexpr bool IsOperationQueueDescriptor(const MemCopyQueueDescriptor&) { return false; } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 21 | template <> |
| 22 | constexpr bool IsOperationQueueDescriptor(const ConstantQueueDescriptor&) { return false; } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 23 | template <> |
| 24 | constexpr bool IsOperationQueueDescriptor(const PermuteQueueDescriptor&) { return false; } |
| 25 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 26 | // Reference workload factory. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | class RefWorkloadFactory : public IWorkloadFactory |
| 28 | { |
| 29 | public: |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 30 | explicit RefWorkloadFactory(const std::shared_ptr<RefMemoryManager>& memoryManager); |
| 31 | RefWorkloadFactory(); |
| 32 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 33 | ~RefWorkloadFactory() {} |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 34 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 35 | const BackendId& GetBackendId() const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 37 | static bool IsLayerSupported(const Layer& layer, |
| 38 | Optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 39 | std::string& outReasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 40 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 41 | static bool IsLayerSupported(const IConnectableLayer& layer, |
| 42 | Optional<DataType> dataType, |
| 43 | std::string& outReasonIfUnsupported, |
| 44 | const ModelOptions& modelOptions); |
| 45 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 46 | bool SupportsSubTensors() const override { return false; } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 47 | |
Sadik Armagan | c83eb25 | 2020-07-22 16:32:06 +0100 | [diff] [blame] | 48 | ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateSubTensorHandle instead") |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 49 | std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent, |
| 50 | TensorShape const& subTensorShape, |
| 51 | unsigned int const* subTensorOrigin) const override |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 52 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 53 | IgnoreUnused(parent, subTensorShape, subTensorOrigin); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 54 | return nullptr; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 55 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 56 | |
Sadik Armagan | c83eb25 | 2020-07-22 16:32:06 +0100 | [diff] [blame] | 57 | ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead") |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 58 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
| 59 | const bool IsMemoryManaged = true) const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | |
Sadik Armagan | c83eb25 | 2020-07-22 16:32:06 +0100 | [diff] [blame] | 61 | ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead") |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 62 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 63 | DataLayout dataLayout, |
| 64 | const bool IsMemoryManaged = true) const override; |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 65 | |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 66 | std::unique_ptr<IWorkload> CreateWorkload(LayerType type, |
| 67 | const QueueDescriptor& descriptor, |
| 68 | const WorkloadInfo& info) const override; |
| 69 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 70 | private: |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 71 | template <typename F32Workload, typename U8Workload, typename QueueDescriptorType> |
| 72 | std::unique_ptr<IWorkload> MakeWorkload(const QueueDescriptorType& descriptor, const WorkloadInfo& info) const; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 73 | |
| 74 | mutable std::shared_ptr<RefMemoryManager> m_MemoryManager; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | } // namespace armnn |