blob: 3acab0bce730ca5bb3c419fbec1d6132522dcd37 [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)
27 , m_ImportFlags(static_cast<MemorySourceFlags>(MemorySource::Undefined))
28 , m_ExportFlags(static_cast<MemorySourceFlags>(MemorySource::Undefined))
29 {}
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010030
31 std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
32 const TensorShape& subTensorShape,
33 const unsigned int* subTensorOrigin) const override;
34
David Monahanc6e5a6e2019-10-02 09:33:57 +010035 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const override;
36
37 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
38 DataLayout dataLayout) const override;
39
David Monahan3fb7e102019-08-20 11:25:29 +010040 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
Francis Murtagh623069d2020-08-14 17:24:39 +010041 const bool IsMemoryManaged) const override;
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010042
43 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
David Monahan3fb7e102019-08-20 11:25:29 +010044 DataLayout dataLayout,
Francis Murtagh623069d2020-08-14 17:24:39 +010045 const bool IsMemoryManaged) const override;
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010046
47 static const FactoryId& GetIdStatic();
48
Ferran Balaguerbfeb2712019-08-07 15:14:56 +010049 const FactoryId& GetId() const override;
Jan Eilerse9f0f0f2019-08-16 10:28:37 +010050
51 bool SupportsSubTensors() const override;
52
53 MemorySourceFlags GetExportFlags() const override;
54
55 MemorySourceFlags GetImportFlags() const override;
56
57private:
58 mutable std::shared_ptr<ClMemoryManager> m_MemoryManager;
59 MemorySourceFlags m_ImportFlags;
60 MemorySourceFlags m_ExportFlags;
61};
62
Colm Donelanc74b1752021-03-12 15:58:48 +000063} // namespace armnn