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_i, req<std::is_same<Type_i, int64_t>::value> = true>
    op& set_attr(
        attr name,
        const Type_i& value
        );

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

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

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

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

    template <typename Type_fs, req<std::is_same<Type_fs, std::vector<float>>::value> = true>
    op& set_attr(
        attr name,
        const Type_fs& 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_i, req<std::is_same<Type_i, int64_t>::value> = true>
op& set_attr(
    attr name,
    const Type_i& value
    )

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

Parameters:

Type_i

Attribute’s type.

name

Attribute’s name.

value

The attribute’s value.

Returns:

The Op self.

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

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

Parameters:

Type_f

Attribute’s type.

name

Attribute’s name.

value

The attribute’s value.

Returns:

The Op self.

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

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

Parameters:

Type_b

Attribute’s type.

name

Attribute’s name.

value

The attribute’s value.

Returns:

The Op self.

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

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

Parameters:

Type_s

Attribute’s type.

name

Attribute’s name.

value

The attribute’s value.

Returns:

The Op self.

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

Sets the attribute according to the name and type (std::vector<int64_t>).

Parameters:

Type_is

Attribute’s type.

name

Attribute’s name.

value

The attribute’s value.

Returns:

The Op self.

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

Sets the attribute according to the name and type (std::vector<float>).

Parameters:

Type_fs

Attribute’s type.

name

Attribute’s name.

value

The attribute’s value.

Returns:

The Op self.