blob: 8e1c7a8a027239f93c3f0c4d608fb97b2648ed7e [file] [log] [blame]
Jan Eilerse9f0f0f2019-08-16 10:28:37 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
Jan Eilerse9f0f0f2019-08-16 10:28:37 +01007#include <aclCommon/BaseMemoryManager.hpp>
Jan Eilerse9f0f0f2019-08-16 10:28:37 +01008#include <armnn/MemorySources.hpp>
Colm Donelanc74b1752021-03-12 15:58:48 +00009#include <armnn/backends/IMemoryManager.hpp>
10#include <armnn/backends/ITensorHandleFactory.hpp>
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010011
12namespace armnn
13{
14
Colm Donelanc74b1752021-03-12 15:58:48 +000015constexpr const char* ClTensorHandleFactoryId()
16{
17 return "Arm/Cl/TensorHandleFactory";
18}
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010019
Colm Donelanc74b1752021-03-12 15:58:48 +000020class ClTensorHandleFactory : public ITensorHandleFactory
21{
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010022public:
23 static const FactoryId m_Id;
24
25 ClTensorHandleFactory(std::shared_ptr<ClMemoryManager> mgr)
Colm Donelanc74b1752021-03-12 15:58:48 +000026 : m_MemoryManager(mgr)
Colm Donelanc74b1752021-03-12 15:58:48 +000027 {}
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010028
29 std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
30 const TensorShape& subTensorShape,
31 const unsigned int* subTensorOrigin) const override;
32
David Monahanc6e5a6e2019-10-02 09:33:57 +010033 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const override;
34
35 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
36 DataLayout dataLayout) const override;
37
David Monahan3fb7e102019-08-20 11:25:29 +010038 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
Francis Murtagh623069d2020-08-14 17:24:39 +010039 const bool IsMemoryManaged) const override;
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010040
41 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
David Monahan3fb7e102019-08-20 11:25:29 +010042 DataLayout dataLayout,
Francis Murtagh623069d2020-08-14 17:24:39 +010043 const bool IsMemoryManaged) const override;
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010044
45 static const FactoryId& GetIdStatic();
46
Ferran Balaguerbfeb2712019-08-07 15:14:56 +010047 const FactoryId& GetId() const override;
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010048
49 bool SupportsSubTensors() const override;
50
51 MemorySourceFlags GetExportFlags() const override;
52
53 MemorySourceFlags GetImportFlags() const override;
54
55private:
56 mutable std::shared_ptr<ClMemoryManager> m_MemoryManager;
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010057};
58
Matthew Benthamb42a2b42022-11-28 13:43:10 +000059} // namespace armnn