DNNL C API handle wrapper class. More...
#include <dnnl.hpp>
Public Member Functions | |
handle ()=default | |
Constructs an empty handle object. More... | |
handle (const handle< T, traits > &)=default | |
Copy constructor. | |
handle< T, traits > & | operator= (const handle< T, traits > &)=default |
Assignment operator. | |
handle (handle< T, traits > &&)=default | |
Move constructor. | |
handle< T, traits > & | operator= (handle< T, traits > &&)=default |
Move assignment operator. | |
handle (T t, bool weak=false) | |
Constructs a handle wrapper object from a C API handle. More... | |
void | reset (T t, bool weak=false) |
Resets the handle wrapper objects to wrap a new C API handle. More... | |
T | get (bool allow_empty=false) const |
Returns the underlying C API handle. More... | |
operator T () const | |
Converts a handle to the underlying C API handle type. More... | |
operator bool () const | |
Checks whether the object is empty. More... | |
bool | operator== (const handle< T, traits > &other) const |
Equality operator. More... | |
bool | operator!= (const handle &other) const |
Inequality operator. More... | |
DNNL C API handle wrapper class.
This class is used as the base class for primitive (dnnl::primitive), engine (dnnl::engine), and stream (dnnl::stream) classes, as well as others. An object of the dnnl::handle class can be passed by value.
A handle can be weak, in which case it follows std::weak_ptr semantics. Otherwise, it follows std::shared_ptr
semantics.
std::shared_ptr
with deleter set to a dummy function in the weak mode.
|
default |
Constructs an empty handle object.
|
inlineexplicit |
Constructs a handle wrapper object from a C API handle.
t | The C API handle to wrap. |
weak | A flag specifying whether to construct a weak wrapper; defaults to false . |
|
inline |
Resets the handle wrapper objects to wrap a new C API handle.
t | The new value of the C API handle. |
weak | A flag specifying whether the wrapper should be weak; defaults to false . |
|
inline |
Returns the underlying C API handle.
allow_empty | A flag signifying whether the method is allowed to return an empty (null) object without throwing an exception. |
|
inlineexplicit |
Converts a handle to the underlying C API handle type.
Does not throw and returns nullptr
if the object is empty.
|
inlineexplicit |
Checks whether the object is empty.
|
inline |
Equality operator.
other | Another handle wrapper. |
true
if this and the other handle wrapper manage the same underlying C API handle, and false
otherwise. Empty handle objects are considered to be equal.
|
inline |
Inequality operator.
other | Another handle wrapper. |
true
if this and the other handle wrapper manage different underlying C API handles, and false
otherwise. Empty handle objects are considered to be equal.