Deep Neural Network Library (DNNL)  1.3.0
Performance library for Deep Learning
Classes | Macros | Typedefs | Enumerations | Functions

Common operations to create, destroy and inspect primitives. More...

Classes

struct  dnnl::primitive
 Base class for all computational primitives. More...
 
struct  dnnl::primitive_desc_base
 Base class for all primitive descriptors. More...
 
struct  dnnl::primitive_desc
 A base class for descriptors of all primitives that have an operation descriptor and that support iteration over multiple implementations. More...
 
struct  dnnl_exec_arg_t
 A structure that contains an index and a memory object, and is used to pass arguments to dnnl_primitive_execute(). More...
 
struct  dnnl_primitive_desc_iterator
 An opaque structure to describe a primitive descriptor iterator. More...
 
struct  dnnl_primitive_desc
 An opaque structure to describe a primitive descriptor. More...
 
struct  dnnl_primitive
 An opaque structure to describe a primitive. More...
 

Macros

#define DNNL_ARG_SRC_0   1
 Source argument #0.
 
#define DNNL_ARG_SRC   DNNL_ARG_SRC_0
 A special mnemonic for source argument for primitives that have a single source. More...
 
#define DNNL_ARG_SRC_LAYER   DNNL_ARG_SRC_0
 A special mnemonic for RNN input vector. More...
 
#define DNNL_ARG_FROM   DNNL_ARG_SRC_0
 A special mnemonic for reorder source argument. More...
 
#define DNNL_ARG_SRC_1   2
 Source argument #1.
 
#define DNNL_ARG_SRC_ITER   DNNL_ARG_SRC_1
 A special mnemonic for RNN input recurrent hidden state vector. More...
 
#define DNNL_ARG_SRC_2   3
 Source argument #2.
 
#define DNNL_ARG_SRC_ITER_C   DNNL_ARG_SRC_2
 A special mnemonic for RNN input recurrent cell state vector. More...
 
#define DNNL_ARG_DST_0   17
 Destination argument #0.
 
#define DNNL_ARG_DST   DNNL_ARG_DST_0
 A special mnemonic for destination argument for primitives that have a single destination. More...
 
#define DNNL_ARG_TO   DNNL_ARG_DST_0
 A special mnemonic for reorder destination argument. More...
 
#define DNNL_ARG_DST_LAYER   DNNL_ARG_DST_0
 A special mnemonic for RNN output vector. An alias for DNNL_ARG_DST_0.
 
#define DNNL_ARG_DST_1   18
 Destination argument #1.
 
#define DNNL_ARG_DST_ITER   DNNL_ARG_DST_1
 A special mnemonic for RNN input recurrent hidden state vector. More...
 
#define DNNL_ARG_DST_2   19
 Destination argument #2.
 
#define DNNL_ARG_DST_ITER_C   DNNL_ARG_DST_2
 A special mnemonic for LSTM output recurrent cell state vector. More...
 
#define DNNL_ARG_WEIGHTS_0   33
 Weights argument #0.
 
#define DNNL_ARG_WEIGHTS   DNNL_ARG_WEIGHTS_0
 A special mnemonic for primitives that have a single weights argument. More...
 
#define DNNL_ARG_SCALE_SHIFT   DNNL_ARG_WEIGHTS_0
 A special mnemonic for scale and shift argument of normalization primitives. More...
 
#define DNNL_ARG_WEIGHTS_LAYER   DNNL_ARG_WEIGHTS_0
 A special mnemonic for RNN weights applied to the layer input. More...
 
#define DNNL_ARG_WEIGHTS_1   34
 Weights argument #1.
 
#define DNNL_ARG_WEIGHTS_ITER   DNNL_ARG_WEIGHTS_1
 A special mnemonic for RNN weights applied to the recurrent input. More...
 
#define DNNL_ARG_WEIGHTS_2   35
 Weights argument #2.
 
#define DNNL_ARG_WEIGHTS_PEEPHOLE   DNNL_ARG_WEIGHTS_2
 A special mnemonic for RNN weights applied to the peephole weights. More...
 
#define DNNL_ARG_BIAS   41
 Bias tensor argument.
 
#define DNNL_ARG_MEAN   49
 Mean values tensor argument.
 
#define DNNL_ARG_VARIANCE   50
 Variance values tensor argument.
 
#define DNNL_ARG_WORKSPACE   64
 Workspace tensor argument. More...
 
#define DNNL_ARG_SCRATCHPAD   80
 Scratchpad (temporary storage) tensor argument.
 
#define DNNL_ARG_DIFF_SRC_0   129
 Gradient (diff) of the source argument #0.
 
#define DNNL_ARG_DIFF_SRC   DNNL_ARG_DIFF_SRC_0
 A special mnemonic for primitives that have a single diff source argument. More...
 
#define DNNL_ARG_DIFF_SRC_LAYER   DNNL_ARG_DIFF_SRC_0
 A special mnemonic for gradient (diff) of RNN input vector. More...
 
#define DNNL_ARG_DIFF_SRC_1   130
 Gradient (diff) of the source argument #1.
 
#define DNNL_ARG_DIFF_SRC_ITER   DNNL_ARG_DIFF_SRC_1
 A special mnemonic for gradient (diff) of RNN input recurrent hidden state vector. More...
 
#define DNNL_ARG_DIFF_SRC_2   131
 Gradient (diff) of the source argument #2.
 
#define DNNL_ARG_DIFF_SRC_ITER_C   DNNL_ARG_DIFF_SRC_2
 A special mnemonic for gradient (diff) of RNN input recurrent cell state vector. More...
 
#define DNNL_ARG_DIFF_DST_0   145
 Gradient (diff) of the destination argument #0.
 
#define DNNL_ARG_DIFF_DST   DNNL_ARG_DIFF_DST_0
 A special mnemonic for primitives that have a single diff destination argument. More...
 
#define DNNL_ARG_DIFF_DST_LAYER   DNNL_ARG_DIFF_DST_0
 A special mnemonic for gradient (diff) of RNN output vector. More...
 
#define DNNL_ARG_DIFF_DST_1   146
 Gradient (diff) of the destination argument #1.
 
#define DNNL_ARG_DIFF_DST_ITER   DNNL_ARG_DIFF_DST_1
 A special mnemonic for gradient (diff) of RNN input recurrent hidden state vector. More...
 
#define DNNL_ARG_DIFF_DST_2   147
 Gradient (diff) of the destination argument #2.
 
#define DNNL_ARG_DIFF_DST_ITER_C   DNNL_ARG_DIFF_DST_2
 A special mnemonic for gradient (diff) of RNN input recurrent cell state vector. More...
 
#define DNNL_ARG_DIFF_WEIGHTS_0   161
 Gradient (diff) of the weights argument #0.
 
#define DNNL_ARG_DIFF_WEIGHTS   DNNL_ARG_DIFF_WEIGHTS_0
 A special mnemonic for primitives that have a single diff weights argument. More...
 
#define DNNL_ARG_DIFF_SCALE_SHIFT   DNNL_ARG_DIFF_WEIGHTS_0
 A special mnemonic for diff of scale and shift argument of normalization primitives. More...
 
#define DNNL_ARG_DIFF_WEIGHTS_LAYER   DNNL_ARG_DIFF_WEIGHTS_0
 A special mnemonic for diff of RNN weights applied to the layer input. More...
 
#define DNNL_ARG_DIFF_WEIGHTS_1   162
 Gradient (diff) of the weights argument #1.
 
#define DNNL_ARG_DIFF_WEIGHTS_ITER   DNNL_ARG_DIFF_WEIGHTS_1
 A special mnemonic for diff of RNN weights applied to the recurrent input. More...
 
#define DNNL_ARG_DIFF_WEIGHTS_2   163
 Gradient (diff) of the weights argument #2.
 
#define DNNL_ARG_DIFF_WEIGHTS_PEEPHOLE   DNNL_ARG_DIFF_WEIGHTS_2
 A special mnemonic for diff of RNN weights applied to the peephole weights. More...
 
#define DNNL_ARG_DIFF_BIAS   169
 Gradient (diff) of the bias tensor argument.
 
#define DNNL_ARG_ATTR_OUTPUT_SCALES   513
 Output scaling factors provided at execution time.
 
#define DNNL_ARG_MULTIPLE_SRC   1024
 Starting index for source arguments for primitives that take a variable number of source arguments. More...
 
#define DNNL_ARG_MULTIPLE_DST   2048
 Starting index for destination arguments for primitives that produce a variable number of destination arguments. More...
 
#define DNNL_ARG_ATTR_ZERO_POINTS   4096
 Zero points provided at execution time.
 
#define DNNL_ARG_ATTR_POST_OP_DW   8192
 Arguments for fused depthwise convolution. More...
 

Typedefs

typedef void * dnnl_op_desc_t
 A pointer to any of the operation descriptors.
 
typedef const void * const_dnnl_op_desc_t
 A pointer to any of the operation descriptors (constant variant).
 
typedef struct dnnl_primitive_desc_iteratordnnl_primitive_desc_iterator_t
 A primitive descriptor iterator handle.
 
typedef const struct dnnl_primitive_desc_iteratorconst_dnnl_primitive_desc_iterator_t
 A constant primitive descriptor iterator handle.
 
typedef struct dnnl_primitive_descdnnl_primitive_desc_t
 A primitive descriptor handle.
 
typedef const struct dnnl_primitive_descconst_dnnl_primitive_desc_t
 A constant primitive descriptor handle.
 
typedef struct dnnl_primitivednnl_primitive_t
 A primitive handle.
 
typedef const struct dnnl_primitiveconst_dnnl_primitive_t
 A constant primitive handle.
 

Enumerations

enum  dnnl::normalization_flags : unsigned
 Flags for normalization primitives. More...
 
enum  dnnl::query
 Primitive descriptor query specification. More...
 
enum  dnnl_prop_kind_t
 Kinds of propagation. More...
 
enum  dnnl_primitive_kind_t
 Kinds of primitives. More...
 
enum  dnnl_alg_kind_t
 Kinds of algorithms. More...
 
enum  dnnl_normalization_flags_t
 Flags for batch normalization primitive. More...
 
enum  dnnl_query_t
 Primitive descriptor query specification. More...
 

Functions

dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_create (dnnl_primitive_desc_iterator_t *iterator, const_dnnl_op_desc_t op_desc, const_dnnl_primitive_attr_t attr, dnnl_engine_t engine, const_dnnl_primitive_desc_t hint_forward_primitive_desc)
 Creates a primitive descriptor iterator. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_next (dnnl_primitive_desc_iterator_t iterator)
 Advances the primitive descriptor iterator to point to the next available implementation. More...
 
dnnl_primitive_desc_t DNNL_API dnnl_primitive_desc_iterator_fetch (const_dnnl_primitive_desc_iterator_t iterator)
 Fetches the current primitive descriptor from a primitive descriptor iterator. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_destroy (dnnl_primitive_desc_iterator_t iterator)
 Destroys a primitive descriptor iterator. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_create (dnnl_primitive_desc_t *primitive_desc, const_dnnl_op_desc_t op_desc, const_dnnl_primitive_attr_t attr, dnnl_engine_t engine, const_dnnl_primitive_desc_t hint_forward_primitive_desc)
 Creates a primitive descriptor. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_clone (dnnl_primitive_desc_t *primitive_desc, const_dnnl_primitive_desc_t existing_primitive_desc)
 Clones a primitive descriptor. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_get_attr (const_dnnl_primitive_desc_t primitive_desc, const_dnnl_primitive_attr_t *attr)
 Returns a constant reference to the attributes of a primitive descriptor. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_destroy (dnnl_primitive_desc_t primitive_desc)
 Destroys a primitive descriptor. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_query (const_dnnl_primitive_desc_t primitive_desc, dnnl_query_t what, int index, void *result)
 Queries a primitive descriptor for various pieces of information. More...
 
