libdl  0.0.1
Simple yet powerful deep learning
Loading...
Searching...
No Matches
dl::TensorPtr Class Referencefinal

The Tensor is a managed pointer to a tensor. It can generally be thought of like an std::unique_ptr<TensorImpl>. More...

#include <tensorptr.hpp>

Public Member Functions

 TensorPtr (TensorPtr &&other)
 
 TensorPtr (const TensorPtr &other)
 
 TensorPtr (std::nullptr_t p)
 
 TensorPtr (int value)
 
 TensorPtr (float value)
 
 TensorPtr (double value)
 
 TensorPtr (InitializerTensor< int > value)
 
 TensorPtr (InitializerTensor< float > value)
 
 TensorPtr (InitializerTensor< double > value)
 
TensorImploperator-> () noexcept
 
const TensorImploperator-> () const noexcept
 
TensorImploperator* () noexcept
 
const TensorImploperator* () const noexcept
 
TensorPtroperator= (const TensorPtr &other)
 
TensorPtroperator= (TensorPtr &&other)
 
bool operator== (const std::nullptr_t &other) const noexcept
 
 operator bool () const noexcept
 

Static Public Member Functions

template<typename T , typename... Args>
static TensorPtr create (Args &&... args) noexcept
 

Detailed Description

The Tensor is a managed pointer to a tensor. It can generally be thought of like an std::unique_ptr<TensorImpl>.

The Tensor's main purpose is implementation hiding, which is especially importan since the concrete tensor implementation could be, e.g., a sparse tensor, a dense tensor or even tensors on different devices (i.e., using different drivers like cuda or xtensor). The implementation, generally, is agnostic to these differences and Tensor hides them.

Definition at line 45 of file tensorptr.hpp.

Constructor & Destructor Documentation

◆ TensorPtr() [1/2]

dl::TensorPtr::TensorPtr ( TensorPtr &&  other)
inline

Definition at line 52 of file tensorptr.hpp.

52: data(std::move(other.data)){};
T move(T... args)

◆ TensorPtr() [2/2]

dl::TensorPtr::TensorPtr ( std::nullptr_t  p)
inline

Definition at line 54 of file tensorptr.hpp.

54: data(p) {}

Member Function Documentation

◆ create()

template<typename T , typename... Args>
static TensorPtr dl::TensorPtr::create ( Args &&...  args)
inlinestaticnoexcept

Definition at line 75 of file tensorptr.hpp.

75 {
76 return TensorPtr(std::make_unique<T>(std::forward<Args>(args)...));
77 }

◆ operator bool()

dl::TensorPtr::operator bool ( ) const
inlinenoexcept

Definition at line 72 of file tensorptr.hpp.

72{ return (bool)data; }

◆ operator*() [1/2]

const TensorImpl & dl::TensorPtr::operator* ( ) const
inlinenoexcept

Definition at line 66 of file tensorptr.hpp.

66{ return *data; }

◆ operator*() [2/2]

TensorImpl & dl::TensorPtr::operator* ( )
inlinenoexcept

Definition at line 65 of file tensorptr.hpp.

65{ return *data; }

◆ operator->() [1/2]

const TensorImpl * dl::TensorPtr::operator-> ( ) const
inlinenoexcept

Definition at line 63 of file tensorptr.hpp.

63{ return data.get(); }

◆ operator->() [2/2]

TensorImpl * dl::TensorPtr::operator-> ( )
inlinenoexcept

Definition at line 62 of file tensorptr.hpp.

62{ return data.get(); }

◆ operator==()

bool dl::TensorPtr::operator== ( const std::nullptr_t other) const
inlinenoexcept

Definition at line 71 of file tensorptr.hpp.

71{ return data == other; }

The documentation for this class was generated from the following file: