Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::TensorPtr< T, IsHostAccessible > Class Template Referenceexport

Base tensor pointer class that wraps a raw pointer with memory-type safety. More...

Public Member Functions

 TensorPtr (T *ptr) noexcept
 Constructs a new TensorPtr.
 
T * get () const noexcept
 Gets the raw pointer (explicit conversion)
 
 operator T* () const
 Explicit conversion to raw pointer for CUDA kernels.
 
T & operator* () const
 Host-only: Dereference operator.
 
TensorPtr operator+ (size_t offset) const
 Host-only: Pointer addition.
 
T & operator[] (size_t index) const
 Host-only: Subscript operator.
 

Private Attributes

T * ptr_
 

Detailed Description

template<typename T, bool IsHostAccessible>
class Mila::Dnn::TensorPtr< T, IsHostAccessible >

Base tensor pointer class that wraps a raw pointer with memory-type safety.

Template Parameters
TPrecisionElement type
IsHostAccessibleWhether the pointer points to host-accessible memory

Constructor & Destructor Documentation

◆ TensorPtr()

template<typename T , bool IsHostAccessible>
Mila::Dnn::TensorPtr< T, IsHostAccessible >::TensorPtr ( T *  ptr)
inlineexplicitnoexcept

Constructs a new TensorPtr.

Parameters
ptrRaw pointer to wrap

Member Function Documentation

◆ get()

template<typename T , bool IsHostAccessible>
T * Mila::Dnn::TensorPtr< T, IsHostAccessible >::get ( ) const
inlinenoexcept

Gets the raw pointer (explicit conversion)

Returns
TPrecision* Raw pointer
Here is the caller graph for this function:

◆ operator T*()

template<typename T , bool IsHostAccessible>
Mila::Dnn::TensorPtr< T, IsHostAccessible >::operator T* ( ) const
inline

Explicit conversion to raw pointer for CUDA kernels.

Returns
Raw pointer for use in CUDA kernels

◆ operator*()

template<typename T , bool IsHostAccessible>
T & Mila::Dnn::TensorPtr< T, IsHostAccessible >::operator* ( ) const
inline

Host-only: Dereference operator.

Returns
Reference to the element
Exceptions
std::runtime_errorif memory is not host-accessible

◆ operator+()

template<typename T , bool IsHostAccessible>
TensorPtr Mila::Dnn::TensorPtr< T, IsHostAccessible >::operator+ ( size_t  offset) const
inline

Host-only: Pointer addition.

Parameters
offsetOffset to add
Returns
TensorPtr at the offset position
Exceptions
std::runtime_errorif memory is not host-accessible

◆ operator[]()

template<typename T , bool IsHostAccessible>
T & Mila::Dnn::TensorPtr< T, IsHostAccessible >::operator[] ( size_t  index) const
inline

Host-only: Subscript operator.

Parameters
indexElement index
Returns
Reference to the element
Exceptions
std::runtime_errorif memory is not host-accessible

Member Data Documentation

◆ ptr_

template<typename T , bool IsHostAccessible>
T* Mila::Dnn::TensorPtr< T, IsHostAccessible >::ptr_
private

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