const dnnl_memory_desc_t DNNL_API * dnnl_primitive_desc_query_md (const_dnnl_primitive_desc_t primitive_desc, dnnl_query_t what, int index)
 Queries primitive descriptor for a memory descriptor. More...
 
int DNNL_API dnnl_primitive_desc_query_s32 (const_dnnl_primitive_desc_t primitive_desc, dnnl_query_t what, int index)
 Queries primitive descriptor for a signed 32bit int. More...
 
dnnl_status_t DNNL_API dnnl_primitive_create (dnnl_primitive_t *primitive, const_dnnl_primitive_desc_t primitive_desc)
 Creates a primitive. More...
 
dnnl_status_t DNNL_API dnnl_primitive_execute (const_dnnl_primitive_t primitive, dnnl_stream_t stream, int nargs, const dnnl_exec_arg_t *args)
 Executes a primitive. More...
 
dnnl_status_t DNNL_API dnnl_primitive_get_primitive_desc (const_dnnl_primitive_t primitive, const_dnnl_primitive_desc_t *primitive_desc)
 Retrieves a constant reference to the primitive descriptor of a given primitive. More...
 
dnnl_status_t DNNL_API dnnl_primitive_destroy (dnnl_primitive_t primitive)
 Destroys a primitive. More...
 
dnnl_primitive_kind_t dnnl::convert_to_c (primitive::kind kind)
 Converts primitive kind enum value from C++ API to C API type. More...
 
dnnl_normalization_flags_t dnnl::convert_to_c (normalization_flags flags)
 Converts normalization flags enum value from C++ API to C API type. More...
 
dnnl_query_t dnnl::convert_to_c (query query)
 Converts query enum value from C++ API to C API type. More...
 
const_dnnl_primitive_desc_t dnnl::primitive::get_primitive_desc () const
 Returns the C API primitive descriptor of the underlying C API primitive. More...
 
kind dnnl::primitive::get_kind () const
 Returns the kind of the primitive. More...
 

Detailed Description

Common operations to create, destroy and inspect primitives.

Macro Definition Documentation

◆ DNNL_ARG_SRC

#define DNNL_ARG_SRC   DNNL_ARG_SRC_0

◆ DNNL_ARG_SRC_LAYER

#define DNNL_ARG_SRC_LAYER   DNNL_ARG_SRC_0

A special mnemonic for RNN input vector.

An alias for DNNL_ARG_SRC_0.

Examples:
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ DNNL_ARG_FROM

#define DNNL_ARG_FROM   DNNL_ARG_SRC_0

◆ DNNL_ARG_SRC_ITER

#define DNNL_ARG_SRC_ITER   DNNL_ARG_SRC_1

A special mnemonic for RNN input recurrent hidden state vector.

An alias for DNNL_ARG_SRC_1.

Examples:
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ DNNL_ARG_SRC_ITER_C

#define DNNL_ARG_SRC_ITER_C   DNNL_ARG_SRC_2

A special mnemonic for RNN input recurrent cell state vector.

An alias for DNNL_ARG_SRC_2.

Examples:
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ DNNL_ARG_DST

#define DNNL_ARG_DST   DNNL_ARG_DST_0

◆ DNNL_ARG_TO

#define DNNL_ARG_TO   DNNL_ARG_DST_0

◆ DNNL_ARG_DST_ITER

#define DNNL_ARG_DST_ITER   DNNL_ARG_DST_1

A special mnemonic for RNN input recurrent hidden state vector.

An alias for DNNL_ARG_DST_1.

Examples:
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ DNNL_ARG_DST_ITER_C

#define DNNL_ARG_DST_ITER_C   DNNL_ARG_DST_2

A special mnemonic for LSTM output recurrent cell state vector.

An alias for DNNL_ARG_DST_2.

Examples:
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ DNNL_ARG_WEIGHTS

#define DNNL_ARG_WEIGHTS   DNNL_ARG_WEIGHTS_0

◆ DNNL_ARG_SCALE_SHIFT

#define DNNL_ARG_SCALE_SHIFT   DNNL_ARG_WEIGHTS_0

A special mnemonic for scale and shift argument of normalization primitives.

Alias for DNNL_ARG_WEIGHTS_0.

◆ DNNL_ARG_WEIGHTS_LAYER

#define DNNL_ARG_WEIGHTS_LAYER   DNNL_ARG_WEIGHTS_0

A special mnemonic for RNN weights applied to the layer input.

An alias for DNNL_ARG_WEIGHTS_0.

Examples:
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ DNNL_ARG_WEIGHTS_ITER

#define DNNL_ARG_WEIGHTS_ITER   DNNL_ARG_WEIGHTS_1

A special mnemonic for RNN weights applied to the recurrent input.

An alias for DNNL_ARG_WEIGHTS_1.

Examples:
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ DNNL_ARG_WEIGHTS_PEEPHOLE

#define DNNL_ARG_WEIGHTS_PEEPHOLE   DNNL_ARG_WEIGHTS_2

A special mnemonic for RNN weights applied to the peephole weights.

An alias for DNNL_ARG_WEIGHTS_2.

◆ DNNL_ARG_WORKSPACE

#define DNNL_ARG_WORKSPACE   64

Workspace tensor argument.

Workspace is used to pass information from forward propagation to backward propagation computations.

