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