.. index:: pair: struct; dnnl::primitive .. _doxid-structdnnl_1_1primitive: struct dnnl::primitive ====================== .. toctree:: :hidden: enum_dnnl_primitive_kind.rst Overview ~~~~~~~~ Base class for all computational primitives. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include struct primitive: public :ref:`dnnl::handle` { // enums enum :ref:`kind`; // construction :ref:`primitive`(); :ref:`primitive`(:ref:`const_dnnl_primitive_desc_t` c_pd); :ref:`primitive`( :ref:`const_dnnl_primitive_desc_t` c_pd, const std::vector& cache_blob ); :ref:`primitive`(const :ref:`primitive_desc`& pd); :ref:`primitive`(const :ref:`primitive_desc`& pd, const std::vector& cache_blob); // methods :ref:`const_dnnl_primitive_desc_t` :ref:`get_primitive_desc`() const; :ref:`kind` :ref:`get_kind`() const; std::vector :ref:`get_cache_blob`() const; void :ref:`execute`(const :ref:`stream`& astream, const std::unordered_map`>& args) const; :ref:`handle`(); :ref:`handle`(); :ref:`handle`(); :ref:`handle`(); }; // direct descendants struct :ref:`augru_backward`; struct :ref:`augru_forward`; struct :ref:`batch_normalization_backward`; struct :ref:`batch_normalization_forward`; struct :ref:`binary`; struct :ref:`concat`; struct :ref:`convolution_backward_data`; struct :ref:`convolution_backward_weights`; struct :ref:`convolution_forward`; struct :ref:`deconvolution_backward_data`; struct :ref:`deconvolution_backward_weights`; struct :ref:`deconvolution_forward`; struct :ref:`eltwise_backward`; struct :ref:`eltwise_forward`; struct :ref:`group_normalization_backward`; struct :ref:`group_normalization_forward`; struct :ref:`gru_backward`; struct :ref:`gru_forward`; struct :ref:`inner_product_backward_data`; struct :ref:`inner_product_backward_weights`; struct :ref:`inner_product_forward`; struct :ref:`layer_normalization_backward`; struct :ref:`layer_normalization_forward`; struct :ref:`lbr_augru_backward`; struct :ref:`lbr_augru_forward`; struct :ref:`lbr_gru_backward`; struct :ref:`lbr_gru_forward`; struct :ref:`lrn_backward`; struct :ref:`lrn_forward`; struct :ref:`lstm_backward`; struct :ref:`lstm_forward`; struct :ref:`matmul`; struct :ref:`pooling_backward`; struct :ref:`pooling_forward`; struct :ref:`prelu_backward`; struct :ref:`prelu_forward`; struct :ref:`reduction`; struct :ref:`reorder`; struct :ref:`resampling_backward`; struct :ref:`resampling_forward`; struct :ref:`shuffle_backward`; struct :ref:`shuffle_forward`; struct :ref:`softmax_backward`; struct :ref:`softmax_forward`; struct :ref:`sum`; struct :ref:`vanilla_rnn_backward`; struct :ref:`vanilla_rnn_forward`; Inherited Members ----------------- .. ref-code-block:: cpp :class: doxyrest-overview-inherited-code-block public: // methods :ref:`handle`& :ref:`operator =` (const :ref:`handle`&); :ref:`handle`& :ref:`operator =` (:ref:`handle`&&); void :ref:`reset`(T t, bool weak = false); T :ref:`get`(bool allow_empty = false) const; :ref:`operator T` () const; :ref:`operator bool` () const; bool :ref:`operator ==` (const :ref:`handle`& other) const; bool :ref:`operator !=` (const :ref:`handle`& other) const; .. _details-structdnnl_1_1primitive: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Base class for all computational primitives. Construction ------------ .. index:: pair: function; primitive .. _doxid-structdnnl_1_1primitive_1a4ba1e667dfc4d3abda8fa47e8bc8bbdb: .. ref-code-block:: cpp :class: doxyrest-title-code-block primitive() Default constructor. Constructs an empty object. .. index:: pair: function; primitive .. _doxid-structdnnl_1_1primitive_1add43d05c97c3cd96a5d7cab07d6935f4: .. ref-code-block:: cpp :class: doxyrest-title-code-block primitive(:ref:`const_dnnl_primitive_desc_t` c_pd) Constructs a primitive from a C API primitive descriptor. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - c_pd - C API primitive descriptor. .. index:: pair: function; primitive .. _doxid-structdnnl_1_1primitive_1abd151bdbbd2ccc7074e59cda584d38f4: .. ref-code-block:: cpp :class: doxyrest-title-code-block primitive( :ref:`const_dnnl_primitive_desc_t` c_pd, const std::vector& cache_blob ) Constructs a primitive from a C API primitive descriptor and a cache blob. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - c_pd - C API primitive descriptor. * - cache_blob - Cache blob. .. index:: pair: function; primitive .. _doxid-structdnnl_1_1primitive_1ac356cacc1b41b95397d2c6a8c091e700: .. ref-code-block:: cpp :class: doxyrest-title-code-block primitive(const :ref:`primitive_desc`& pd) Constructs a primitive from a primitive descriptor. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - pd - Primitive descriptor. .. index:: pair: function; primitive .. _doxid-structdnnl_1_1primitive_1a6aabbb4e883e6cdd796a67e5e9fb2228: .. ref-code-block:: cpp :class: doxyrest-title-code-block primitive(const :ref:`primitive_desc`& pd, const std::vector& cache_blob) Constructs a primitive from a primitive descriptor and a cache blob. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - pd - Primitive descriptor. * - cache_blob - Cache blob. Methods ------- .. index:: pair: function; get_primitive_desc .. _doxid-group__dnnl__api__primitives__common_1ga6d84440f113be4c6697092a0b968aa36: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`const_dnnl_primitive_desc_t` get_primitive_desc() const Returns the C API primitive descriptor of the underlying C API primitive. .. rubric:: Returns: The underlying C API primitive descriptor. .. index:: pair: function; get_kind .. _doxid-group__dnnl__api__primitives__common_1gab715f58b261078428fc2a99c9ee527fc: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`kind` get_kind() const Returns the kind of the primitive. .. rubric:: Returns: The primitive kind. .. index:: pair: function; get_cache_blob .. _doxid-group__dnnl__api__primitives__common_1ga8bf59b36c745ee8eaec9d0dd22e266e9: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector get_cache_blob() const Returns a cache blob for the primitive. .. note:: The cache blob can be empty. It's the user's responsibility to check whether it's empty prior to passing it to the primitive constructor. .. rubric:: Returns: Vector containing the cache blob. .. index:: pair: function; execute .. _doxid-structdnnl_1_1primitive_1a2c112f2449a18a87310dee2ecd8c64eb: .. ref-code-block:: cpp :class: doxyrest-title-code-block void execute(const :ref:`stream`& astream, const std::unordered_map`>& args) const Executes computations specified by the primitive in a specified stream. Arguments are passed via an arguments map containing pairs. The index must be one of the ``DNNL_ARG_*`` values such as ``DNNL_ARG_SRC``, and the memory must have a memory descriptor matching the one returned by :ref:`primitive_desc::query_md ` (:ref:`query::exec_arg_md `, index) unless using dynamic shapes (see :ref:`DNNL_RUNTIME_DIM_VAL `). .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - astream - Stream object. The stream must belong to the same engine as the primitive. * - args - Arguments map. .. index:: pair: function; handle .. _doxid-structdnnl_1_1primitive_1a5c631f7e5e4c92a13edb8e3422d3a973: .. ref-code-block:: cpp :class: doxyrest-title-code-block handle() Constructs an empty handle object. .. warning:: Uninitialized object cannot be used in most library calls and is equivalent to a null pointer. Any attempt to use its methods, or passing it to the other library function, will cause an exception to be thrown. .. index:: pair: function; handle .. _doxid-structdnnl_1_1primitive_1a022001b5b9c8940a1326a02b61fc4860: .. ref-code-block:: cpp :class: doxyrest-title-code-block handle() Copy constructor. .. index:: pair: function; handle .. _doxid-structdnnl_1_1primitive_1aa13f3ecf4db240717074814412c7e70c: .. ref-code-block:: cpp :class: doxyrest-title-code-block handle() Move constructor. .. index:: pair: function; handle .. _doxid-structdnnl_1_1primitive_1a9c408c09fce1278f5cb0d1fa9818fc86: .. ref-code-block:: cpp :class: doxyrest-title-code-block handle() Constructs a handle wrapper object from a C API handle. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - t - The C API handle to wrap. * - weak - A flag specifying whether to construct a weak wrapper; defaults to ``false``.