Examples:
cnn_inference_f32.c, cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, cpu_cnn_training_f32.c, and rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_SRC

#define DNNL_ARG_DIFF_SRC   DNNL_ARG_DIFF_SRC_0

A special mnemonic for primitives that have a single diff source argument.

An alias for DNNL_ARG_DIFF_SRC_0.

Examples:
cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, and cpu_cnn_training_f32.c.

◆ DNNL_ARG_DIFF_SRC_LAYER

#define DNNL_ARG_DIFF_SRC_LAYER   DNNL_ARG_DIFF_SRC_0

A special mnemonic for gradient (diff) of RNN input vector.

An alias for DNNL_ARG_DIFF_SRC_0.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_SRC_ITER

#define DNNL_ARG_DIFF_SRC_ITER   DNNL_ARG_DIFF_SRC_1

A special mnemonic for gradient (diff) of RNN input recurrent hidden state vector.

An alias for DNNL_ARG_DIFF_SRC_1.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_SRC_ITER_C

#define DNNL_ARG_DIFF_SRC_ITER_C   DNNL_ARG_DIFF_SRC_2

A special mnemonic for gradient (diff) of RNN input recurrent cell state vector.

An alias for DNNL_ARG_DIFF_SRC_1.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_DST

#define DNNL_ARG_DIFF_DST   DNNL_ARG_DIFF_DST_0

A special mnemonic for primitives that have a single diff destination argument.

An alias for DNNL_ARG_DIFF_DST_0.

Examples:
cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, and cpu_cnn_training_f32.c.

◆ DNNL_ARG_DIFF_DST_LAYER

#define DNNL_ARG_DIFF_DST_LAYER   DNNL_ARG_DIFF_DST_0

A special mnemonic for gradient (diff) of RNN output vector.

An alias for DNNL_ARG_DIFF_DST_0.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_DST_ITER

#define DNNL_ARG_DIFF_DST_ITER   DNNL_ARG_DIFF_DST_1

A special mnemonic for gradient (diff) of RNN input recurrent hidden state vector.

An alias for DNNL_ARG_DIFF_DST_1.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_DST_ITER_C

#define DNNL_ARG_DIFF_DST_ITER_C   DNNL_ARG_DIFF_DST_2

A special mnemonic for gradient (diff) of RNN input recurrent cell state vector.

An alias for DNNL_ARG_DIFF_DST_2.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_WEIGHTS

#define DNNL_ARG_DIFF_WEIGHTS   DNNL_ARG_DIFF_WEIGHTS_0

A special mnemonic for primitives that have a single diff weights argument.

Alias for DNNL_ARG_DIFF_WEIGHTS_0.

Examples:
cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, and cpu_cnn_training_f32.c.

◆ DNNL_ARG_DIFF_SCALE_SHIFT

#define DNNL_ARG_DIFF_SCALE_SHIFT   DNNL_ARG_DIFF_WEIGHTS_0

A special mnemonic for diff of scale and shift argument of normalization primitives.

Alias for DNNL_ARG_DIFF_WEIGHTS_0.

◆ DNNL_ARG_DIFF_WEIGHTS_LAYER

#define DNNL_ARG_DIFF_WEIGHTS_LAYER   DNNL_ARG_DIFF_WEIGHTS_0

A special mnemonic for diff of RNN weights applied to the layer input.

An alias for DNNL_ARG_DIFF_WEIGHTS_0.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_WEIGHTS_ITER

#define DNNL_ARG_DIFF_WEIGHTS_ITER   DNNL_ARG_DIFF_WEIGHTS_1

A special mnemonic for diff of RNN weights applied to the recurrent input.

An alias for DNNL_ARG_DIFF_WEIGHTS_1.

Examples:
rnn_training_f32.cpp.

◆ DNNL_ARG_DIFF_WEIGHTS_PEEPHOLE

#define DNNL_ARG_DIFF_WEIGHTS_PEEPHOLE   DNNL_ARG_DIFF_WEIGHTS_2

A special mnemonic for diff of RNN weights applied to the peephole weights.

An alias for DNNL_ARG_DIFF_WEIGHTS_2.

◆ DNNL_ARG_MULTIPLE_SRC

#define DNNL_ARG_MULTIPLE_SRC   1024

Starting index for source arguments for primitives that take a variable number of source arguments.

◆ DNNL_ARG_MULTIPLE_DST

#define DNNL_ARG_MULTIPLE_DST   2048

Starting index for destination arguments for primitives that produce a variable number of destination arguments.

◆ DNNL_ARG_ATTR_POST_OP_DW

#define DNNL_ARG_ATTR_POST_OP_DW   8192

Arguments for fused depthwise convolution.

See dev_guide_attributes_post_ops_depthwise_fusion

Enumeration Type Documentation

◆ normalization_flags

enum dnnl::normalization_flags : unsigned
strong

Flags for normalization primitives.

Enumerator
use_global_stats 

Use global statistics.

If specified, the library uses mean and variance provided by the user as an input on forward propagation and does not compute their derivatives on backward propagation. Otherwise, the library computes mean and variance on forward propagation for training and inference, outputs them on forward propagation for training, and computes the respective derivatives on backward propagation.

use_scale_shift 

Use scale and shift parameters.

If specified, the user is expected to pass scale and shift as inputs on forward propagation. On backward propagation of type dnnl::prop_kind::backward, the library computes their derivatives. If not specified, the scale and shift parameters are not used by the library in any way.

fuse_norm_relu 

Fuse normalization with ReLU.

On training, normalization will require the workspace to implement backward propagation. On inference, the workspace is not required and behavior is the same as when normalization is fused with ReLU using the post-ops API.

◆ query

enum dnnl::query
strong

Primitive descriptor query specification.

In general, queries are not used with the C++ API because most queries are implemented as class members.

See dnnl_query_t for more information.

