A class for wrapping an DNNL handle.
More...
#include <dnnl.hpp>
|
| | handle ()=default |
| | Empty constructor. More...
|
| |
| | handle (T t, bool weak=false) |
| | Constructs a C handle wrapper from a C handle. More...
|
| |
| void | reset (T t, bool weak=false) |
| | Resets the value of a C handle. More...
|
| |
|
T | get (bool allow_emtpy=false) const |
| | Returns the value of the underlying C handle.
|
| |
template<typename T, typename traits = handle_traits<T>>
class dnnl::handle< T, traits >
A class for wrapping an DNNL handle.
It is used as the base class for primitive (dnnl_primitive_t), engine (dnnl_engine_t), and stream (dnnl_stream_t) handles. An object of the dnnl::handle class can be passed by value. This class enables wrapping:
- Newly constructed handles.
In this case, the constructed handle uses reference counting provided by std::shared_ptr with a proper deleter function specified through the handle_traits class.
- Pre-existing handles returned by the DNNL C API (for example, through dnnl_primitive_get_primitive_desc()).
In this case, an DNNL C API handle is wrapped without a deleter because it is assumed that the handle wrapper for the original object deletes the handle (this model is similar to std::weak_ptr).
◆ handle() [1/2]
template<typename T, typename traits = handle_traits<T>>
Empty constructor.
Allows declaring an object before actual initialization (mostly for convenience).
- Warning
- Uninitialized object cannot be used in any library calls. Any attempt to use its methods or passing it to the other library function will lead to a thrown exception.
◆ handle() [2/2]
template<typename T, typename traits = handle_traits<T>>
Constructs a C handle wrapper from a C handle.
- Parameters
-
| t | The C handle to wrap. |
| weak | A flag to specify whether to construct a weak wrapper. |
◆ reset()
template<typename T, typename traits = handle_traits<T>>
| void dnnl::handle< T, traits >::reset |
( |
T |
t, |
|
|
bool |
weak = false |
|
) |
| |
|
inline |
Resets the value of a C handle.
- Parameters
-
| t | The new value of the C handle. |
| weak | A flag to specify whether the wrapper should be weak. |
The documentation for this class was generated from the following file: