Deep Neural Network Library (DNNL)  1.1.3
Performance library for Deep Learning
Functions
Common primitive operations

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 for given op_desc, attr, engine, and optionally a hint primitive descriptor from forward propagation (required for backward propagation). More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_next (dnnl_primitive_desc_iterator_t iterator)
 Iterates over primitive descriptors. More...
 
dnnl_primitive_desc_t DNNL_API dnnl_primitive_desc_iterator_fetch (const_dnnl_primitive_desc_iterator_t iterator)
 Fetches the current primitive descriptor. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_destroy (dnnl_primitive_desc_iterator_t iterator)
 Deletes a primitive descriptor iterator.
 
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_desc using op_desc, attr, engine, and optionally a hint primitive descriptor from forward propagation. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_clone (dnnl_primitive_desc_t *primitive_desc, const_dnnl_primitive_desc_t existing_primitive_desc)
 Makes a copy of a primitive_desc.
 
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 attribute of a primitive_desc. More...
 
dnnl_status_t DNNL_API dnnl_primitive_desc_destroy (dnnl_primitive_desc_t primitive_desc)
 Deletes a primitive_desc.
 
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 primitive descriptor. 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 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 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 using a primitive_desc descriptor.
 
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 using a stream, and nargs arguments args. 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 reference to the primitive_desc descriptor of given primitive. More...
 
dnnl_status_t DNNL_API dnnl_primitive_destroy (dnnl_primitive_t primitive)
 Deletes a primitive.
 

Detailed Description

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 for given op_desc, attr, engine, and optionally a hint primitive descriptor from forward propagation (required for backward propagation).

Pass NULL for forward propagation.

◆ dnnl_primitive_desc_iterator_next()

dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_next ( dnnl_primitive_desc_iterator_t  iterator)

Iterates over primitive descriptors.

Returns dnnl_iterator_ends if no more primitive descriptors are 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.

Note
The user should delete the fetched primitive descriptor using dnnl_primitive_desc_destroy() once it is no longer needed.

◆ 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_desc using op_desc, attr, engine, and optionally a hint primitive descriptor from forward propagation.

The call is equivalent to creating a primitive descriptor iterator, immediately fetching a primitive descriptor, and then destroying the iterator.

Examples:
cnn_inference_f32.c, cpu_cnn_training_f32.c, and cross_engine_reorder.c.

◆ 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 attribute of a primitive_desc.

Warning
The user should not destroy the obtained attr.
The lifetime of an attr is the same as that of a primitive_desc, so it is illegal to use the attr once primitive_desc has been destroyed.

◆ 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 primitive descriptor.

One of the most typical use cases is to query a primitive descriptor created with source, weights, and destination formats equal to dnnl_format_tag_any about the corresponding memory descriptors (what equals dnnl_query_src_md, dnnl_query_weights_md, and dnnl_query_dst_md respectively) to be able to prepare memory and create reorders if required.

Another quite typical use case is to query an operation primitive descriptor for a workspace (what equals dnnl_query_workspace_md). The returned status dnnl_not_required indicates that a workspace is not required.

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

A few other possibilities:

See also
dnnl_query_t for more options

◆ 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 memory descriptor.

Returns
NULL in case of any error.

This is just a specialized version of dnnl_primitive_desc_query used for convenience.

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 signed 32bit int.

Returns
0 in case of any error (in particular if the queried entity is not of type int32_t). Note that 0 might also be the actual returned value.

This is just a specialized version of dnnl_primitive_desc_query used for convenience.

◆ 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 using a stream, and nargs arguments args.

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 reference to the primitive_desc descriptor of given primitive.

Warning
The returned object must not be destroyed by the user. The const qualifier of the returned object prevents such attempts.