.. index:: pair: group; Attributes .. _doxid-group__dnnl__api__attributes: Attributes ========== .. toctree:: :hidden: enum_dnnl_algorithm.rst enum_dnnl_scratchpad_mode_t.rst enum_dnnl_prop_kind.rst enum_dnnl_scratchpad_mode.rst struct_dnnl_post_ops.rst struct_dnnl_primitive_attr.rst struct_dnnl_post_ops-2.rst struct_dnnl_primitive_attr-2.rst Overview ~~~~~~~~ A container for parameters that extend primitives behavior. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block // typedefs typedef struct :ref:`dnnl_primitive_attr`* :ref:`dnnl_primitive_attr_t`; typedef const struct :ref:`dnnl_primitive_attr`* :ref:`const_dnnl_primitive_attr_t`; typedef struct :ref:`dnnl_post_ops`* :ref:`dnnl_post_ops_t`; typedef const struct :ref:`dnnl_post_ops`* :ref:`const_dnnl_post_ops_t`; // enums enum :ref:`dnnl::algorithm`; enum :ref:`dnnl_scratchpad_mode_t`; enum :ref:`dnnl::prop_kind`; enum :ref:`dnnl::scratchpad_mode`; // structs struct :ref:`dnnl_post_ops`; struct :ref:`dnnl_primitive_attr`; struct :ref:`dnnl::post_ops`; struct :ref:`dnnl::primitive_attr`; // global functions :ref:`dnnl_scratchpad_mode_t` :ref:`dnnl::convert_to_c`(:ref:`scratchpad_mode` mode); :ref:`dnnl_prop_kind_t` :ref:`dnnl::convert_to_c`(:ref:`prop_kind` akind); :ref:`dnnl_alg_kind_t` :ref:`dnnl::convert_to_c`(:ref:`algorithm` aalgorithm); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_create`(:ref:`dnnl_primitive_attr_t`* attr); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_clone`( :ref:`dnnl_primitive_attr_t`* attr, :ref:`const_dnnl_primitive_attr_t` existing_attr ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_destroy`(:ref:`dnnl_primitive_attr_t` attr); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_fpmath_mode`( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t`* mode ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_fpmath_mode`( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t` mode ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_fpmath_mode_v2`( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t`* mode, int* apply_to_int ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_fpmath_mode_v2`( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t` mode, int apply_to_int ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_deterministic`( :ref:`const_dnnl_primitive_attr_t` attr, int* value ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_deterministic`( :ref:`dnnl_primitive_attr_t` attr, int value ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_accumulation_mode`( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_accumulation_mode_t`* mode ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_accumulation_mode`( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_accumulation_mode_t` mode ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_scratchpad_mode`( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_scratchpad_mode_t`* mode ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_scratchpad_mode`( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_scratchpad_mode_t` mode ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_scales_mask`( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_scales`( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask, int ndims, const :ref:`dnnl_dims_t` group_dims, :ref:`dnnl_data_type_t` data_type ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_zero_points_mask`( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_zero_points`( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask, int ndims, const :ref:`dnnl_dims_t` group_dims, :ref:`dnnl_data_type_t` data_type ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_post_ops`( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`const_dnnl_post_ops_t`* post_ops ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_post_ops`( :ref:`dnnl_primitive_attr_t` attr, :ref:`const_dnnl_post_ops_t` post_ops ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_create`(:ref:`dnnl_post_ops_t`* post_ops); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_clone`( :ref:`dnnl_post_ops_t`* post_ops, :ref:`const_dnnl_post_ops_t` existing_post_ops ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_destroy`(:ref:`dnnl_post_ops_t` post_ops); int DNNL_API :ref:`dnnl_post_ops_len`(:ref:`const_dnnl_post_ops_t` post_ops); :ref:`dnnl_primitive_kind_t` DNNL_API :ref:`dnnl_post_ops_get_kind`( :ref:`const_dnnl_post_ops_t` post_ops, int index ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_append_sum`( :ref:`dnnl_post_ops_t` post_ops, float scale, int32_t zero_point, :ref:`dnnl_data_type_t` data_type ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_get_params_sum`( :ref:`const_dnnl_post_ops_t` post_ops, int index, float* scale, int32_t* zero_point, :ref:`dnnl_data_type_t`* data_type ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_append_eltwise`( :ref:`dnnl_post_ops_t` post_ops, :ref:`dnnl_alg_kind_t` alg_kind, float alpha, float beta ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_get_params_eltwise`( :ref:`const_dnnl_post_ops_t` post_ops, int index, :ref:`dnnl_alg_kind_t`* alg_kind, float* alpha, float* beta ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_append_dw`( :ref:`dnnl_post_ops_t` post_ops, :ref:`dnnl_data_type_t` weights_data_type, :ref:`dnnl_data_type_t` bias_data_type, :ref:`dnnl_data_type_t` dst_data_type, :ref:`dnnl_dim_t` kernel_size, :ref:`dnnl_dim_t` stride_size, :ref:`dnnl_dim_t` padding_l_size ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_get_params_dw`( :ref:`const_dnnl_post_ops_t` post_ops, int index, :ref:`dnnl_data_type_t`* weights_data_type, :ref:`dnnl_data_type_t`* bias_data_type, :ref:`dnnl_data_type_t`* dst_data_type, :ref:`dnnl_dim_t`* kernel_size, :ref:`dnnl_dim_t`* stride_size, :ref:`dnnl_dim_t`* padding_l_size ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_append_binary`( :ref:`dnnl_post_ops_t` post_ops, :ref:`dnnl_alg_kind_t` alg_kind, :ref:`const_dnnl_memory_desc_t` src1_desc ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_get_params_binary`( :ref:`const_dnnl_post_ops_t` post_ops, int index, :ref:`dnnl_alg_kind_t`* alg_kind, :ref:`const_dnnl_memory_desc_t`* src1_desc ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_append_prelu`( :ref:`dnnl_post_ops_t` post_ops, int mask ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_post_ops_get_params_prelu`( :ref:`const_dnnl_post_ops_t` post_ops, int index, int* mask ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_rnn_data_qparams`( :ref:`dnnl_primitive_attr_t` attr, const float scale, const float shift ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_rnn_data_qparams`( :ref:`const_dnnl_primitive_attr_t` attr, float* scale, float* shift ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_rnn_weights_qparams`( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t` count, int mask, const float* scales ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_rnn_weights_qparams`( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t`* count, int* mask, const float** scales ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_set_rnn_weights_projection_qparams`( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t` count, int mask, const float* scales ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_primitive_attr_get_rnn_weights_projection_qparams`( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t`* count, int* mask, const float** scales ); .. _details-group__dnnl__api__attributes: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ A container for parameters that extend primitives behavior. Attributes can also contain Post-ops, which are computations executed after the primitive. .. rubric:: See also: :ref:`Primitive Attributes ` :ref:`Primitive Attributes: Post-ops ` Typedefs -------- .. index:: pair: typedef; dnnl_primitive_attr_t .. _doxid-group__dnnl__api__attributes_1ga06d701a25b82d4c8a93aaabb93e03dc3: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef struct :ref:`dnnl_primitive_attr`* dnnl_primitive_attr_t A primitive descriptor attributes handle that controls primitive behavior. .. index:: pair: typedef; const_dnnl_primitive_attr_t .. _doxid-group__dnnl__api__attributes_1ga871d7ee732a90fec43f1c878581bb59a: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef const struct :ref:`dnnl_primitive_attr`* const_dnnl_primitive_attr_t A constant primitive descriptor attributes handle. .. index:: pair: typedef; dnnl_post_ops_t .. _doxid-group__dnnl__api__attributes_1ga7d715ce1a81606584df9dcf045976401: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef struct :ref:`dnnl_post_ops`* dnnl_post_ops_t A post operation chain handle. .. index:: pair: typedef; const_dnnl_post_ops_t .. _doxid-group__dnnl__api__attributes_1ga997bc4a3d9d2ce50238b1c035963fc39: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef const struct :ref:`dnnl_post_ops`* const_dnnl_post_ops_t A constant post operation chain handle. Global Functions ---------------- .. index:: pair: function; convert_to_c .. _doxid-group__dnnl__api__attributes_1gaa30f540e1ed09b2865f153fd599c967b: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_scratchpad_mode_t` dnnl::convert_to_c(:ref:`scratchpad_mode` mode) Converts a scratchpad mode enum value from C++ API to C API type. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - mode - C++ API scratchpad mode enum value. .. rubric:: Returns: Corresponding C API scratchpad mode enum value. .. index:: pair: function; convert_to_c .. _doxid-group__dnnl__api__attributes_1gae13881206fecd43ce0e0daead7f0009e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_prop_kind_t` dnnl::convert_to_c(:ref:`prop_kind` akind) Converts propagation kind enum value from C++ API to C API type. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - akind - C++ API propagation kind enum value. .. rubric:: Returns: Corresponding C API propagation kind enum value. .. index:: pair: function; convert_to_c .. _doxid-group__dnnl__api__attributes_1gad4c07d30e46391ce7ce0900d18cbfa30: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_alg_kind_t` dnnl::convert_to_c(:ref:`algorithm` aalgorithm) Converts algorithm kind enum value from C++ API to C API type. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aalgorithm - C++ API algorithm kind enum value. .. rubric:: Returns: Corresponding C API algorithm kind enum value. .. index:: pair: function; dnnl_primitive_attr_create .. _doxid-group__dnnl__api__attributes_1gaf630fdc0d8d0fd8522ec93852a559081: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_create(:ref:`dnnl_primitive_attr_t`* attr) Creates an empty (default) primitive attributes with all the parameters set to their default values. Empty attributes are implied whenever the respective argument is NULL. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Output primitive attributes. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_clone .. _doxid-group__dnnl__api__attributes_1gab6ac5a4b13fa1ab3251c51f3c750bd63: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_clone( :ref:`dnnl_primitive_attr_t`* attr, :ref:`const_dnnl_primitive_attr_t` existing_attr ) Clones primitive attributes. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Output primitive attributes. * - existing_attr - Primitive attributes to clone. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_destroy .. _doxid-group__dnnl__api__attributes_1ga96a7539382945195627f2932bff8fadb: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_destroy(:ref:`dnnl_primitive_attr_t` attr) Destroys primitive attributes. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes to destroy. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_fpmath_mode .. _doxid-group__dnnl__api__attributes_1gac63b70ab1d2fe88c31f03c961b2e924a: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_fpmath_mode( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t`* mode ) Returns the floating-point math mode primitive attribute. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - Output FP math mode. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_fpmath_mode .. _doxid-group__dnnl__api__attributes_1gafe55fa618bc10b65b6c0b6eca7e43840: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_fpmath_mode( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t` mode ) Sets the floating-point math mode primitive attributes. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - FP math mode. The possible values are: :ref:`dnnl_fpmath_mode_strict ` (default), :ref:`dnnl_fpmath_mode_bf16 `, :ref:`dnnl_fpmath_mode_f16 `, :ref:`dnnl_fpmath_mode_tf32 `, :ref:`dnnl_fpmath_mode_any `. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_fpmath_mode_v2 .. _doxid-group__dnnl__api__attributes_1gab6dd49fedbc548aea2d6ede5a0c42a6c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_fpmath_mode_v2( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t`* mode, int* apply_to_int ) Returns the floating-point math mode primitive attribute. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - Output FP math mode. * - apply_to_int - Output use floating-point arithmetic for integer primitives. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_fpmath_mode_v2 .. _doxid-group__dnnl__api__attributes_1ga96edebcfaf7451fa96d698be110a18e9: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_fpmath_mode_v2( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_fpmath_mode_t` mode, int apply_to_int ) Sets the floating-point math mode primitive attributes. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - FP math mode. The possible values are: :ref:`dnnl_fpmath_mode_strict ` (default), :ref:`dnnl_fpmath_mode_bf16 `, :ref:`dnnl_fpmath_mode_f16 `, :ref:`dnnl_fpmath_mode_tf32 `, :ref:`dnnl_fpmath_mode_any `. * - apply_to_int - Boolean. Use of floating-point arithmetic for integer primitives. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_deterministic .. _doxid-group__dnnl__api__attributes_1gacb11e4d0243975ef944eb25fffe2ef0a: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_deterministic( :ref:`const_dnnl_primitive_attr_t` attr, int* value ) Returns the deterministic primitive attribute value. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - value - Output deterministic attribute value .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_deterministic .. _doxid-group__dnnl__api__attributes_1ga69af4e29cba07fdb95672c070ac26511: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_deterministic( :ref:`dnnl_primitive_attr_t` attr, int value ) Sets the deterministic primitive attribute value. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - value - Boolean value to set deterministic attribute. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_accumulation_mode .. _doxid-group__dnnl__api__attributes_1ga1add29950cb3ec6595aebd572bcf7f92: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_accumulation_mode( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_accumulation_mode_t`* mode ) Returns the accumulation mode primitive attribute. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - Output accumulation mode. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_accumulation_mode .. _doxid-group__dnnl__api__attributes_1ga691c818641709d7dc94b92a2db7686b5: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_accumulation_mode( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_accumulation_mode_t` mode ) Sets the accumulation mode primitive attribute. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - Accumulation mode. The possible values are: :ref:`dnnl_accumulation_mode_strict ` (default), which is s32 for quantized primitives, f32/f64 otherwise :ref:`dnnl_accumulation_mode_relaxed `, which is same as strict but allows intermediate accumulators to be in src/dst datatype :ref:`dnnl_accumulation_mode_any `, which allows accumulators to be src/dst datatype or any wider type. :ref:`dnnl_accumulation_mode_f32 `, :ref:`dnnl_accumulation_mode_s32 `, :ref:`dnnl_accumulation_mode_f16 `. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_scratchpad_mode .. _doxid-group__dnnl__api__attributes_1gab14d8e830a52510a75a917f75764a6b8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_scratchpad_mode( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_scratchpad_mode_t`* mode ) Returns the primitive attributes scratchpad mode. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - Output scratchpad mode. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_scratchpad_mode .. _doxid-group__dnnl__api__attributes_1ga4adeb17e538392ec3a16d2f6ef3f7cca: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_scratchpad_mode( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_scratchpad_mode_t` mode ) Sets primitive attributes scratchpad mode. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - mode - Scratchpad mode. The possible values are: :ref:`dnnl_scratchpad_mode_library ` (default) and :ref:`dnnl_scratchpad_mode_user `. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_scales_mask .. _doxid-group__dnnl__api__attributes_1gad7eac877f75cfa282be094b1e48cb71d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_scales_mask( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask ) Sets primitive attributes scaling factors for primitive operations for a given memory argument. The scaling factors must be passed at execution time as an argument with index :ref:`DNNL_ARG_ATTR_SCALES ` \| arg. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - arg - Parameter argument index as passed to the :ref:`dnnl_primitive_execute() ` call. * - mask - Scaling factors correspondence mask that defines the correspondence between the tensor dimensions and the ``scales`` array. The set i-th bit indicates that a dedicated scaling factor is used for each index along that dimension. Set the mask to 0 to use a common scaling factor for the whole output tensor. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. rubric:: See also: :ref:`dnnl_primitive_attr_set_scales_mask ` .. index:: pair: function; dnnl_primitive_attr_set_scales .. _doxid-group__dnnl__api__attributes_1ga6c56ea6104c9275574370a40e2d5b273: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_scales( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask, int ndims, const :ref:`dnnl_dims_t` group_dims, :ref:`dnnl_data_type_t` data_type ) Sets primitive attributes scaling factors for primitive operations for a given memory argument. The scaling factors must be passed at execution time as an argument with index :ref:`DNNL_ARG_ATTR_SCALES ` \| arg. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - arg - Parameter argument index as passed to the :ref:`dnnl_primitive_execute() ` call. * - mask - Scaling factors correspondence mask that defines the correspondence between the tensor dimensions and the ``scales`` array. The set i-th bit indicates that a dedicated scaling factor is used for each index along that dimension. Set the mask to 0 to use a common scaling factor for the whole output tensor. * - ndims - Number of group dimensions. * - group_dims - Scaling factors correspondence groups that define the correspondence between the tensor dimensions and the scales array. The group dimensions should only be provided for each logical dimension that has correspondence mask ``mask`` set. * - data_type - Scaling factors data_type. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. rubric:: See also: :ref:`dnnl_primitive_attr_set_scales ` .. index:: pair: function; dnnl_primitive_attr_set_zero_points_mask .. _doxid-group__dnnl__api__attributes_1ga24e429b5410f5657bc5bdda0a6c5d0a7: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_zero_points_mask( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask ) Sets primitive attributes zero points for primitive operations for a given memory argument. The zero points must be passed at execution time as an argument with index :ref:`DNNL_ARG_ATTR_ZERO_POINTS ` \| arg. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - arg - Parameter argument index as passed to the :ref:`dnnl_primitive_execute() ` call. * - mask - Zero point correspondence mask that defines the correspondence between the tensor dimensions and the ``zero_points`` array. The set i-th bit indicates that a dedicated zero point is used for each index along that dimension. Set the mask to 0 to use a common zero point for the whole output tensor. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. rubric:: See also: :ref:`dnnl_primitive_attr_set_zero_points_mask ` .. index:: pair: function; dnnl_primitive_attr_set_zero_points .. _doxid-group__dnnl__api__attributes_1ga94f3e4f640fb0ca210c2413bb5cf2255: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_zero_points( :ref:`dnnl_primitive_attr_t` attr, int arg, int mask, int ndims, const :ref:`dnnl_dims_t` group_dims, :ref:`dnnl_data_type_t` data_type ) Sets primitive attributes zero points for primitive operations for a given memory argument. The zero points must be passed at execution time as an argument with index :ref:`DNNL_ARG_ATTR_ZERO_POINTS ` \| arg. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - arg - Parameter argument index as passed to the :ref:`dnnl_primitive_execute() ` call. * - mask - Zero point correspondence mask that defines the correspondence between the tensor dimensions and the ``zero_points`` array. The set i-th bit indicates that a dedicated zero point is used for each index along that dimension. Set the mask to 0 to use a common zero point for the whole output tensor. * - ndims - Number of group dimensions. * - group_dims - Zero point factors correspondence groups that define the correspondence between the tensor dimensions and the zero_points array. The group dimensions should be only provided for each logical dimension that has the bit set correspondence mask ``mask`` set. * - data_type - Zero points factors data_type. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. rubric:: See also: :ref:`dnnl_primitive_attr_set_zero_points ` .. index:: pair: function; dnnl_primitive_attr_get_post_ops .. _doxid-group__dnnl__api__attributes_1ga50c92661cc69e1eeb17b61f006320a05: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_post_ops( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`const_dnnl_post_ops_t`* post_ops ) Returns primitive attributes post-ops. .. warning:: The output ``post_ops`` points to the internal ``attr`` field, so it is an error to modify or destroy them. The lifetime of ``post_ops`` is the same as that of the ``attr`` it belongs to, so it is an error to use ``post_ops`` after ``attr`` has been destroyed. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - post_ops - Output post-ops. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_post_ops .. _doxid-group__dnnl__api__attributes_1ga7045d42606599f156bfca69820c21ea2: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_post_ops( :ref:`dnnl_primitive_attr_t` attr, :ref:`const_dnnl_post_ops_t` post_ops ) Sets primitive attributes post-ops. .. note:: There is no way to check whether the post-ops would be supported by the target primitive. Any error will be reported by the dnnl\_\_[propagation kind]_primitive_desc_create() function call. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - post_ops - Post-ops to set. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_create .. _doxid-group__dnnl__api__attributes_1gaa8d8c32ad4472de464e47336ad702a48: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_create(:ref:`dnnl_post_ops_t`* post_ops) Creates empty post-ops sequence. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Output post-ops. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_clone .. _doxid-group__dnnl__api__attributes_1ga087b5f530ae5cfd1134cfad694e84de1: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_clone( :ref:`dnnl_post_ops_t`* post_ops, :ref:`const_dnnl_post_ops_t` existing_post_ops ) Clones post-ops primitive attribute. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Output post-ops primitive attribute. * - existing_post_ops - Post-ops primitive attribute to clone. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_destroy .. _doxid-group__dnnl__api__attributes_1ga67487a65afa2e2066f4b4eb12d47535b: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_destroy(:ref:`dnnl_post_ops_t` post_ops) Destroys post-ops. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops to destroy. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_len .. _doxid-group__dnnl__api__attributes_1ga98550f7eddff153ea819a6c4a68e7eec: .. ref-code-block:: cpp :class: doxyrest-title-code-block int DNNL_API dnnl_post_ops_len(:ref:`const_dnnl_post_ops_t` post_ops) Returns the length of post-ops. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. .. rubric:: Returns: The number of post-ops entries. .. index:: pair: function; dnnl_post_ops_get_kind .. _doxid-group__dnnl__api__attributes_1gabb9d82e4e8f1c83f169468d4b92f4109: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_primitive_kind_t` DNNL_API dnnl_post_ops_get_kind( :ref:`const_dnnl_post_ops_t` post_ops, int index ) Returns the kind of a post-op entry. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - index - Post-op entry index. .. rubric:: Returns: The kind of the post-op with the specified index. :ref:`dnnl_undefined_primitive ` if there is no post-op at the specified index. .. index:: pair: function; dnnl_post_ops_append_sum .. _doxid-group__dnnl__api__attributes_1ga21a32731c8cf6e6034fd4f8704bd63db: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_append_sum( :ref:`dnnl_post_ops_t` post_ops, float scale, int32_t zero_point, :ref:`dnnl_data_type_t` data_type ) Appends an accumulation v3 (sum) to post-ops. Prior to accumulating the result, a zero point is subtracted from the previous value and is multiplied by the scale. The kind of this post-op is :ref:`dnnl_sum `. This feature may improve performance for cases like dequantize the asymmetrically quantized sum's src1 tensor to f32 domain before performing the sum operation by subtracting the ``zero_point`` before the scaling. In the simplest case where accumulation is the only post-op, the computations will be: .. code-block:: cpp dst[:] <- scale * (dst[:] - zero_point) + op(...) // instead of dst[:] <- op(...) If ``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 the same size. As a result, computations will be: .. code-block:: cpp dst[:] <- scale * (as_data_type(dst[:]) - zero_point) + op(...) // instead of dst[:] <- op(...) .. note:: This post-op executes in-place and does not change the destination layout. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - scale - Accumulation scaling factor. * - zero_point - Single scalar int32_t value of zero point. * - data_type - Accumulation data_type. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_get_params_sum .. _doxid-group__dnnl__api__attributes_1ga029625f8a29d82a49ddb966428b6143e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_get_params_sum( :ref:`const_dnnl_post_ops_t` post_ops, int index, float* scale, int32_t* zero_point, :ref:`dnnl_data_type_t`* data_type ) Returns the parameters of an accumulation (sum) post-op with zero point and data type parameter. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - index - Index of the sum post-op. * - scale - Output accumulation scaling factor. * - zero_point - Zero point. * - data_type - Data type for accumulation. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_append_eltwise .. _doxid-group__dnnl__api__attributes_1gaf5927e8931bf113abb94837541cec662: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_append_eltwise( :ref:`dnnl_post_ops_t` post_ops, :ref:`dnnl_alg_kind_t` alg_kind, float alpha, float beta ) Appends an elementwise post-op. The kind of this post operation is :ref:`dnnl_eltwise `. In the simplest case when the elementwise is the only post operation, the computations would be: .. code-block:: cpp dst[:] <- eltwise_op (op(...)) // instead of dst[:] <- op(...) where eltwise_op is configured with the given parameters. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - alg_kind - Elementwise algorithm for the post-op. * - alpha - Alpha parameter for the elementwise algorithm. * - beta - Beta parameter for the elementwise algorithm. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_get_params_eltwise .. _doxid-group__dnnl__api__attributes_1gaedc7af352b0ae178c025e9272a428533: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_get_params_eltwise( :ref:`const_dnnl_post_ops_t` post_ops, int index, :ref:`dnnl_alg_kind_t`* alg_kind, float* alpha, float* beta ) Returns the parameters of an elementwise post-op. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - index - Index of the elementwise post-op. * - alg_kind - Output elementwise algorithm kind. * - alpha - Output alpha parameter for the elementwise algorithm. * - beta - Output beta parameter for the elementwise algorithm. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. :ref:`dnnl_invalid_arguments ` if ``index`` does not refer to an elementwise post-op. .. index:: pair: function; dnnl_post_ops_append_dw .. _doxid-group__dnnl__api__attributes_1ga38509493009271e2b8c6d8fadb1fcac1: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_append_dw( :ref:`dnnl_post_ops_t` post_ops, :ref:`dnnl_data_type_t` weights_data_type, :ref:`dnnl_data_type_t` bias_data_type, :ref:`dnnl_data_type_t` dst_data_type, :ref:`dnnl_dim_t` kernel_size, :ref:`dnnl_dim_t` stride_size, :ref:`dnnl_dim_t` padding_l_size ) Appends a depthwise post-op convolution. This post-op can only be fused with a 2D 1x1 convolution (convolution with weights spatial dimensions equal to 1 i.e., kh=kw=1). The kind of this post-op is :ref:`dnnl_convolution `. The number of outputs for primitive with fusion is one. The output spatial size can be derived as below: output_height = ceil(output_height_1x1_convolution, stride) output_width = ceil(output_width_1x1_convolution, stride) See :ref:`dev_guide_attributes_post_ops_depthwise ` and :ref:`dev_guide_attributes_post_ops_depthwise_fusion ` for more info. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - weights_data_type - Weights data type of depthwise post-op * - bias_data_type - Bias data type of depthwise post-op * - dst_data_type - Output data type of depthwise post-op * - kernel_size - Size of kernel of depthwise post-op * - stride_size - Size of stride of depthwise post-op * - padding_l_size - Size of left and top paddings of depthwise post-op .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise .. index:: pair: function; dnnl_post_ops_get_params_dw .. _doxid-group__dnnl__api__attributes_1ga5e474604cf257e0dfae1ada352cf2f36: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_get_params_dw( :ref:`const_dnnl_post_ops_t` post_ops, int index, :ref:`dnnl_data_type_t`* weights_data_type, :ref:`dnnl_data_type_t`* bias_data_type, :ref:`dnnl_data_type_t`* dst_data_type, :ref:`dnnl_dim_t`* kernel_size, :ref:`dnnl_dim_t`* stride_size, :ref:`dnnl_dim_t`* padding_l_size ) Returns the parameters of an depthwise post-op. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - index - Index of the elementwise post-op. * - weights_data_type - Weights data type of depthwise post-op * - bias_data_type - Bias data type of depthwise post-op * - dst_data_type - Output data type of depthwise post-op * - kernel_size - Size of kernel of depthwise post-op * - stride_size - Size of stride of depthwise post-op * - padding_l_size - Size of left and top paddings of depthwise post-op .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise .. index:: pair: function; dnnl_post_ops_append_binary .. _doxid-group__dnnl__api__attributes_1gabc40e53d80f6f1d61cc5b17807d2446c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_append_binary( :ref:`dnnl_post_ops_t` post_ops, :ref:`dnnl_alg_kind_t` alg_kind, :ref:`const_dnnl_memory_desc_t` src1_desc ) Appends a binary post-op. The kind of this post operation is :ref:`dnnl_binary `. In the simplest case when the binary is the only post operation, the computations would be: .. code-block:: cpp dst[:] <- binary_op (dst[:], another_input[:]) where binary_op is configured with the given parameters. binary_op supports broadcast semantics for a second operand. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - alg_kind - Binary algorithm for the post-op. * - src1_desc - Memory descriptor of a second operand. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_get_params_binary .. _doxid-group__dnnl__api__attributes_1ga29acfcbce0ad42f36627469aa67b4046: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_get_params_binary( :ref:`const_dnnl_post_ops_t` post_ops, int index, :ref:`dnnl_alg_kind_t`* alg_kind, :ref:`const_dnnl_memory_desc_t`* src1_desc ) Returns the parameters of a binary post-op. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - index - Index of the binary post-op. * - alg_kind - Output binary algorithm kind. * - src1_desc - Output memory descriptor of a second operand. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. :ref:`dnnl_invalid_arguments ` if ``index`` does not refer to a binary post-op. .. index:: pair: function; dnnl_post_ops_append_prelu .. _doxid-group__dnnl__api__attributes_1ga833465b0aac349988b29245e1112656f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_append_prelu( :ref:`dnnl_post_ops_t` post_ops, int mask ) Appends a prelu forward post-op. The kind of this post-op is :ref:`dnnl::primitive::kind::prelu `. The post-op can be defined as: .. code-block:: cpp dst[:] <- prelu(dst[:], weights[:]) prelu: dst[:] <- dst[:] if dst[:] > 0 dst[:] <- dst[:] * weights[:] if dst[:] <= 0 .. note:: The order of dimensions does not depend on how elements are laid out in memory. For example: * for a 2D CNN activations tensor the order is always (n, c) * for a 4D CNN activations tensor the order is always (n, c, h, w) * for a 5D CNN weights tensor the order is always (g, oc, ic, kh, kw) Prelu weights tensor is passed in runtime execution phase. Prelu weights tensor data type is implicitly assumed as f32 using plain layout (a, ab, acb, acdb, acdeb) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - mask - Defines the correspondence between the output tensor dimensions and the prelu weights tensor. The set i-th bit indicates that a dedicated weights value is used for each index along that dimension. Set the mask to 0 to use a common weights value for the whole output tensor. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_post_ops_get_params_prelu .. _doxid-group__dnnl__api__attributes_1ga5207e88213978239909da6e9f346cda7: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_post_ops_get_params_prelu( :ref:`const_dnnl_post_ops_t` post_ops, int index, int* mask ) Returns the parameters of a prelu post-op. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - post_ops - Post-ops. * - index - Index of the prelu post-op. * - mask - Mask of the prelu post-op. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_rnn_data_qparams .. _doxid-group__dnnl__api__attributes_1ga0067a4b6e5dd2fe7578cd4a25dddfe39: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_rnn_data_qparams( :ref:`dnnl_primitive_attr_t` attr, const float scale, const float shift ) 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: .. ref-code-block:: cpp // RNN parameters int l = 2, t = 2, mb = 32, sic = 32, slc = 32, dic = 32, dlc = 32; // Activations quantization parameters float scale = 63.f, shift = 64.f; 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 an RNN primitive descriptor. dnnl_primitive_desc_t rnn_pd; dnnl_vanilla_rnn_forward_primitive_desc_create(&rnn_pd, engine, /* arguments */, attr); .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - scale - The value to scale the data by. * - shift - The value to shift the data by. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_rnn_data_qparams .. _doxid-group__dnnl__api__attributes_1gae04744b95cdabcbcda1087229759be04: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_rnn_data_qparams( :ref:`const_dnnl_primitive_attr_t` attr, float* scale, float* shift ) Returns the quantization scale and shift parameters for RNN data tensors. .. note:: Quantization scale and shift are common for src_layer, src_iter, dst_iter, and dst_layer. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - scale - The value to scale the data by. * - shift - The value to shift the data by. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_rnn_weights_qparams .. _doxid-group__dnnl__api__attributes_1ga815dbfe548cfcb70076fe091888e5466: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_rnn_weights_qparams( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t` count, int mask, const float* scales ) Sets quantization scaling factors for RNN weights tensors. The low-precision configuration of the RNN primitives expects input weights to use the signed 8-bit integer data type. The scaling factors are used to quantize floating-point data to signed integer and must be passed to RNN primitives using attributes. .. note:: The dimension order is always native and does not depend on the actual layout used. For example, five-dimensional weights always have (l, d, i, g, o) logical dimension ordering. .. note:: Quantization scales are common for weights_layer and weights_iteration .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - count - Number of elements in the ``scales`` array. * - mask - Scaling factors correspondence mask that defines the correspondence between the output tensor dimensions and the ``scales`` vector. The set i-th bit indicates that a dedicated scaling factor should be used for each index along that dimension. Set the mask to 0 to use a common scaling factor for the whole output tensor. * - scales - Array of output scaling factors that must contain ``count`` values and the following equality must hold: .. math:: count = \prod\limits_{d \in mask} weights.dims[d]. Violations can only be detected when the attributes are used to create a primitive descriptor. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_rnn_weights_qparams .. _doxid-group__dnnl__api__attributes_1ga5bb88cfe42454f01884ddcdb906f6f7c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_rnn_weights_qparams( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t`* count, int* mask, const float** scales ) Returns the quantization scaling factors for RNN weights tensors. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - count - Number of elements in the ``scales`` array. * - mask - Scaling factors correspondence mask that defines the correspondence between the output tensor dimensions and the ``scales`` vector. The set i-th bit indicates that a dedicated scaling factor should be used for each index along that dimension. Set the mask to 0 to use a common scaling factor for the whole output tensor. * - scales - Array of output scaling factors that contain ``count`` values and the following equality must hold: .. math:: count = \prod\limits_{d \in mask} weights.dims[d]. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_set_rnn_weights_projection_qparams .. _doxid-group__dnnl__api__attributes_1gac7973cc7b4c62eb6766e9ac96c51d49d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_set_rnn_weights_projection_qparams( :ref:`dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t` count, int mask, const float* scales ) Sets quantization scaling factors for RNN projection weights tensors. The low-precision configuration of the RNN primitives expects input weights to use the signed 8-bit integer data type. The scaling factors are used to quantize floating-point data to signed integer and must be passed to RNN primitives using attributes. .. note:: The dimension order is always native and does not depend on the actual layout used. For example, five-dimensional weights always have (l, d, i, g, o) logical dimension ordering. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - count - Number of elements in the ``scales`` array. * - mask - Scaling factors correspondence mask that defines the correspondence between the output tensor dimensions and the ``scales`` vector. The set i-th bit indicates that a dedicated scaling factor should be used for each index along that dimension. Set the mask to 0 to use a common scaling factor for the whole output tensor. * - scales - Array of output scaling factors that must contain ``count`` values and the following equality must hold: .. math:: count = \prod\limits_{d \in mask} weights.dims[d]. Violations can only be detected when the attributes are used to create a primitive descriptor. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_primitive_attr_get_rnn_weights_projection_qparams .. _doxid-group__dnnl__api__attributes_1gaa33206be6e7a0b7de2341041da75cc90: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_primitive_attr_get_rnn_weights_projection_qparams( :ref:`const_dnnl_primitive_attr_t` attr, :ref:`dnnl_dim_t`* count, int* mask, const float** scales ) Returns the quantization scaling factors for RNN projection weights tensors. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - attr - Primitive attributes. * - count - Number of elements in the ``scales`` array. * - mask - Scaling factors correspondence mask that defines the correspondence between the output tensor dimensions and the ``scales`` vector. The set i-th bit indicates that a dedicated scaling factor should be used for each index along that dimension. Set the mask to 0 to use a common scaling factor for the whole output tensor. * - scales - Array of output scaling factors that contain ``count`` values and the following equality must hold: .. math:: count = \prod\limits_{d \in mask} weights.dims[d]. .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise.