.. index:: pair: group; Eltwise .. _doxid-group__dnnl__api__eltwise: Eltwise ======= .. toctree:: :hidden: struct_dnnl_eltwise_backward.rst struct_dnnl_eltwise_forward.rst Overview ~~~~~~~~ A primitive to perform elementwise operations such as the rectifier linear unit (ReLU). :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block // structs struct :ref:`dnnl::eltwise_backward`; struct :ref:`dnnl::eltwise_forward`; // global functions :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_eltwise_forward_primitive_desc_create`( :ref:`dnnl_primitive_desc_t`* primitive_desc, :ref:`dnnl_engine_t` engine, :ref:`dnnl_prop_kind_t` prop_kind, :ref:`dnnl_alg_kind_t` alg_kind, :ref:`const_dnnl_memory_desc_t` src_desc, :ref:`const_dnnl_memory_desc_t` dst_desc, float alpha, float beta, :ref:`const_dnnl_primitive_attr_t` attr ); :ref:`dnnl_status_t` DNNL_API :ref:`dnnl_eltwise_backward_primitive_desc_create`( :ref:`dnnl_primitive_desc_t`* primitive_desc, :ref:`dnnl_engine_t` engine, :ref:`dnnl_alg_kind_t` alg_kind, :ref:`const_dnnl_memory_desc_t` diff_src_desc, :ref:`const_dnnl_memory_desc_t` diff_dst_desc, :ref:`const_dnnl_memory_desc_t` data_desc, float alpha, float beta, :ref:`const_dnnl_primitive_desc_t` hint_fwd_pd, :ref:`const_dnnl_primitive_attr_t` attr ); .. _details-group__dnnl__api__eltwise: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ 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. .. rubric:: See also: :ref:`Eltwise ` in developer guide Global Functions ---------------- .. index:: pair: function; dnnl_eltwise_forward_primitive_desc_create .. _doxid-group__dnnl__api__eltwise_1gaf5ae8472e1a364502103dea646ccb5bf: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_eltwise_forward_primitive_desc_create( :ref:`dnnl_primitive_desc_t`* primitive_desc, :ref:`dnnl_engine_t` engine, :ref:`dnnl_prop_kind_t` prop_kind, :ref:`dnnl_alg_kind_t` alg_kind, :ref:`const_dnnl_memory_desc_t` src_desc, :ref:`const_dnnl_memory_desc_t` dst_desc, float alpha, float beta, :ref:`const_dnnl_primitive_attr_t` attr ) Creates a primitive descriptor for an eltwise forward propagation primitive. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - primitive_desc - Output primitive descriptor. * - engine - Engine to use. * - prop_kind - Propagation kind. Possible values are :ref:`dnnl_forward_training ` and :ref:`dnnl_forward_inference `. * - alg_kind - Elementwise algorithm kind. * - src_desc - Source memory descriptor. * - dst_desc - Destination memory descriptor. * - alpha - The alpha parameter for the elementwise operation. Specific meaning depends on the algorithm. * - beta - The beta parameter for the elementwise operation. Specific meaning depends on the algorithm. * - attr - Primitive attributes (can be NULL). .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise. .. index:: pair: function; dnnl_eltwise_backward_primitive_desc_create .. _doxid-group__dnnl__api__eltwise_1gaba11ca62016a1c23d997db47bcd6c27d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_status_t` DNNL_API dnnl_eltwise_backward_primitive_desc_create( :ref:`dnnl_primitive_desc_t`* primitive_desc, :ref:`dnnl_engine_t` engine, :ref:`dnnl_alg_kind_t` alg_kind, :ref:`const_dnnl_memory_desc_t` diff_src_desc, :ref:`const_dnnl_memory_desc_t` diff_dst_desc, :ref:`const_dnnl_memory_desc_t` data_desc, float alpha, float beta, :ref:`const_dnnl_primitive_desc_t` hint_fwd_pd, :ref:`const_dnnl_primitive_attr_t` attr ) Creates a primitive descriptor for an eltwise backward propagation primitive. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - primitive_desc - Output primitive descriptor. * - engine - Engine to use. * - alg_kind - Elementwise algorithm kind. * - diff_src_desc - Diff source memory descriptor. * - diff_dst_desc - Diff destination memory descriptor. * - data_desc - Destination memory descriptor if one of the "use_dst_for_bwd" algorithms are used (such as :ref:`dnnl_eltwise_relu_use_dst_for_bwd `), source memory descriptor otherwise. * - alpha - The alpha parameter for the elementwise operation. Specific meaning depends on the algorithm. * - beta - The beta parameter for the elementwise operation. Specific meaning depends on the algorithm. * - hint_fwd_pd - Primitive descriptor for a respective forward propagation primitive. * - attr - Primitive attributes (can be NULL). .. rubric:: Returns: :ref:`dnnl_success ` on success and a status describing the error otherwise.