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* ConstCpuTensorHandle::GetConstTensor<void>()
const 45 , m_MutableMemory(nullptr)
50 void* CpuTensorHandle::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 ScopedCpuTensorHandle::CopyOutTo(
void* memory)
const 106 memcpy(memory, GetTensor<void>(),
GetTensorInfo().GetNumBytes());
109 void ScopedCpuTensorHandle::CopyInFrom(
const void* memory)
111 memcpy(GetTensor<void>(), memory,
GetTensorInfo().GetNumBytes());
119 void ScopedCpuTensorHandle::CopyFrom(
const void* srcMemory,
unsigned int numBytes)
121 BOOST_ASSERT(GetTensor<void>() ==
nullptr);
127 memcpy(GetTensor<void>(), srcMemory, numBytes);
const TensorShape & GetShape() const
unsigned int GetNumBytes() const
void SetMemory(void *mem)
MemoryType GetMemoryArea() const
const T * GetConstTensor() const
Copyright (c) 2020 ARM Limited.
ScopedCpuTensorHandle & operator=(const ScopedCpuTensorHandle &other)
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
DataType GetDataType() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
TensorShape GetUnpaddedTensorStrides(const TensorInfo &tensorInfo)
ConstCpuTensorHandle(const TensorInfo &tensorInfo)
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.
ScopedCpuTensorHandle(const TensorInfo &tensorInfo)
CpuTensorHandle(const TensorInfo &tensorInfo)
const TensorInfo & GetTensorInfo() const
unsigned int GetNumBytes() const
constexpr unsigned int GetDataTypeSize(DataType dataType)
virtual void Allocate() override
Indicate to the memory manager that this resource is no longer active.