blob: b03433352eaef93ae06320087d84ebe19e90e837 [file] [log] [blame]
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <aclCommon/BaseMemoryManager.hpp>
9#include <backendsCommon/ITensorHandleFactory.hpp>
10
11namespace armnn
12{
13
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010014constexpr const char* NeonTensorHandleFactoryId() { return "Arm/Neon/TensorHandleFactory"; }
15
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010016class NeonTensorHandleFactory : public ITensorHandleFactory
17{
18public:
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010019 NeonTensorHandleFactory(std::weak_ptr<NeonMemoryManager> mgr)
20 : m_MemoryManager(mgr),
David Monahan3fb7e102019-08-20 11:25:29 +010021 m_ImportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc)),
22 m_ExportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc))
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010023 {}
24
25 std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010026 const TensorShape& subTensorShape,
27 const unsigned int* subTensorOrigin) const override;
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010028
David Monahan3fb7e102019-08-20 11:25:29 +010029 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
30 const bool IsMemoryManaged = true) const override;
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010031
32 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
David Monahan3fb7e102019-08-20 11:25:29 +010033 DataLayout dataLayout,
34 const bool IsMemoryManaged = true) const override;
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010035
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010036 static const FactoryId& GetIdStatic();
37
Ferran Balaguerbfeb2712019-08-07 15:14:56 +010038 const FactoryId& GetId() const override;
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010039
40 bool SupportsSubTensors() const override;
41
42 MemorySourceFlags GetExportFlags() const override;
43
44 MemorySourceFlags GetImportFlags() const override;
45
46private:
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010047 mutable std::shared_ptr<NeonMemoryManager> m_MemoryManager;
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010048 MemorySourceFlags m_ImportFlags;
49 MemorySourceFlags m_ExportFlags;
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010050};
51
52} // namespace armnn