aboutsummaryrefslogtreecommitdiff
path: root/src/backends/tosaReference/TosaRefTensorHandleFactory.hpp
blob: 17dd1d4d063cc3db905faf77d6fc512f9e0c6642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

#include "TosaRefMemoryManager.hpp"

#include <armnn/backends/ITensorHandleFactory.hpp>

namespace armnn
{

constexpr const char * TosaRefTensorHandleFactoryId() { return "Arm/TosaRef/TensorHandleFactory"; }

class TosaRefTensorHandleFactory : public ITensorHandleFactory
{

public:
    TosaRefTensorHandleFactory(std::shared_ptr<TosaRefMemoryManager> mgr)
    : m_MemoryManager(mgr)
    , m_ImportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc))
    , m_ExportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc))
    {}

    std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
                                                         TensorShape const& subTensorShape,
                                                         unsigned int const* subTensorOrigin) const override;

    std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const override;

    std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
                                                      DataLayout dataLayout) const override;

    std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
                                                      const bool IsMemoryManaged) const override;

    std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
                                                      DataLayout dataLayout,
                                                      const bool IsMemoryManaged) const override;

    static const FactoryId& GetIdStatic();

    const FactoryId& GetId() const override;

    bool SupportsSubTensors() const override;

    MemorySourceFlags GetExportFlags() const override;

    MemorySourceFlags GetImportFlags() const override;

private:
    mutable std::shared_ptr<TosaRefMemoryManager> m_MemoryManager;
    MemorySourceFlags m_ImportFlags;
    MemorySourceFlags m_ExportFlags;

};

} // namespace armnn