An extension for performing extra operations after a base operation. More...
Functions | |
dnnl_status_t DNNL_API | dnnl_post_ops_create (dnnl_post_ops_t *post_ops) |
Creates an empty sequence of post operations post_ops . | |
dnnl_status_t DNNL_API | dnnl_post_ops_destroy (dnnl_post_ops_t post_ops) |
Deletes a post_ops sequence. | |
int DNNL_API | dnnl_post_ops_len (const_dnnl_post_ops_t post_ops) |
Returns the length of post operations for given post_ops . | |
dnnl_primitive_kind_t DNNL_API | dnnl_post_ops_get_kind (const_dnnl_post_ops_t post_ops, int index) |
Returns the kind of post operation with index index in given post_ops . More... | |
dnnl_status_t DNNL_API | dnnl_post_ops_append_sum (dnnl_post_ops_t post_ops, float scale) |
Appends accumulation (sum) post operation to the post_ops . More... | |
dnnl_status_t DNNL_API | dnnl_post_ops_get_params_sum (const_dnnl_post_ops_t post_ops, int index, float *scale) |
Gets the parameters of the accumulation (sum) post operation with index index in the sequence of post_ops . More... | |
dnnl_status_t DNNL_API | dnnl_post_ops_append_eltwise (dnnl_post_ops_t post_ops, float scale, dnnl_alg_kind_t alg, float alpha, float beta) |
Appends eltwise post operation to the post_ops with given parameters kind , alpha , and beta (. More... | |
dnnl_status_t DNNL_API | dnnl_post_ops_get_params_eltwise (const_dnnl_post_ops_t post_ops, int index, float *scale, dnnl_alg_kind_t *alg, float *alpha, float *beta) |
Gets the eltwise parameters of the post operation with index index in the sequence of post_ops . More... | |
An extension for performing extra operations after a base operation.
dnnl_primitive_kind_t DNNL_API dnnl_post_ops_get_kind | ( | const_dnnl_post_ops_t | post_ops, |
int | index | ||
) |
Returns the kind of post operation with index index
in given post_ops
.
In case of error, returns dnnl_undefined_primitive.
dnnl_status_t DNNL_API dnnl_post_ops_append_sum | ( | dnnl_post_ops_t | post_ops, |
float | scale | ||
) |
Appends accumulation (sum) post operation to the post_ops
.
Prior to accumulating the result, the previous value would be multiplied by scale
.
The kind of this post operation is dnnl_sum.
This feature might improve performance for cases like residual learning blocks, where the result of convolution is accumulated to the previously computed activations. The parameter scale
might be extreme for the integer-based computations when the result and previous activations have different logical scaling factors.
In the simplest case when the accumulation is the only post operation, the computations would be: dst[] <- scale * dst[] + op(...) // instead of dst[] <- op(...)
dnnl_status_t DNNL_API dnnl_post_ops_get_params_sum | ( | const_dnnl_post_ops_t | post_ops, |
int | index, | ||
float * | scale | ||
) |
Gets the parameters of the accumulation (sum) post operation with index index
in the sequence of post_ops
.
index
would not correspond to the accumulation post operation, the function returns dnnl_invalid_arguments. dnnl_status_t DNNL_API dnnl_post_ops_append_eltwise | ( | dnnl_post_ops_t | post_ops, |
float | scale, | ||
dnnl_alg_kind_t | alg, | ||
float | alpha, | ||
float | beta | ||
) |
Appends eltwise post operation to the post_ops
with given parameters kind
, alpha
, and beta
(.
The kind of this post operation is dnnl_eltwise.
In the simplest case when the eltwise is the only post operation, the computations would be: dst[] <- scale * eltwise_op ( op(...) ) // instead of dst[] <- op(...) where eltwise_op is configured with the given parameters.
dnnl_status_t DNNL_API dnnl_post_ops_get_params_eltwise | ( | const_dnnl_post_ops_t | post_ops, |
int | index, | ||
float * | scale, | ||
dnnl_alg_kind_t * | alg, | ||
float * | alpha, | ||
float * | beta | ||
) |
Gets the eltwise parameters of the post operation with index index
in the sequence of post_ops
.