Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +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/ITensorHandleFactory.hpp> |
Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +0100 | [diff] [blame] | 8 | #include <aclCommon/BaseMemoryManager.hpp> |
Matteo Martincigh | e5b8eb9 | 2019-11-28 15:45:42 +0000 | [diff] [blame] | 9 | #include <armnn/backends/IMemoryManager.hpp> |
Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +0100 | [diff] [blame] | 10 | #include <armnn/MemorySources.hpp> |
| 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | constexpr const char* ClTensorHandleFactoryId() { return "Arm/Cl/TensorHandleFactory"; } |
| 16 | |
| 17 | class ClTensorHandleFactory : public ITensorHandleFactory { |
| 18 | public: |
| 19 | static const FactoryId m_Id; |
| 20 | |
| 21 | ClTensorHandleFactory(std::shared_ptr<ClMemoryManager> mgr) |
| 22 | : m_MemoryManager(mgr), |
| 23 | m_ImportFlags(static_cast<MemorySourceFlags>(MemorySource::Undefined)), |
| 24 | m_ExportFlags(static_cast<MemorySourceFlags>(MemorySource::Undefined)) |
| 25 | {} |
| 26 | |
| 27 | std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent, |
| 28 | const TensorShape& subTensorShape, |
| 29 | const unsigned int* subTensorOrigin) const override; |
| 30 | |
David Monahan | c6e5a6e | 2019-10-02 09:33:57 +0100 | [diff] [blame] | 31 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const override; |
| 32 | |
| 33 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
| 34 | DataLayout dataLayout) const override; |
| 35 | |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 36 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
| 37 | const bool IsMemoryManaged = true) const override; |
Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +0100 | [diff] [blame] | 38 | |
| 39 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 40 | DataLayout dataLayout, |
| 41 | const bool IsMemoryManaged = true) const override; |
Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +0100 | [diff] [blame] | 42 | |
| 43 | static const FactoryId& GetIdStatic(); |
| 44 | |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 45 | const FactoryId& GetId() const override; |
Jan Eilers | e9f0f0f | 2019-08-16 10:28:37 +0100 | [diff] [blame] | 46 | |
| 47 | bool SupportsSubTensors() const override; |
| 48 | |
| 49 | MemorySourceFlags GetExportFlags() const override; |
| 50 | |
| 51 | MemorySourceFlags GetImportFlags() const override; |
| 52 | |
| 53 | private: |
| 54 | mutable std::shared_ptr<ClMemoryManager> m_MemoryManager; |
| 55 | MemorySourceFlags m_ImportFlags; |
| 56 | MemorySourceFlags m_ExportFlags; |
| 57 | }; |
| 58 | |
| 59 | } // namespace armnn |