Enumerator
undef 

no query

engine 

execution engine

primitive_kind 

primitive kind

num_of_inputs_s32 

number of inputs expected

num_of_outputs_s32 

number of outputs expected

time_estimate_f64 

runtime estimation (seconds), unimplemented

memory_consumption_s64 

memory consumption (bytes)

extra (scratch) memory, additional to all inputs and outputs memory

See also
Primitive Attributes: Scratchpad
scratchpad_engine 

scratchpad engine

engine to be used for creating scratchpad memory

reorder_src_engine 

reorder source engine

reorder_dst_engine 

reorder destination engine

impl_info_str 

implementation name

prop_kind 

propagation kind

op_d 

operation descriptor

convolution_d 

convolution descriptor

deconvolution_d 

deconvolution descriptor

shuffle_d 

shuffle descriptor

eltwise_d 

eltwise descriptor

softmax_d 

softmax descriptor

pooling_d 

pooling descriptor

lrn_d 

lrn descriptor

batch_normalization_d 

batch normalization descriptor

layer_normalization_d 

layer normalization descriptor

inner_product_d 

inner product descriptor

rnn_d 

rnn descriptor

binary_d 

binary descriptor

logsoftmax_d 

logsoftmax descriptor

matmul_d 

matmul descriptor

resampling_d 

resampling descriptor

src_md 

source memory desc

diff_src_md 

source gradient (diff) memory desc

weights_md 

weights memory descriptor desc

diff_weights_md 

weights gradient (diff) memory desc

dst_md 

destination memory desc

diff_dst_md 

destination gradient (diff) memory desc

workspace_md 

workspace memory desc

scratchpad_md 

scratchpad memory desc

exec_arg_md 

memory desc of an execute argument

◆ dnnl_prop_kind_t

Kinds of propagation.

Enumerator
dnnl_prop_kind_undef 

Undefined propagation type.

dnnl_forward_training 

Forward data propagation (training mode).

In this mode primitives perform computations necessary for subsequent backward propagation.

dnnl_forward_inference 

Forward data propagation (inference mode).

In this mode primitives perform only computations that are necessary for inference and omit computations that are necessary only for backward propagation.

dnnl_forward_scoring 

Forward data propagation (alias for dnnl_forward_inference).

dnnl_forward 

Forward data propagation (alias for dnnl_forward_training).

dnnl_backward 

Backward propagation (with respect to all parameters).

dnnl_backward_data 

Backward data propagation.

dnnl_backward_weights 

Backward weights propagation.

dnnl_backward_bias 

Backward bias propagation.

◆ dnnl_primitive_kind_t

Kinds of primitives.

Used to implement a way to extend the library with new primitives without changing the ABI.

Enumerator
dnnl_undefined_primitive 

Undefined primitive.

dnnl_reorder 

A reorder primitive.

dnnl_shuffle 

A shuffle primitive.

dnnl_concat 

A (out-of-place) concat primitive.

dnnl_sum 

A sum primitive.

dnnl_convolution 

A convolution primitive.

dnnl_deconvolution 

A deconvolution primitive.

dnnl_eltwise 

An element-wise primitive.

dnnl_softmax 

A softmax primitive.

dnnl_pooling 

A pooling primitive.

dnnl_lrn 

An LRN primitive.

dnnl_batch_normalization 

A batch normalization primitive.

dnnl_layer_normalization 

A layer normalization primitive.

dnnl_inner_product 

An inner product primitive.

dnnl_rnn 

A rnn primitive.

dnnl_gemm 

A matrix multiplication primitive (internal).

dnnl_binary 

A binary primitive.

dnnl_logsoftmax 

A logsoftmax primitive.

dnnl_matmul 

A matrix multiplication primitive.

dnnl_resampling 

A resampling primitive.

◆ dnnl_alg_kind_t

Kinds of algorithms.

Enumerator
dnnl_convolution_direct 

Direct convolution.

dnnl_convolution_winograd 

Winograd convolution.

dnnl_convolution_auto 

Convolution algorithm(either direct or Winograd) is chosen just in time.

dnnl_deconvolution_direct 

Direct deconvolution.

dnnl_deconvolution_winograd 

Winograd deconvolution.

dnnl_eltwise_relu 

Eltwise: ReLU.

dnnl_eltwise_tanh 

Eltwise: hyperbolic tangent non-linearity (tanh)

dnnl_eltwise_elu 

Eltwise: exponential linear unit (elu)

dnnl_eltwise_square 

Eltwise: square.

dnnl_eltwise_abs 

Eltwise: abs.

dnnl_eltwise_sqrt 

Eltwise: square root.

dnnl_eltwise_linear 

Eltwise: linear.

dnnl_eltwise_bounded_relu 

Eltwise: bounded_relu.

dnnl_eltwise_soft_relu 

Eltwise: soft_relu.

dnnl_eltwise_logistic 

Eltwise: logistic.

dnnl_eltwise_exp 

Eltwise: exponent.

dnnl_eltwise_gelu_tanh 

Eltwise: gelu.

Note
Tanh approximation formula is used to approximate the cumulative distribution function of a Gaussian here
dnnl_eltwise_gelu 

Eltwise: tanh-based gelu (alias for dnnl_eltwise_gelu_tanh)

dnnl_eltwise_swish 

Eltwise: swish.

dnnl_eltwise_log 

Eltwise: natural logarithm.

dnnl_eltwise_clip 

Eltwise: clip.

dnnl_eltwise_pow 

Eltwise: pow.

dnnl_eltwise_gelu_erf 

Eltwise: erf-based gelu.

dnnl_eltwise_relu_use_dst_for_bwd 

Eltwise: ReLU (dst for backward)

dnnl_eltwise_tanh_use_dst_for_bwd 

Eltwise: hyperbolic tangent non-linearity (tanh) (dst for backward)

dnnl_eltwise_elu_use_dst_for_bwd 

Eltwise: exponential linear unit (elu) (dst for backward)

dnnl_eltwise_sqrt_use_dst_for_bwd 

Eltwise: square root (dst for backward)

dnnl_eltwise_logistic_use_dst_for_bwd 

Eltwise: logistic (dst for backward)

dnnl_eltwise_exp_use_dst_for_bwd 

Eltwise: exp (dst for backward)

dnnl_pooling_max 

Max pooling.

dnnl_pooling_avg_include_padding 

Average pooling include padding.

dnnl_pooling_avg_exclude_padding 

Average pooling exclude padding.

dnnl_pooling_avg 

Average pooling (alias for dnnl_pooling_avg_exclude_padding)

dnnl_lrn_across_channels 

Local response normalization (LRN) across multiple channels.

dnnl_lrn_within_channel 

LRN within a single channel.

dnnl_vanilla_rnn 

RNN cell.

dnnl_vanilla_lstm 

LSTM cell.

dnnl_vanilla_gru 

GRU cell.

dnnl_lbr_gru 

GRU cell with linear before reset.

Modification of original GRU cell. Differs from dnnl_vanilla_gru in how the new memory gate is calculated:

\[ c_t = tanh(W_c*x_t + b_{c_x} + r_t*(U_c*h_{t-1}+b_{c_h})) \]

Primitive expects 4 biases on input: \([b_{u}, b_{r}, b_{c_x}, b_{c_h}]\)

dnnl_binary_add 

Binary add.

dnnl_binary_mul 

Binary mul.

dnnl_binary_max 

Binary max.

dnnl_binary_min 

Binary min.

dnnl_resampling_nearest 

Nearest Neighbor Resampling Method.

dnnl_resampling_linear 

Linear Resampling Method.

◆ dnnl_normalization_flags_t

Flags for batch normalization primitive.

Enumerator
dnnl_use_global_stats 

Use global statistics.

If specified

  • on forward propagation use mean and variance provided by user (input)
  • on backward propagation reduces the amount of computations, since mean and variance are considered as constants

If not specified:

  • on forward propagation mean and variance are computed and stored in output
  • on backward propagation compute full derivative wrt to data
dnnl_use_scaleshift 

Use scale and shift parameters.

If specified:

  • on forward propagation use scale and shift (aka scale and bias) for the batch normalization results
  • on backward propagation (for prop_kind == dnnl_backward) compute diff wrt to scale and shift (hence one extra output used)

If no specified:

dnnl_fuse_norm_relu 

Fuse with ReLU.

The flag implies negative slope being 0. On training this is the only configuration supported. For inference, to use non-zero negative slope consider using Primitive Attributes: Post-ops.

If specified:

  • on inference this option behaves the same as if the primitive were fused with ReLU using post ops API with zero negative slope.
  • on training primitive requires workspace (required to be able to perform backward pass)

◆ dnnl_query_t

Primitive descriptor query specification.

For generic function dnnl_primitive_desc_query(), the type of result must agree with the queried argument. The correspondence table:

Query kind Type of query result ----—
dnnl_query_engine dnnl_engine_t *
dnnl_query_scratchpad_engine dnnl_engine_t *
dnnl_query_primitive_kind dnnl_primitive_kind_t *
dnnl_query_*_s32 int *
dnnl_query_*_s64 dnnl_dim_t * (same as int64_t *)
dnnl_query_*_f64 double *
dnnl_query_*_str const char **
dnnl_query_op_d const_dnnl_op_desc_t *
dnnl_query_*_md const dnnl_memory_desc_t **
dnnl_query_*_<op>_d const dnnl_<op>_desc_t **
dnnl_query_*_pd const_dnnl_primitive_desc_t *
Note
Rule of thumb: all opaque types and structures are returned by reference. All numbers are returned by value.
Warning
All returned references point to constant objects and are valid only during the lifetime of the queried primitive descriptor. Returned objects must not be destroyed by the user. If you need to keep the object longer than the lifetime of the queried primitive descriptor, use dnnl_primitive_desc_clone() to make a copy.
Enumerator
dnnl_query_undef 

no query

dnnl_query_engine 

execution engine

dnnl_query_primitive_kind 

primitive kind

dnnl_query_num_of_inputs_s32 

number of inputs expected

dnnl_query_num_of_outputs_s32 

number of outputs expected

dnnl_query_time_estimate_f64 

runtime estimation (seconds)

dnnl_query_memory_consumption_s64 

memory consumption – extra

dnnl_query_scratchpad_engine 

(scratch) memory, additional to all inputs and outputs memory (bytes)

scratchpad engine – engine to be used

dnnl_query_impl_info_str 

for creating scratchpad memory

implementation name

dnnl_query_reorder_src_engine 

source engine

dnnl_query_reorder_dst_engine 

destination engine

dnnl_query_prop_kind 

propagation kind

dnnl_query_some_d 

stub

dnnl_query_op_d 

op descriptor

dnnl_query_convolution_d 

convolution descriptor

dnnl_query_deconvolution_d 

deconvolution descriptor

dnnl_query_shuffle_d 

shuffle descriptor

dnnl_query_eltwise_d 

eltwise descriptor

dnnl_query_softmax_d 

softmax descriptor

dnnl_query_pooling_d 

pooling descriptor

dnnl_query_lrn_d 

lrn descriptor

dnnl_query_batch_normalization_d 

batch normalization descriptor

dnnl_query_layer_normalization_d 

layer normalization descriptor

dnnl_query_inner_product_d 

inner product descriptor

dnnl_query_rnn_d 

rnn descriptor

dnnl_query_gemm_d 

GEMM descriptor (internal)

dnnl_query_binary_d 

binary descriptor

