ArmNN  NotReleased
ITensorHandle.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
8 
9 #include <boost/core/ignore_unused.hpp>
10 
11 namespace armnn
12 {
13 
14 class TensorShape;
15 
17 {
18 public:
19  virtual ~ITensorHandle(){}
20 
23  virtual void Manage() = 0;
24 
27  virtual void Allocate() = 0;
28 
31  virtual ITensorHandle* GetParent() const = 0;
32 
36  virtual const void* Map(bool blocking=true) const = 0;
37 
39  virtual void Unmap() const = 0;
40 
44  void* Map(bool blocking=true)
45  {
46  return const_cast<void*>(static_cast<const ITensorHandle*>(this)->Map(blocking));
47  }
48 
50  void Unmap()
51  {
52  return static_cast<const ITensorHandle*>(this)->Unmap();
53  }
54 
58  virtual TensorShape GetStrides() const = 0;
59 
63  virtual TensorShape GetShape() const = 0;
64 
65  // Testing support to be able to verify and set tensor data content
66  virtual void CopyOutTo(void* memory) const = 0;
67  virtual void CopyInFrom(const void* memory) = 0;
68 
70  virtual unsigned int GetImportFlags() const { return 0; }
71 
76  virtual bool Import(void* memory, MemorySource source)
77  {
78  boost::ignore_unused(memory, source);
79  return false;
80  };
81 };
82 
83 }
void * Map(bool blocking=true)
virtual bool Import(void *memory, MemorySource source)
virtual unsigned int GetImportFlags() const
Get flags describing supported import sources.
virtual const void * Map(bool blocking=true) const =0
virtual void CopyOutTo(void *memory) const =0
virtual TensorShape GetShape() const =0
virtual ITensorHandle * GetParent() const =0
virtual void Manage()=0
void Unmap()
Unmap the tensor data that was previously mapped with call to Map().
virtual TensorShape GetStrides() const =0
virtual void Unmap() const =0
Unmap the tensor data.
virtual void CopyInFrom(const void *memory)=0
virtual void Allocate()=0