19 auto runningSize = size;
20 std::vector<unsigned int> strides(shape.GetNumDimensions());
21 auto lastIdx = shape.GetNumDimensions()-1;
22 for (
unsigned int i=0; i < lastIdx ; i++)
24 strides[lastIdx-i] = runningSize;
25 runningSize *= shape[lastIdx-i];
27 strides[0] = runningSize;
28 return TensorShape(shape.GetNumDimensions(), strides.data());
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 memcpy(memory, GetTensor<void>(),
GetTensorInfo().GetNumBytes());
109 void ScopedTensorHandle::CopyInFrom(
const void* memory)
111 memcpy(GetTensor<void>(), memory,
GetTensorInfo().GetNumBytes());
119 void ScopedTensorHandle::CopyFrom(
const void* srcMemory,
unsigned int numBytes)
127 memcpy(GetTensor<void>(), srcMemory, numBytes);
ScopedTensorHandle & operator=(const ScopedTensorHandle &other)
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
const TensorShape & GetShape() const
void SetMemory(void *mem)
TensorHandle(const TensorInfo &tensorInfo)
unsigned int GetNumBytes() const
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
MemoryType GetMemoryArea() const
ScopedTensorHandle(const TensorInfo &tensorInfo)
Copyright (c) 2021 ARM Limited and Contributors.
const TensorInfo & GetTensorInfo() const
ConstTensorHandle(const TensorInfo &tensorInfo)
DataType GetDataType() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
#define ARMNN_ASSERT(COND)
TensorShape GetUnpaddedTensorStrides(const TensorInfo &tensorInfo)
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
const T * GetConstTensor() const
unsigned int GetNumBytes() const
constexpr unsigned int GetDataTypeSize(DataType dataType)