dnnl_query_logsoftmax_d 

logsoftmax descriptor

dnnl_query_matmul_d 

matrix multiplication (matmul) descriptor

dnnl_query_resampling_d 

resampling descriptor

dnnl_query_some_md 

stub

dnnl_query_src_md 

source memory desc

dnnl_query_diff_src_md 

source gradient memory desc

dnnl_query_weights_md 

weights memory descriptor desc

dnnl_query_diff_weights_md 

weights grad. memory desc

dnnl_query_dst_md 

destination memory desc

dnnl_query_diff_dst_md 

destination grad. memory desc

dnnl_query_workspace_md 

workspace memory desc

dnnl_query_scratchpad_md 

scratchpad memory desc

dnnl_query_exec_arg_md 

memory desc of an execute argument

Function Documentation

◆ dnnl_primitive_desc_iterator_create()

dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_create ( dnnl_primitive_desc_iterator_t iterator,
const_dnnl_op_desc_t  op_desc,
const_dnnl_primitive_attr_t  attr,
dnnl_engine_t  engine,
const_dnnl_primitive_desc_t  hint_forward_primitive_desc 
)

Creates a primitive descriptor iterator.

Parameters
iteratorOutput primitive descriptor iterator.
op_descOperation descriptor.
attrPrimitive attributes (can be NULL).
engineEngine to use.
hint_forward_primitive_descFor backward propagation: primitive descriptor for a respective forward propagation primitive. Pass NULL for forward propagation.
Returns
dnnl_success on success and a status describing the error otherwise.

◆ dnnl_primitive_desc_iterator_next()

dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_next ( dnnl_primitive_desc_iterator_t  iterator)

Advances the primitive descriptor iterator to point to the next available implementation.

Parameters
iteratorA primitive descriptor iterator to advance.
Returns
dnnl_success on success and a status describing the error otherwise.
dnnl_iterator_ends if no more implementations available.

◆ dnnl_primitive_desc_iterator_fetch()

dnnl_primitive_desc_t DNNL_API dnnl_primitive_desc_iterator_fetch ( const_dnnl_primitive_desc_iterator_t  iterator)

Fetches the current primitive descriptor from a primitive descriptor iterator.

Note
The user is responsible for deleting the resulting primitive descriptor using dnnl_primitive_desc_destroy().
Parameters
iteratorA primitive descriptor iterator.
Returns
A primitive descriptor.

◆ dnnl_primitive_desc_iterator_destroy()

dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_destroy ( dnnl_primitive_desc_iterator_t  iterator)

Destroys a primitive descriptor iterator.

Parameters
iteratorPrimitive descriptor iterator to destroy.
Returns
dnnl_success on success and a status describing the error otherwise.

◆ dnnl_primitive_desc_create()

dnnl_status_t DNNL_API dnnl_primitive_desc_create ( dnnl_primitive_desc_t primitive_desc,
const_dnnl_op_desc_t  op_desc,
const_dnnl_primitive_attr_t  attr,
dnnl_engine_t  engine,
const_dnnl_primitive_desc_t  hint_forward_primitive_desc 
)

Creates a primitive descriptor.

This function is equivalent to a sequence of dnnl_primitive_desc_iterator_create() and dnnl_primitive_desc_iterator_fetch(). In other words, the library will pick the first suitable implementation.

Parameters
primitive_descOutput primitive descriptor.
op_descOperation descriptor.
attrPrimitive attributes (can be NULL).
engineEngine to use.
hint_forward_primitive_descFor backward propagation: primitive descriptor for a respective forward propagation primitive. Pass NULL for forward propagation.
Returns
dnnl_success on success and a status describing the error otherwise.
Examples:
cnn_inference_f32.c, cpu_cnn_training_f32.c, and cross_engine_reorder.c.

◆ dnnl_primitive_desc_clone()

dnnl_status_t DNNL_API dnnl_primitive_desc_clone ( dnnl_primitive_desc_t primitive_desc,
const_dnnl_primitive_desc_t  existing_primitive_desc 
)

Clones a primitive descriptor.

The resulting primitive descriptor must be destroyed separately.

Parameters
primitive_descOutput primitive descriptor.
existing_primitive_descPrimitive descriptor to clone.
Returns
dnnl_success on success and a status describing the error otherwise.

◆ dnnl_primitive_desc_get_attr()

dnnl_status_t DNNL_API dnnl_primitive_desc_get_attr ( const_dnnl_primitive_desc_t  primitive_desc,
const_dnnl_primitive_attr_t attr 
)

Returns a constant reference to the attributes of a primitive descriptor.

Warning
It is an error to destroy the resulting attr.
The lifetime of an attr is the same as that of a primitive_desc, so it is an error to use the attr once the primitive_desc has been destroyed.
Parameters
primitive_descPrimitive descriptor.
attrOuput primitive attributes.
Returns
dnnl_success on success and a status describing the error otherwise.

◆ dnnl_primitive_desc_destroy()

dnnl_status_t DNNL_API dnnl_primitive_desc_destroy ( dnnl_primitive_desc_t  primitive_desc)

Destroys a primitive descriptor.

Parameters
primitive_descPrimitive descriptor to destroy.
Returns
dnnl_success on success and a status describing the error otherwise.
Examples:
cnn_inference_f32.c, cpu_cnn_training_f32.c, and cross_engine_reorder.c.

◆ dnnl_primitive_desc_query()

dnnl_status_t DNNL_API dnnl_primitive_desc_query ( const_dnnl_primitive_desc_t  primitive_desc,
dnnl_query_t  what,
int  index,
void *  result 
)

Queries a primitive descriptor for various pieces of information.

The most common use case is to query a primitive descriptor, created with source, weights, and destination memory descriptors with format tags set to dnnl_format_tag_any, for the corresponding memory descriptors (in this case the what is set to dnnl_query_src_md, dnnl_query_weights_md, and dnnl_query_dst_md respectively) so that it is possible to create memory objects and reorder primitives if necessary.

