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

Base class for all computational primitives. More...

#include <dnnl.hpp>

Inheritance diagram for dnnl::primitive:
Collaboration diagram for dnnl::primitive:

Public Types

enum  kind
 Kinds of primitives supported by the library. More...
 

Public Member Functions

 primitive ()=default
 Default constructor. Constructs an empty object.
 
 primitive (const_dnnl_primitive_desc_t c_pd)
 Constructs a primitive from a C API primitive descriptor. More...
 
 primitive (const primitive_desc &pd)
 Constructs a primitive from a primitive descriptor. More...
 
const_dnnl_primitive_desc_t get_primitive_desc () const
 Returns the C API primitive descriptor of the underlying C API primitive. More...
 
kind get_kind () const
 Returns the kind of the primitive. More...
 
void execute (const stream &astream, const std::unordered_map< int, memory > &args) const
 Executes computations specified by the primitive in a specified stream. 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_primitive_t >
bool operator== (const handle< dnnl_primitive_t, handle_traits< dnnl_primitive_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_primitive_t, handle_traits< dnnl_primitive_t > > &)=default
 Copy constructor.
 
 handle (handle< dnnl_primitive_t, handle_traits< dnnl_primitive_t > > &&)=default
 Move constructor.
 
 handle (dnnl_primitive_t t, bool weak=false)
 Constructs a handle wrapper object from a C API handle. More...
 
handle< dnnl_primitive_t, handle_traits< dnnl_primitive_t > > & operator= (const handle< dnnl_primitive_t, handle_traits< dnnl_primitive_t > > &)=default
 Assignment operator.
 
handle< dnnl_primitive_t, handle_traits< dnnl_primitive_t > > & operator= (handle< dnnl_primitive_t, handle_traits< dnnl_primitive_t > > &&)=default
 Move assignment operator.
 
void reset (dnnl_primitive_t t, bool weak=false)
 Resets the handle wrapper objects to wrap a new C API handle. More...
 
dnnl_primitive_t get (bool allow_empty=false) const
 Returns the underlying C API handle. More...
 
 operator dnnl_primitive_t () const
 Converts a handle to the underlying C API handle type. More...
 
 operator bool () const
 Checks whether the object is not empty. More...
 

Detailed Description

Base class for all computational primitives.

Member Enumeration Documentation

◆ kind

enum dnnl::primitive::kind
strong

Kinds of primitives supported by the library.

Enumerator
undef 

Undefined primitive.

reorder 

A reorder primitive.

shuffle 

A shuffle primitive.

concat 

A (out-of-place) tensor concatenation primitive.

sum 

A summation primitive.

convolution 

A convolution primitive.

deconvolution 

A deconvolution primitive.

eltwise 

An element-wise primitive.

softmax 

A softmax primitive.

pooling 

A pooling primitive.

lrn 

An LRN primitive.

batch_normalization 

A batch normalization primitive.

layer_normalization 

A layer normalization primitive.

inner_product 

An inner product primitive.

rnn 

An RNN primitive.

binary 

A binary primitive.

logsoftmax 

A logsoftmax primitive.

matmul 

A matmul (matrix multiplication) primitive.

resampling 

A resampling primitive.

pooling_v2 

A pooling version 2 primitive.

reduction 

A reduction primitive.

prelu 

A PReLU primitive.

Constructor & Destructor Documentation

◆ primitive() [1/2]

dnnl::primitive::primitive ( const_dnnl_primitive_desc_t  c_pd)

Constructs a primitive from a C API primitive descriptor.

Parameters
c_pdC API primitive descriptor.

◆ primitive() [2/2]

dnnl::primitive::primitive ( const primitive_desc pd)

Constructs a primitive from a primitive descriptor.

Parameters
pdPrimitive descriptor.

Member Function Documentation

◆ execute()

void dnnl::primitive::execute ( const stream astream,
const std::unordered_map< int, memory > &  args 
) const

Executes computations specified by the primitive in a specified stream.

Arguments are passed via an arguments map containing <index, memory object> pairs. The index must be one of the DNNL_ARG_* values such as DNNL_ARG_SRC, and the memory must have a memory descriptor matching the one returned by primitive_desc::query_md(query::exec_arg_md, index) unless using dynamic shapes (see DNNL_RUNTIME_DIM_VAL).

Parameters
astreamStream object. The stream must belong to the same engine as the primitive.
argsArguments map.
Examples:
cpu_sgemm_and_matmul.cpp, inference_int8_matmul.cpp, and rnn_training_f32.cpp.

◆ 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: