Partition

Overview

Partition represents a collection of operations and their input and output logical tensors identified by library as the basic unit for compilation and execution. More…

// typedefs

typedef struct dnnl_graph_partition* dnnl_graph_partition_t;
typedef const struct dnnl_graph_partition* const_dnnl_graph_partition_t;

// enums

enum dnnl_graph_partition_policy_t;

// classes

class dnnl::graph::partition;

// global functions

dnnl_status_t DNNL_API dnnl_graph_partition_create_with_op(
    dnnl_graph_partition_t* partition,
    const_dnnl_graph_op_t op,
    dnnl_engine_kind_t ekind
    );

dnnl_status_t DNNL_API dnnl_graph_partition_destroy(dnnl_graph_partition_t partition);

dnnl_status_t DNNL_API dnnl_graph_partition_get_op_num(
    const_dnnl_graph_partition_t partition,
    size_t* num
    );

dnnl_status_t DNNL_API dnnl_graph_partition_get_ops(
    dnnl_graph_partition_t partition,
    size_t num,
    size_t* ids
    );

dnnl_status_t DNNL_API dnnl_graph_partition_get_id(
    const_dnnl_graph_partition_t partition,
    size_t* id
    );

dnnl_status_t DNNL_API dnnl_graph_partition_compile(
    dnnl_graph_partition_t partition,
    dnnl_graph_compiled_partition_t compiled_partition,
    size_t in_num,
    const dnnl_graph_logical_tensor_t** inputs,
    size_t out_num,
    const dnnl_graph_logical_tensor_t** outputs,
    dnnl_engine_t engine
    );

dnnl_status_t DNNL_API dnnl_graph_partition_get_input_ports_num(
    const_dnnl_graph_partition_t partition,
    size_t* num
    );

dnnl_status_t DNNL_API dnnl_graph_partition_get_input_ports(
    const_dnnl_graph_partition_t partition,
    size_t num,
    dnnl_graph_logical_tensor_t* inputs
    );

dnnl_status_t DNNL_API dnnl_graph_partition_get_output_ports_num(
    const_dnnl_graph_partition_t partition,
    size_t* num
    );

dnnl_status_t DNNL_API dnnl_graph_partition_get_output_ports(
    const_dnnl_graph_partition_t partition,
    size_t num,
    dnnl_graph_logical_tensor_t* outputs
    );

dnnl_status_t DNNL_API dnnl_graph_partition_is_supported(
    const_dnnl_graph_partition_t partition,
    uint8_t* is_supported
    );

dnnl_status_t DNNL_API dnnl_graph_partition_get_engine_kind(
    const_dnnl_graph_partition_t partition,
    dnnl_engine_kind_t* kind
    );

Detailed Documentation

Partition represents a collection of operations and their input and output logical tensors identified by library as the basic unit for compilation and execution.

Typedefs

typedef struct dnnl_graph_partition* dnnl_graph_partition_t

A partition handle.

typedef const struct dnnl_graph_partition* const_dnnl_graph_partition_t

A constant partition handle.

Global Functions

dnnl_status_t DNNL_API dnnl_graph_partition_create_with_op(
    dnnl_graph_partition_t* partition,
    const_dnnl_graph_op_t op,
    dnnl_engine_kind_t ekind
    )

Creates a new partition with a given operator and engine kind.

The API is used to create a partition from an operation directly without creating the graph and calling get_partitions(). The output partition contains only one operation specified by the parameter. The output partition instance should be destroyed via dnnl_graph_partition_destroy after use.

Parameters:

partition

The handle of output partition.

op

The operation used to create partition.

ekind

The engine kind used to create partition.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_destroy(dnnl_graph_partition_t partition)

Destroys a partition.

Parameters:

partition

The partition to be destroyed.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_op_num(
    const_dnnl_graph_partition_t partition,
    size_t* num
    )

Returns the number of operations in a partition.

Parameters:

partition

The target partition.

num

Output the number of operations.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_ops(
    dnnl_graph_partition_t partition,
    size_t num,
    size_t* ids
    )

Returns the list of op IDs of the partition.

Parameters:

partition

The target partition.

num

The number of ops.

ids

Output the op IDs.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_id(
    const_dnnl_graph_partition_t partition,
    size_t* id
    )

Returns the ID of a partition.

Parameters:

partition

The target partition.

id

Output the ID of the partition.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_compile(
    dnnl_graph_partition_t partition,
    dnnl_graph_compiled_partition_t compiled_partition,
    size_t in_num,
    const dnnl_graph_logical_tensor_t** inputs,
    size_t out_num,
    const dnnl_graph_logical_tensor_t** outputs,
    dnnl_engine_t engine
    )

Compiles a partition with given input and output logical tensors.

The output logical tensors can contain unknown dimensions. For this case, the compilation will deduce the output shapes according to input shapes. The output logical tensors can also have layout type any. The compilation will choose the optimal layout for output tensors. The optimal layout will be represented as an opaque layout ID saved in the output logical tensor.

Parameters:

partition

The target partition.

compiled_partition

Output compiled partition.

in_num

The number of input logical tensors.

inputs

A list of input logical tensors.

out_num

The number of output logical tensors.

outputs

A list of output logical tensors.

engine

The target engine of the compilation.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_input_ports_num(
    const_dnnl_graph_partition_t partition,
    size_t* num
    )

Returns the number of input logical tensors of a partition.

Parameters:

partition

The target partition.

num

Output the number of input logical tensors.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_input_ports(
    const_dnnl_graph_partition_t partition,
    size_t num,
    dnnl_graph_logical_tensor_t* inputs
    )

Returns a list of input logical tensors from a partition.

Parameters:

partition

The target partition.

num

The number of input logical tensors.

inputs

The list of input logical tensors.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_output_ports_num(
    const_dnnl_graph_partition_t partition,
    size_t* num
    )

Returns the number of output logical tensors of a partition.

Parameters:

partition

The target partition.

num

Output the number of output logical tensors.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_output_ports(
    const_dnnl_graph_partition_t partition,
    size_t num,
    dnnl_graph_logical_tensor_t* outputs
    )

Returns a list of output logical tensors from a partition.

Parameters:

partition

The target partition.

num

The number of output logical tensors.

outputs

The list of output logical tensors.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_is_supported(
    const_dnnl_graph_partition_t partition,
    uint8_t* is_supported
    )

Returns the supporting status of a partition.

Some operations may not be supported by the library under certain circumstances. During partitioning stage, unsupported partitions will be returned to users with each containing an unsupported operation. Users should check the supporting status of a partition before transforming the computation graph or compiling the partition.

Parameters:

partition

The target partition.

is_supported

Output flag to indicate the supporting status. 0 means unsupported while 1 means supported.

Returns:

dnnl_success on success or a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_partition_get_engine_kind(
    const_dnnl_graph_partition_t partition,
    dnnl_engine_kind_t* kind
    )

Returns the engine kind of a partition.

Parameters:

partition

The target partition.

kind

The output engine kind.

Returns:

dnnl_success on success or a status describing the error otherwise.