Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefTensorHandleFactory.hpp" |
| 7 | #include "RefTensorHandle.hpp" |
| 8 | |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 9 | #include <armnn/utility/IgnoreUnused.hpp> |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | |
| 14 | using FactoryId = ITensorHandleFactory::FactoryId; |
| 15 | |
| 16 | const FactoryId& RefTensorHandleFactory::GetIdStatic() |
| 17 | { |
| 18 | static const FactoryId s_Id(RefTensorHandleFactoryId()); |
| 19 | return s_Id; |
| 20 | } |
| 21 | |
| 22 | std::unique_ptr<ITensorHandle> RefTensorHandleFactory::CreateSubTensorHandle(ITensorHandle& parent, |
| 23 | TensorShape const& subTensorShape, |
| 24 | unsigned int const* subTensorOrigin) const |
| 25 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 26 | IgnoreUnused(parent, subTensorShape, subTensorOrigin); |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 27 | return nullptr; |
| 28 | } |
| 29 | |
David Monahan | c6e5a6e | 2019-10-02 09:33:57 +0100 | [diff] [blame] | 30 | std::unique_ptr<ITensorHandle> RefTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo) const |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 31 | { |
Narumol Prangnawarat | 3b90af6 | 2020-06-26 11:00:21 +0100 | [diff] [blame] | 32 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | std::unique_ptr<ITensorHandle> RefTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | c6e5a6e | 2019-10-02 09:33:57 +0100 | [diff] [blame] | 36 | DataLayout dataLayout) const |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 37 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 38 | IgnoreUnused(dataLayout); |
Narumol Prangnawarat | 3b90af6 | 2020-06-26 11:00:21 +0100 | [diff] [blame] | 39 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
| 40 | } |
| 41 | |
| 42 | std::unique_ptr<ITensorHandle> RefTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
| 43 | const bool IsMemoryManaged) const |
| 44 | { |
| 45 | if (IsMemoryManaged) |
| 46 | { |
| 47 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | return std::make_unique<RefTensorHandle>(tensorInfo, m_ImportFlags); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | std::unique_ptr<ITensorHandle> RefTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
| 56 | DataLayout dataLayout, |
| 57 | const bool IsMemoryManaged) const |
| 58 | { |
| 59 | IgnoreUnused(dataLayout); |
| 60 | if (IsMemoryManaged) |
| 61 | { |
| 62 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | return std::make_unique<RefTensorHandle>(tensorInfo, m_ImportFlags); |
| 67 | } |
Ferran Balaguer | bfeb271 | 2019-08-07 15:14:56 +0100 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | const FactoryId& RefTensorHandleFactory::GetId() const |
| 71 | { |
| 72 | return GetIdStatic(); |
| 73 | } |
| 74 | |
| 75 | bool RefTensorHandleFactory::SupportsSubTensors() const |
| 76 | { |
| 77 | return false; |
| 78 | } |
| 79 | |
| 80 | MemorySourceFlags RefTensorHandleFactory::GetExportFlags() const |
| 81 | { |
| 82 | return m_ExportFlags; |
| 83 | } |
| 84 | |
| 85 | MemorySourceFlags RefTensorHandleFactory::GetImportFlags() const |
| 86 | { |
| 87 | return m_ImportFlags; |
| 88 | } |
| 89 | |
| 90 | } // namespace armnn |