aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/RefTensorHandle.hpp
blob: 66d840ab35848ce07edf540402e10888001a69c5 (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
62
63
64
65
66
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once

#include <backendsCommon/CpuTensorHandle.hpp>

namespace armnn
{

// An implementation of ITensorHandle with simple "bump the pointer" memory-management behaviour
class RefTensorHandle : public ITensorHandle
{
public:
    RefTensorHandle(const TensorInfo& tensorInfo);

    ~RefTensorHandle();

    virtual void Manage() override
    {}

    virtual ITensorHandle* GetParent() const override
    {
        return nullptr;
    }

    virtual const void* Map(bool /* blocking = true */) const override
    {
        return m_Memory;
    }

    virtual void Unmap() const override
    {}

    virtual void Allocate() override;

    TensorShape GetStrides() const override
    {
        return GetUnpaddedTensorStrides(m_TensorInfo);
    }

    TensorShape GetShape() const override
    {
        return m_TensorInfo.GetShape();
    }

    const TensorInfo& GetTensorInfo() const
    {
        return m_TensorInfo;
    }

private:
    // Only used for testing
    void CopyOutTo(void*) const override;
    void CopyInFrom(const void*) override;

    RefTensorHandle(const RefTensorHandle& other) = delete;

    RefTensorHandle& operator=(const RefTensorHandle& other) = delete;

    TensorInfo m_TensorInfo;
    void* m_Memory;
};

}