2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
22 virtual ~ITensorHandle(){}
24 /// Indicate to the memory manager that this resource is active.
25 /// This is used to compute overlapping lifetimes of resources.
26 virtual void Manage() = 0;
28 /// Indicate to the memory manager that this resource is no longer active.
29 /// This is used to compute overlapping lifetimes of resources.
30 virtual void Allocate() = 0;
32 /// Get the type backend associated with the tensor handle.
34 virtual ITensorHandle::Type GetType() const = 0;
36 /// Get the parent tensor if this is a subtensor.
37 /// \return a pointer to the parent tensor. Otherwise nullptr if not a subtensor.
38 virtual ITensorHandle* GetParent() const = 0;
40 /// Map the tensor data for access.
41 /// \param blocking hint to block the calling thread until all other accesses are complete. (backend dependent)
42 /// \return pointer to the first element of the mapped data.
43 virtual const void* Map(bool blocking=true) const = 0;
45 /// Unmap the tensor data
46 virtual void Unmap() const = 0;
48 /// Map the tensor data for access. Must be paired with call to Unmap().
49 /// \param blocking hint to block the calling thread until all other accesses are complete. (backend dependent)
50 /// \return pointer to the first element of the mapped data.
51 void* Map(bool blocking=true)
53 return const_cast<void*>(static_cast<const ITensorHandle*>(this)->Map(blocking));
56 /// Unmap the tensor data that was previously mapped with call to Map().
59 return static_cast<const ITensorHandle*>(this)->Unmap();
62 /// Get the strides for each dimension ordered from largest to smallest where
63 /// the smallest value is the same as the size of a single element in the tensor.
64 /// \return a TensorShape filled with the strides for each dimension
65 virtual TensorShape GetStrides() const = 0;
67 /// Get the number of elements for each dimension orderd from slowest iterating dimension
68 /// to fastest iterating dimension.
69 /// \return a TensorShape filled with the number of elements for each dimension.
70 virtual TensorShape GetShape() const = 0;