A wrapper around a TensorLike that adds buffer ownership. More...
#include <TensorOwner.hpp>
Public Types | |
using | ValueType = typename TensorType::ValueType |
using | Type = typename TensorType::Type |
Public Member Functions | |
template<typename... Args> | |
TensorOwner (sp::UniquePtr< Type > &&inBuffer, Args &&... args) | |
Construct from a unique pointer, and take ownership of it. Behaviour is undefined if the buffer is too small. More... | |
TensorOwner ()=default | |
Creates an uninitialised TensorOwner. More... | |
operator TensorType () const | |
Implicitly convert to the underlying TensorLike. More... | |
auto | get () const |
Explicitly convert to the underlying TensorLike. More... | |
template<typename std::enable_if<!std::is_same_v< TensorType, typename TensorType::ConstTensor >, int >::type = 0> | |
operator typename TensorType::ConstTensor () const | |
Implicitly convert to the underlying TensorLike. More... | |
auto | data () |
Allow access to the buffer (since a common use-case is initialisation). More... | |
auto | data () const |
Static Public Attributes | |
constexpr static int | Rank = TensorType::Rank |
A wrapper around a TensorLike that adds buffer ownership.
Typically, this is used indirectly via libSCALE's Device or Host objects. Something like:
Objects allocated in this way will automatically be unallocated when they go out of scope, and will implicitly convert to the underlying TensorLike type. Usually, you'll create some TensorOwner<T>
s to own the memory, and pass them (with an implicit conversion) to functions/kernels that accept T
to do the actual processing.
sp::TensorOwner< TensorType >::TensorOwner | ( | sp::UniquePtr< Type > && | inBuffer, |
Args &&... | args | ||
) |
Construct from a unique pointer, and take ownership of it. Behaviour is undefined if the buffer is too small.
|
default |
Creates an uninitialised TensorOwner.
auto sp::TensorOwner< TensorType >::data | ( | ) |
Allow access to the buffer (since a common use-case is initialisation).
auto sp::TensorOwner< TensorType >::get | ( | ) | const |
Explicitly convert to the underlying TensorLike.
sp::TensorOwner< TensorType >::operator TensorType | ( | ) | const |
Implicitly convert to the underlying TensorLike.
sp::TensorOwner< TensorType >::operator typename TensorType::ConstTensor | ( | ) | const |
Implicitly convert to the underlying TensorLike.