19 auto runningSize = size;
22 for (
unsigned int i=0; i < lastIdx ; i++)
24 strides[lastIdx-i] = runningSize;
25 runningSize *= shape[lastIdx-i];
27 strides[0] = runningSize;
32 : m_TensorInfo(tensorInfo)
38 const void* ConstTensorHandle::GetConstTensor<void>()
const
45 , m_MutableMemory(nullptr)
50 void* TensorHandle::GetTensor<void>()
const
52 return m_MutableMemory;
80 ::operator
delete(GetTensor<void>());
88 ::operator
delete(GetTensor<void>());
93 if (GetTensor<void>() ==
nullptr)
100 "that already has allocated memory.");
104 void ScopedTensorHandle::CopyOutTo(
void* memory)
const
106 const void* src = GetTensor<void>();
111 if (memory ==
nullptr)
113 throw NullPointerException(
"TensorHandle::CopyOutTo called with a null dest pointer");
118 void ScopedTensorHandle::CopyInFrom(
const void* memory)
120 void* dest = GetTensor<void>();
123 throw NullPointerException(
"TensorHandle::CopyInFrom called with a null dest pointer");
125 if (memory ==
nullptr)
127 throw NullPointerException(
"TensorHandle::CopyInFrom called with a null src pointer");
132 void ScopedTensorHandle::CopyFrom(
const ScopedTensorHandle& other)
134 CopyFrom(other.GetTensor<
void>(), other.GetTensorInfo().GetNumBytes());
137 void ScopedTensorHandle::CopyFrom(
const void* srcMemory,
unsigned int numBytes)
139 if (GetTensor<void>() !=
nullptr)
141 throw NullPointerException(
"TensorHandle::CopyFrom called on an already allocated TensorHandle");
145 std::stringstream msg;
147 ") does not match the number of bytes being copied (" << numBytes <<
")";
154 memcpy(GetTensor<void>(), srcMemory, numBytes);
MemoryType GetMemoryArea() const
unsigned int GetNumBytes() const
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
ConstTensorHandle(const TensorInfo &tensorInfo)
const T * GetConstTensor() const
const TensorInfo & GetTensorInfo() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Base class for all ArmNN exceptions so that users can filter to just those.
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
ScopedTensorHandle(const TensorInfo &tensorInfo)
ScopedTensorHandle & operator=(const ScopedTensorHandle &other)
void SetMemory(void *mem)
TensorHandle(const TensorInfo &tensorInfo)
const TensorShape & GetShape() const
unsigned int GetNumBytes() const
DataType GetDataType() const
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Copyright (c) 2021 ARM Limited and Contributors.
TensorShape GetUnpaddedTensorStrides(const TensorInfo &tensorInfo)
constexpr unsigned int GetDataTypeSize(DataType dataType)
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers