Skip to content
Snippets Groups Projects
Commit 541967f1 authored by Olivier BICHLER's avatar Olivier BICHLER Committed by Maxence Naud
Browse files

Improved specifications

parent 48ecdca1
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ namespace Aidge {
template <class T>
class TensorImpl_cpu : public TensorImpl {
static_assert(std::is_trivially_copyable<T>::value, "TensorImpl type should be trivially copyable");
private:
/// Pointer to the data and its capacity
future_std::span<T> mData;
......
......@@ -529,6 +529,7 @@ public:
template <typename expectedType>
const expectedType& get(std::size_t idx) const {
AIDGE_ASSERT(NativeType<expectedType>::type == mDataType, "wrong data type");
AIDGE_ASSERT(mImpl->hostPtr() != nullptr, "get() can only be used for backends providing a valid host pointer");
AIDGE_ASSERT(idx < mSize, "idx out of range");
return *reinterpret_cast<expectedType *>(mImpl->hostPtr(mImplOffset + idx));
}
......@@ -541,6 +542,7 @@ public:
template <typename expectedType>
void set(std::size_t idx, expectedType value){
AIDGE_ASSERT(NativeType<expectedType>::type == mDataType, "wrong data type");
AIDGE_ASSERT(mImpl->hostPtr() != nullptr, "get() can only be used for backends providing a valid host pointer");
AIDGE_ASSERT(idx < mSize, "idx out of range");
expectedType* dataPtr = static_cast<expectedType*>(mImpl->hostPtr(mImplOffset + idx));
*dataPtr = value;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment