Intel® oneAPI Deep Neural Network Developer Guide and Reference
A newer version of this document is available. Customers should click here to go to the newest version.
struct dnnl::primitive
Overview
Base class for all computational primitives. More…
#include <dnnl.hpp>
struct primitive: public dnnl::handle
{
    // enums
    enum kind;
    // construction
    primitive();
    primitive(const_dnnl_primitive_desc_t c_pd);
    primitive(
        const_dnnl_primitive_desc_t c_pd,
        const std::vector<uint8_t>& cache_blob
        );
    primitive(const primitive_desc& pd);
    primitive(const primitive_desc& pd, const std::vector<uint8_t>& cache_blob);
    // methods
    const_dnnl_primitive_desc_t get_primitive_desc() const;
    kind get_kind() const;
    std::vector<uint8_t> get_cache_blob() const;
    void execute(const stream& astream, const std::unordered_map<int, memory>& args) const;
    handle();
    handle();
    handle();
    handle();
};
// direct descendants
struct augru_backward;
struct augru_forward;
struct batch_normalization_backward;
struct batch_normalization_forward;
struct binary;
struct concat;
struct convolution_backward_data;
struct convolution_backward_weights;
struct convolution_forward;
struct deconvolution_backward_data;
struct deconvolution_backward_weights;
struct deconvolution_forward;
struct eltwise_backward;
struct eltwise_forward;
struct group_normalization_backward;
struct group_normalization_forward;
struct gru_backward;
struct gru_forward;
struct inner_product_backward_data;
struct inner_product_backward_weights;
struct inner_product_forward;
struct layer_normalization_backward;
struct layer_normalization_forward;
struct lbr_augru_backward;
struct lbr_augru_forward;
struct lbr_gru_backward;
struct lbr_gru_forward;
struct lrn_backward;
struct lrn_forward;
struct lstm_backward;
struct lstm_forward;
struct matmul;
struct pooling_backward;
struct pooling_forward;
struct prelu_backward;
struct prelu_forward;
struct reduction;
struct reorder;
struct resampling_backward;
struct resampling_forward;
struct shuffle_backward;
struct shuffle_forward;
struct softmax_backward;
struct softmax_forward;
struct sum;
struct vanilla_rnn_backward;
struct vanilla_rnn_forward;Inherited Members
public:
    // methods
    handle<T, traits>& operator = (const handle<T, traits>&);
    handle<T, traits>& operator = (handle<T, traits>&&);
    void reset(T t, bool weak = false);
    T get(bool allow_empty = false) const;
    operator T () const;
    operator bool () const;
    bool operator == (const handle<T, traits>& other) const;
    bool operator != (const handle& other) const;Detailed Documentation
Base class for all computational primitives.
Construction
primitive()Default constructor. Constructs an empty object.
primitive(const_dnnl_primitive_desc_t c_pd)Constructs a primitive from a C API primitive descriptor.
Parameters:
| c_pd | C API primitive descriptor. | 
primitive(
    const_dnnl_primitive_desc_t c_pd,
    const std::vector<uint8_t>& cache_blob
    )Constructs a primitive from a C API primitive descriptor and a cache blob.
Parameters:
| c_pd | C API primitive descriptor. | 
| cache_blob | Cache blob. | 
primitive(const primitive_desc& pd)Constructs a primitive from a primitive descriptor.
Parameters:
| pd | Primitive descriptor. | 
primitive(const primitive_desc& pd, const std::vector<uint8_t>& cache_blob)Constructs a primitive from a primitive descriptor and a cache blob.
Parameters:
| pd | Primitive descriptor. | 
| cache_blob | Cache blob. | 
Methods
const_dnnl_primitive_desc_t get_primitive_desc() constReturns the C API primitive descriptor of the underlying C API primitive.
Returns:
The underlying C API primitive descriptor.
kind get_kind() constReturns the kind of the primitive.
Returns:
The primitive kind.
std::vector<uint8_t> get_cache_blob() constReturns a cache blob for the primitive.
Returns:
Vector containing the cache blob.
void execute(const stream& astream, const std::unordered_map<int, memory>& args) constExecutes computations specified by the primitive in a specified stream.
Arguments are passed via an arguments map containing <index, memory object> 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 primitive_desc::query_md (query::exec_arg_md, index) unless using dynamic shapes (see DNNL_RUNTIME_DIM_VAL).
Parameters:
| astream | Stream object. The stream must belong to the same engine as the primitive. | 
| args | Arguments map. | 
handle()Constructs an empty handle object.
handle()Copy constructor.
handle()Move constructor.
handle()Constructs a handle wrapper object from a C API handle.
Parameters:
| t | The C API handle to wrap. | 
| weak | A flag specifying whether to construct a weak wrapper; defaults to false. |