oneAPI Deep Neural Network Library (oneDNN)
Performance library for Deep Learning
1.8.0
dnnl::engine Struct Reference

An execution engine. More...

#include <dnnl.hpp>

Inheritance diagram for dnnl::engine:
Collaboration diagram for dnnl::engine:

Public Types

enum  kind
 Kinds of engines. More...
 

Public Member Functions

 engine ()=default
 Constructs an empty engine. More...
 
 engine (kind akind, size_t index)
 Constructs an engine. More...
 
 engine (kind akind, cl_device_id device, cl_context context)
 Constructs an engine from OpenCL device and context objects. More...
 
 engine (const handle< dnnl_primitive_desc_t > &pd)
 Constructs an engine based on a primitive from the primitive descriptor pd by querying its engine. More...
 
kind get_kind () const
 Returns the kind of the engine. More...
 
cl_context get_ocl_context () const
 Returns the OpenCL context associated with the engine. More...
 
cl_device_id get_ocl_device () const
 Returns the OpenCL device associated with the engine. More...
 
 handle ()=default
 Constructs an empty handle object. More...
 
 handle (const handle< T, traits > &)=default
 Copy constructor.
 
 handle (handle< T, traits > &&)=default
 Move constructor.
 
 handle (T t, bool weak=false)
 Constructs a handle wrapper object from a C API handle. More...
 
- Public Member Functions inherited from dnnl::handle< dnnl_engine_t >
bool operator== (const handle< dnnl_engine_t, handle_traits< dnnl_engine_t > > &other) const
 Equality operator. More...
 
bool operator!= (const handle &other) const
 Inequality operator. More...
 
 handle ()=default
 Constructs an empty handle object. More...
 
 handle (const handle< dnnl_engine_t, handle_traits< dnnl_engine_t > > &)=default
 Copy constructor.
 
 handle (handle< dnnl_engine_t, handle_traits< dnnl_engine_t > > &&)=default
 Move constructor.
 
 handle (dnnl_engine_t t, bool weak=false)
 Constructs a handle wrapper object from a C API handle. More...
 
handle< dnnl_engine_t, handle_traits< dnnl_engine_t > > & operator= (const handle< dnnl_engine_t, handle_traits< dnnl_engine_t > > &)=default
 Assignment operator.
 
handle< dnnl_engine_t, handle_traits< dnnl_engine_t > > & operator= (handle< dnnl_engine_t, handle_traits< dnnl_engine_t > > &&)=default
 Move assignment operator.
 
void reset (dnnl_engine_t t, bool weak=false)
 Resets the handle wrapper objects to wrap a new C API handle. More...
 
dnnl_engine_t get (bool allow_empty=false) const
 Returns the underlying C API handle. More...
 
 operator dnnl_engine_t () const
 Converts a handle to the underlying C API handle type. More...
 
 operator bool () const
 Checks whether the object is not empty. More...
 

Static Public Member Functions

static size_t get_count (kind akind)
 Returns the number of engines of a certain kind. More...
 
template<typename primitive_desc >
static engine query (const primitive_desc &pd)
 Returns the engine of a primitive descriptor. More...
 

Detailed Description

Member Enumeration Documentation

◆ kind

enum dnnl::engine::kind
strong

Kinds of engines.

Enumerator
any 

An unspecified engine.

cpu 

CPU engine.

gpu 

GPU engine.

Constructor & Destructor Documentation

◆ engine() [1/4]

dnnl::engine::engine ( )
default

Constructs an empty engine.

An empty engine cannot be used in any operations.

◆ engine() [2/4]

dnnl::engine::engine ( kind  akind,
size_t  index 
)
inline

Constructs an engine.

Parameters
akindThe kind of engine to construct.
indexThe index of the engine. Must be less than the value returned by get_count() for this particular kind of engine.

◆ engine() [3/4]

dnnl::engine::engine ( kind  akind,
cl_device_id  device,
cl_context  context 
)
inline

Constructs an engine from OpenCL device and context objects.

Parameters
akindThe kind of engine to construct.
deviceThe OpenCL device that this engine will encapsulate.
contextThe OpenCL context (containing the device) that this engine will use for all operations.

◆ engine() [4/4]

dnnl::engine::engine ( const handle< dnnl_primitive_desc_t > &  pd)
inline

Constructs an engine based on a primitive from the primitive descriptor pd by querying its engine.

Parameters
pdThe primitive descriptor to query.

Member Function Documentation

◆ get_count()

static size_t dnnl::engine::get_count ( kind  akind)
inlinestatic

Returns the number of engines of a certain kind.

Parameters
akindThe kind of engines to count.
Returns
The number of engines of the specified kind.

◆ get_kind()

kind dnnl::engine::get_kind ( ) const
inline

Returns the kind of the engine.

Returns
The kind of the engine.

◆ get_ocl_context()

cl_context dnnl::engine::get_ocl_context ( ) const
inline

Returns the OpenCL context associated with the engine.

Returns
OpenCL context.
Examples
gpu_opencl_interop.cpp.

◆ get_ocl_device()

cl_device_id dnnl::engine::get_ocl_device ( ) const
inline

Returns the OpenCL device associated with the engine.

Returns
OpenCL device.

◆ query()

template<typename primitive_desc >
static engine dnnl::engine::query ( const primitive_desc pd)
inlinestatic

Returns the engine of a primitive descriptor.

Parameters
pdThe primitive descriptor to query.
Returns
A weak handle to the engine that the primitive descriptor was created with.

◆ handle() [1/2]

dnnl::handle< T, traits >::handle
default

Constructs an empty handle object.

Warning
Uninitialized object cannot be used in most library calls and is equivalent to a null pointer. Any attempt to use its methods, or passing it to the other library function, will cause an exception to be thrown.

◆ handle() [2/2]

dnnl::handle< T, traits >::handle
inlineexplicit

Constructs a handle wrapper object from a C API handle.

Parameters
tThe C API handle to wrap.
weakA flag specifying whether to construct a weak wrapper; defaults to false.

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