[−][src]Function onednn_sys::dnnl_primitive_attr_set_rnn_data_qparams
pub unsafe extern "C" fn dnnl_primitive_attr_set_rnn_data_qparams(
attr: dnnl_primitive_attr_t,
scale: f32,
shift: f32
) -> dnnl_status_t
Set quantization scale and shift parameters for RNN data tensors.
For performance reasons, the low-precision configuration of the RNN primitives expects input activations to have the unsigned 8-bit integer data type. The scale and shift parameters are used to quantize floating-point data to unsigned integer and must be passed to the RNN primitive using attributes.
The quantization formula is scale * (data + shift)
.
@note Quantization scale and shift are common for src_layer, src_iter, dst_iter, and dst_layer.
Example usage: @code // RNN parameters int l = 2, t = 2, mb = 32, sic = 32, slc = 32, dic = 32, dlc = 32; // Activations quantization parameters float scale = ..., shift = ..;
dnnl_primitive_attr_t rnn_attr; // Create default attributes dnnl_primitive_attr_create(&rnn_attr); // Set scale and shift for int8 quantization of activation dnnl_primitive_attr_set_rnn_data_qparams(rnn_attr, scale, shift); // Create and configure rnn op_desc dnnl_rnn_desc_t rnn_d; dnnl_primitive_desc_t rnn_pd; dnnl_primitive_desc_create(&rnn_pd, &rnn_d, attr, engine, NULL);
@endcode
@param attr Primitive attributes. @param scale The value to scale the data by. @param shift The value to shift the data by. @returns #dnnl_success on success and a status describing the error otherwise.