class dnnl::graph::op

Overview

An op object. More…

#include <dnnl_graph.hpp>

class op: public op_handle
{
public:
    // enums

    enum attr;
    enum kind;

    // construction

    op(size_t id, kind akind, const std::string& verbose_name = "");

    op(
        size_t id,
        kind akind,
        const std::vector<logical_tensor>& inputs,
        const std::vector<logical_tensor>& outputs,
        const std::string& verbose_name = ""
        );

    // methods

    void add_input(const logical_tensor& t);
    void add_inputs(const std::vector<logical_tensor>& ts);
    void add_output(const logical_tensor& t);
    void add_outputs(const std::vector<logical_tensor>& ts);

    template <typename Type, req<std::is_same<Type, int64_t>::value> = true>
    op& set_attr(
        attr name,
        const Type& value
        );
};

Detailed Documentation

An op object.

Construction

op(size_t id, kind akind, const std::string& verbose_name = "")

Constructs an op object with an unique ID, an operation kind, and a name string.

Parameters:

id

The unique ID of the op.

akind

The op kind specifies which computation is represented by the op, such as Convolution or ReLU.

verbose_name

The string added as the op name.

op(
    size_t id,
    kind akind,
    const std::vector<logical_tensor>& inputs,
    const std::vector<logical_tensor>& outputs,
    const std::string& verbose_name = ""
    )

Constructs an op object with an unique ID, an operation kind, and input/output logical tensors.

Parameters:

id

The unique ID of this op.

akind

The op kind specifies which computation is represented by this op, such as Convolution or ReLU.

inputs

Input logical tensor to be bound to this op.

outputs

Output logical tensor to be bound to this op.

verbose_name

The string added as the op name.

Methods

void add_input(const logical_tensor& t)

Adds an input logical tensor to the op.

Parameters:

t

Input logical tensor.

void add_inputs(const std::vector<logical_tensor>& ts)

Adds a vector of input logical tensors to the op.

Parameters:

ts

The list of input logical tensors.

void add_output(const logical_tensor& t)

Adds an output logical tensor to the op.

Parameters:

t

Output logical tensor.

void add_outputs(const std::vector<logical_tensor>& ts)

Adds a vector of output logical tensors to the op.

Parameters:

ts

The list of output logical tensors.

template <typename Type, req<std::is_same<Type, int64_t>::value> = true>
op& set_attr(
    attr name,
    const Type& value
    )

Sets the attribute according to the name and type (int64_t).

Parameters:

Type

Attribute’s type.

name

Attribute’s name.

value

The attribute’s value.

Returns:

The Op self.