[][src]Function onednn_sys::dnnl_post_ops_append_sum_v2

pub unsafe extern "C" fn dnnl_post_ops_append_sum_v2(
    post_ops: dnnl_post_ops_t,
    scale: f32,
    data_type: dnnl_data_type_t
) -> dnnl_status_t

Appends an accumulation v2 (sum) to post-ops. Prior to accumulating the result, the previous value is multiplied by a scale.

The kind of this post-op is #dnnl_sum.

This feature may improve performance for cases like residual learning blocks, where the result of convolution is accumulated to the previously computed activations. The parameter @p scale may be used 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-op, the computations would be:

dst[:] <- scale * dst[:] + op(...) // instead of dst[:] <- op(...)

If @p data_type is specified, original dst tensor will be reinterpreted as a tensor with provided data type. Since it is reinterpretation, data_type and dst data type should have same size. As a result, computations would be:

dst[:] <- scale * as_data_type(dst[:]) + op(...)
                                   // instead of dst[:] <- op(...)

@note This post-op executes in-place and does not change the destination layout.

@param post_ops Post-ops. @param scale Accumulation scaling factor. @param data_type Accumulation data_type. @returns #dnnl_success on success and a status describing the error otherwise.