Another typical use case is to query a primitive descriptor for workspace memory descriptor (with what set to dnnl_query_workspace_md). If this query returns dnnl_not_required status, then workspace memory is not required.

Note
When querying for a memory descriptor for a scratchpad, a workspace, or an optional parameter, the query will return a pointer to a zero memory descriptor if the parameter is not needed.

A few other use cases:

See also
dnnl_query_t for more options
Parameters
primitive_descPrimitive descriptor.
whatParameter to query.
indexIndex of the parameter to query for.
resultOutput result. The type depends on the query. For example, it must be a dnnl_memory_desc_t* if querying for a memory descriptor.
Returns
dnnl_success on success and a status describing the error otherwise.

◆ dnnl_primitive_desc_query_md()

const dnnl_memory_desc_t DNNL_API* dnnl_primitive_desc_query_md ( const_dnnl_primitive_desc_t  primitive_desc,
dnnl_query_t  what,
int  index 
)

Queries primitive descriptor for a memory descriptor.

Note
This function is a convenience version of dnnl_primitive_desc_query().
Parameters
primitive_descPrimitive descriptor.
whatKind of memory descriptor parameter to query for.
indexIndex of the parameter to query.
Returns
A pointer to the requested memory descriptor.
A pointer to a zero memory descriptor if the parameter is not needed.
NULL in case of any error.
Examples:
cnn_inference_f32.c, and cpu_cnn_training_f32.c.

◆ dnnl_primitive_desc_query_s32()

int DNNL_API dnnl_primitive_desc_query_s32 ( const_dnnl_primitive_desc_t  primitive_desc,
dnnl_query_t  what,
int  index 
)

Queries primitive descriptor for a signed 32bit int.

Note
This function is a convenience version of dnnl_primitive_desc_query().
Parameters
primitive_descPrimitive descriptor.
whatKind of the value to query for.
indexIndex of the parameter to query.
Returns
The requested value.
0 in case of any error (in particular if the queried entity is not of type int32_t). Note that 0 may also be the actual returned value.

◆ dnnl_primitive_create()

dnnl_status_t DNNL_API dnnl_primitive_create ( dnnl_primitive_t primitive,
const_dnnl_primitive_desc_t  primitive_desc 
)

Creates a primitive.

Parameters
primitiveOutput primitive.
primitive_descPrimitive descriptor used to create the primitive.
Returns
dnnl_success on success and a status describing the error otherwise.
Examples:
cnn_inference_f32.c, cpu_cnn_training_f32.c, and cross_engine_reorder.c.

◆ dnnl_primitive_execute()

dnnl_status_t DNNL_API dnnl_primitive_execute ( const_dnnl_primitive_t  primitive,
dnnl_stream_t  stream,
int  nargs,
const dnnl_exec_arg_t args 
)

Executes a primitive.

Parameters
primitivePrimitive to execute.
streamStream to use.
nargsNumber of arguments.
argsArray of arguments. Each argument is an <index, dnnl_memory_t> pair. The index is one of the DNNL_ARG_* values such as DNNL_ARG_SRC. Unless runtime shapes are used (see DNNL_RUNTIME_DIM_VAL), the memory object must have the same memory descriptor as that returned by dnnl_primitive_desc_query_md(dnnl_query_exec_arg_md, index).
Returns
dnnl_success on success and a status describing the error otherwise.
Examples:
cnn_inference_f32.c, cpu_cnn_training_f32.c, and cross_engine_reorder.c.

◆ dnnl_primitive_get_primitive_desc()

dnnl_status_t DNNL_API dnnl_primitive_get_primitive_desc ( const_dnnl_primitive_t  primitive,
const_dnnl_primitive_desc_t primitive_desc 
)

Retrieves a constant reference to the primitive descriptor of a given primitive.

Warning
It is an error to destroy the returned object. It is owned by the primitive. The const qualifier of the returned object prevents such attempts.
Parameters
primitivePrimitive to query for the primitive descriptor.
primitive_descOutput primitive descriptor.
Returns
dnnl_success on success and a status describing the error otherwise.

◆ dnnl_primitive_destroy()

dnnl_status_t DNNL_API dnnl_primitive_destroy ( dnnl_primitive_t  primitive)

Destroys a primitive.

Parameters
primitiveThe primitive to destroy.
Returns
dnnl_success on success and a status describing the error otherwise.
Examples:
cnn_inference_f32.c, cpu_cnn_training_f32.c, and cross_engine_reorder.c.

◆ convert_to_c() [1/3]

dnnl_primitive_kind_t dnnl::convert_to_c ( primitive::kind  kind)
inline

Converts primitive kind enum value from C++ API to C API type.

Parameters
kindC++ API primitive kind enum value.
Returns
Corresponding C API primitive kind enum value.

◆ convert_to_c() [2/3]

dnnl_normalization_flags_t dnnl::convert_to_c ( normalization_flags  flags)
inline

Converts normalization flags enum value from C++ API to C API type.

Parameters
flagsC++ API normalization flags enum value.
Returns
Corresponding C API normalization flags enum value.

◆ convert_to_c() [3/3]

dnnl_query_t dnnl::convert_to_c ( query  query)
inline

Converts query enum value from C++ API to C API type.

Parameters
queryC++ API query enum value.
Returns
Corresponding C API query enum value.

◆ get_primitive_desc()

const_dnnl_primitive_desc_t dnnl::primitive::get_primitive_desc ( ) const
inline

Returns the C API primitive descriptor of the underlying C API primitive.

Returns
The underlying C API primitive descriptor.

◆ get_kind()

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

Returns the kind of the primitive.

Returns
The primitive kind.