18 auto runningSize = size;
19 std::vector<unsigned int> strides(shape.GetNumDimensions());
20 auto lastIdx = shape.GetNumDimensions()-1;
21 for (
unsigned int i=0; i < lastIdx ; i++)
23 strides[lastIdx-i] = runningSize;
24 runningSize *= shape[lastIdx-i];
26 strides[0] = runningSize;
27 return TensorShape(shape.GetNumDimensions(), strides.data());
31 : m_TensorInfo(tensorInfo)
37 const void* ConstCpuTensorHandle::GetConstTensor<void>()
const 44 , m_MutableMemory(nullptr)
49 void* CpuTensorHandle::GetTensor<void>()
const 51 return m_MutableMemory;
79 ::operator
delete(GetTensor<void>());
87 ::operator
delete(GetTensor<void>());
92 if (GetTensor<void>() ==
nullptr)
99 "that already has allocated memory.");
103 void ScopedCpuTensorHandle::CopyOutTo(
void* memory)
const 105 memcpy(memory, GetTensor<void>(),
GetTensorInfo().GetNumBytes());
108 void ScopedCpuTensorHandle::CopyInFrom(
const void* memory)
110 memcpy(GetTensor<void>(), memory,
GetTensorInfo().GetNumBytes());
118 void ScopedCpuTensorHandle::CopyFrom(
const void* srcMemory,
unsigned int numBytes)
120 BOOST_ASSERT(GetTensor<void>() ==
nullptr);
126 memcpy(GetTensor<void>(), srcMemory, numBytes);
const T * GetConstTensor() const
unsigned int GetNumBytes() const
CpuTensorHandle(const TensorInfo &tensorInfo)
const TensorInfo & GetTensorInfo() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
ConstCpuTensorHandle(const TensorInfo &tensorInfo)
void SetMemory(void *mem)
ScopedCpuTensorHandle & operator=(const ScopedCpuTensorHandle &other)
constexpr unsigned int GetDataTypeSize(DataType dataType)
TensorShape GetUnpaddedTensorStrides(const TensorInfo &tensorInfo)
ScopedCpuTensorHandle(const TensorInfo &tensorInfo)
unsigned int GetNumBytes() const
virtual void Allocate() override
DataType GetDataType() const
MemoryType GetMemoryArea() const
virtual void Allocate() override
virtual void Allocate() override
const TensorShape & GetShape() const