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 primitive_desc& pd);

    // methods

    const_dnnl_primitive_desc_t get_primitive_desc() const;
    kind get_kind() const;
    void execute(const stream& astream, const std::unordered_map<int, memory>& args) const;
};

// direct descendants

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 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_gru_backward;
struct lbr_gru_forward;
struct logsoftmax_backward;
struct logsoftmax_forward;
struct lrn_backward;
struct lrn_forward;
struct lstm_backward;
struct lstm_forward;
struct matmul;
struct pooling_backward;
struct pooling_forward;
struct pooling_v2_backward;
struct pooling_v2_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 primitive_desc& pd)

Constructs a primitive from a primitive descriptor.

Parameters:

pd

Primitive descriptor.

Methods

const_dnnl_primitive_desc_t get_primitive_desc() const

Returns the C API primitive descriptor of the underlying C API primitive.

Returns:

The underlying C API primitive descriptor.

kind get_kind() const

Returns the kind of the primitive.

Returns:

The primitive kind.

void execute(const stream& astream, const std::unordered_map<int, memory>& args) const

Executes 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.