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);