ArmNN  NotReleased
SampleTensorHandle.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
8 
10 
11 namespace armnn
12 {
13 
14 // An implementation of ITensorHandle with simple "bump the pointer" memory-management behaviour
16 {
17 public:
18  SampleTensorHandle(const TensorInfo& tensorInfo, std::shared_ptr<SampleMemoryManager> &memoryManager);
19 
20  SampleTensorHandle(const TensorInfo& tensorInfo,
21  std::shared_ptr<SampleMemoryManager> &memoryManager,
22  MemorySourceFlags importFlags);
23 
25 
26  virtual void Manage() override;
27 
28  virtual void Allocate() override;
29 
30  virtual ITensorHandle* GetParent() const override
31  {
32  return nullptr;
33  }
34 
35  virtual const void* Map(bool /* blocking = true */) const override;
36  using ITensorHandle::Map;
37 
38  virtual void Unmap() const override
39  {}
40 
41  TensorShape GetStrides() const override
42  {
43  return GetUnpaddedTensorStrides(m_TensorInfo);
44  }
45 
46  TensorShape GetShape() const override
47  {
48  return m_TensorInfo.GetShape();
49  }
50 
51  const TensorInfo& GetTensorInfo() const
52  {
53  return m_TensorInfo;
54  }
55 
56  virtual MemorySourceFlags GetImportFlags() const override
57  {
58  return m_ImportFlags;
59  }
60 
61  virtual bool Import(void* memory, MemorySource source) override;
62 
63 private:
64  void* GetPointer() const;
65 
66  SampleTensorHandle(const SampleTensorHandle& other) = delete; // noncopyable
67  SampleTensorHandle& operator=(const SampleTensorHandle& other) = delete; //noncopyable
68 
69  TensorInfo m_TensorInfo;
70 
71  std::shared_ptr<SampleMemoryManager> m_MemoryManager;
73  mutable void *m_UnmanagedMemory;
74  MemorySourceFlags m_ImportFlags;
75  bool m_Imported;
76 };
77 
78 }
virtual void Manage() override
SampleTensorHandle(const TensorInfo &tensorInfo, std::shared_ptr< SampleMemoryManager > &memoryManager)
TensorShape GetShape() const override
virtual const void * Map(bool blocking=true) const =0
const TensorInfo & GetTensorInfo() const
TensorShape GetStrides() const override
TensorShape GetUnpaddedTensorStrides(const TensorInfo &tensorInfo)
unsigned int MemorySourceFlags
virtual void Unmap() const override
Unmap the tensor data.
virtual bool Import(void *memory, MemorySource source) override
virtual MemorySourceFlags GetImportFlags() const override
Get flags describing supported import sources.
virtual const void * Map(bool) const override
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
virtual void Allocate() override
virtual ITensorHandle * GetParent() const override