Op

Overview

OP is an abstraction of computation logic for deep neural network operations. More…

// typedefs

typedef struct dnnl_graph_op* dnnl_graph_op_t;
typedef const struct dnnl_graph_op* const_dnnl_graph_op_t;

// enums

enum dnnl_graph_op_attr_t;
enum dnnl_graph_op_kind_t;

// classes

class dnnl::graph::op;

// global functions

dnnl_status_t DNNL_API dnnl_graph_op_create(
    dnnl_graph_op_t* op,
    size_t id,
    dnnl_graph_op_kind_t kind,
    const char* verbose_name
    );

dnnl_status_t DNNL_API dnnl_graph_op_destroy(dnnl_graph_op_t op);

dnnl_status_t DNNL_API dnnl_graph_op_add_input(
    dnnl_graph_op_t op,
    const dnnl_graph_logical_tensor_t* input
    );

dnnl_status_t DNNL_API dnnl_graph_op_add_output(
    dnnl_graph_op_t op,
    const dnnl_graph_logical_tensor_t* output
    );

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_f32(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const float* value,
    size_t value_len
    );

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_bool(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const uint8_t* value,
    size_t value_len
    );

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_s64(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const int64_t* value,
    size_t value_len
    );

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_str(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const char* value,
    size_t value_len
    );

dnnl_status_t DNNL_API dnnl_graph_op_get_id(
    const_dnnl_graph_op_t op,
    size_t* id
    );

dnnl_status_t DNNL_API dnnl_graph_op_get_kind(
    const_dnnl_graph_op_t op,
    dnnl_graph_op_kind_t* kind
    );

Detailed Documentation

OP is an abstraction of computation logic for deep neural network operations.

An op object encapsulates an operation kind which describes the computation logic, an unique ID which differentiates operations with the same kind, and logical tensors which describes the input and output of the operation and its connections to other operations in the graph.

Typedefs

typedef struct dnnl_graph_op* dnnl_graph_op_t

An operation handle.

typedef const struct dnnl_graph_op* const_dnnl_graph_op_t

A constant operation handle.

Global Functions

dnnl_status_t DNNL_API dnnl_graph_op_create(
    dnnl_graph_op_t* op,
    size_t id,
    dnnl_graph_op_kind_t kind,
    const char* verbose_name
    )

Initializes an op with unique id, kind, and name.

Parameters:

op

Output op

id

The unique id of the output op.

kind

The op kind.

verbose_name

The string added as the op name.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_destroy(dnnl_graph_op_t op)

Destroys an op.

Parameters:

op

The op to be destroyed.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_add_input(
    dnnl_graph_op_t op,
    const dnnl_graph_logical_tensor_t* input
    )

Adds input logical tensor to the op.

Parameters:

op

Input op.

input

The input logical tensor to be added.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_add_output(
    dnnl_graph_op_t op,
    const dnnl_graph_logical_tensor_t* output
    )

Adds output logical tensor to the op.

Parameters:

op

Input op.

output

The output logical tensor to be added.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_f32(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const float* value,
    size_t value_len
    )

Sets floating point attribute to an op.

Parameters:

op

Input op.

name

The attribute’s name.

value

The attribute’s value.

value_len

The number of value element.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_bool(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const uint8_t* value,
    size_t value_len
    )

Sets boolean attribute to an op.

Parameters:

op

Input op.

name

The attribute’s name.

value

The attribute’s value.

value_len

The number of value element.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_s64(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const int64_t* value,
    size_t value_len
    )

Sets integer attribute to an op.

Parameters:

op

Input op.

name

The attribute’s name.

value

The attribute’s value.

value_len

The number of value element.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_set_attr_str(
    dnnl_graph_op_t op,
    dnnl_graph_op_attr_t name,
    const char* value,
    size_t value_len
    )

Sets string attribute to an op.

Parameters:

op

Input op.

name

The attribute’s name.

value

The attribute’s value.

value_len

The length of the string value.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_get_id(
    const_dnnl_graph_op_t op,
    size_t* id
    )

Returns the unique id of an op.

Parameters:

op

Input op.

id

Output the unique id.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_op_get_kind(
    const_dnnl_graph_op_t op,
    dnnl_graph_op_kind_t* kind
    )

Returns the kind of an op.

Parameters:

op

Input op.

kind

Output op kind.

Returns:

dnnl_success on success or a status describing the error otherwise.