oneAPI Deep Neural Network Library (oneDNN)
Performance library for Deep Learning
1.96.0

A primitive to perform elementwise operations such as the rectifier linear unit (ReLU). More...

Classes

struct  dnnl::eltwise_forward
 Elementwise unary operation forward propagation primitive. More...
 
struct  dnnl::eltwise_backward
 Elementwise unary operation backward propagation primitive. More...
 
struct  dnnl_eltwise_desc_t
 A descriptor of a element-wise operation. More...
 

Functions

dnnl_status_t DNNL_API dnnl_eltwise_forward_desc_init (dnnl_eltwise_desc_t *eltwise_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *data_desc, float alpha, float beta)
 Initializes a descriptor for eltwise forward propagation primitive. More...
 
dnnl_status_t DNNL_API dnnl_eltwise_backward_desc_init (dnnl_eltwise_desc_t *eltwise_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *data_desc, float alpha, float beta)
 Initializes a descriptor for eltwise backward propagation primitive. More...
 

Detailed Description

A primitive to perform elementwise operations such as the rectifier linear unit (ReLU).

Both forward and backward propagation primitives support in-place operation; that is, src and dst can refer to the same memory for forward propagation, and diff_dst and diff_src can refer to the same memory for backward propagation.

Warning
Because the original source data is required for backward propagation, in-place forward propagation is not generally supported in the training mode. However, for algorithms supporting destination as input memory, dst can be used for the backward propagation, which makes it possible to get performance benefit even in the training mode.
See also
Eltwise in developer guide

Function Documentation

◆ dnnl_eltwise_forward_desc_init()

dnnl_status_t DNNL_API dnnl_eltwise_forward_desc_init ( dnnl_eltwise_desc_t eltwise_desc,
dnnl_prop_kind_t  prop_kind,
dnnl_alg_kind_t  alg_kind,
const dnnl_memory_desc_t data_desc,
float  alpha,
float  beta 
)

Initializes a descriptor for eltwise forward propagation primitive.

Parameters
eltwise_descOutput descriptor for an eltwise primitive.
prop_kindPropagation kind. Possible values are dnnl_forward_training and dnnl_forward_inference.
alg_kindElementwise algorithm kind.
data_descSource and destination memory descriptor.
alphaThe alpha parameter for the elementwise operation. Specific meaning depends on the algorithm.
betaThe beta parameter for the elementwise operation. Specific meaning depends on the algorithm.
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_eltwise_backward_desc_init()

dnnl_status_t DNNL_API dnnl_eltwise_backward_desc_init ( dnnl_eltwise_desc_t eltwise_desc,
dnnl_alg_kind_t  alg_kind,
const dnnl_memory_desc_t diff_data_desc,
const dnnl_memory_desc_t data_desc,
float  alpha,
float  beta 
)

Initializes a descriptor for eltwise backward propagation primitive.

Parameters
eltwise_descOutput descriptor for an eltwise primitive.
alg_kindElementwise algorithm kind.
diff_data_descDiff source and diff destination memory descriptors.
data_descSource and destination memory descriptor.
alphaThe alpha parameter for the elementwise operation. Specific meaning depends on the algorithm.
betaThe beta parameter for the elementwise operation. Specific meaning depends on the algorithm.
Returns
dnnl_success on success and a status describing the error otherwise.
Examples:
cpu_cnn_training_f32.c.