Visible to Intel only — GUID: GUID-60F26F6C-0091-4C95-B253-06E5E8AE041B
Visible to Intel only — GUID: GUID-60F26F6C-0091-4C95-B253-06E5E8AE041B
Graph
Overview
Graph represents a computational DAG with a set of operations. More…
// typedefs
typedef struct dnnl_graph_graph* dnnl_graph_graph_t;
typedef const struct dnnl_graph_graph* const_dnnl_graph_graph_t;
// classes
class dnnl::graph::graph;
// global functions
dnnl_status_t DNNL_API dnnl_graph_graph_create(
dnnl_graph_graph_t* graph,
dnnl_engine_kind_t engine_kind
);
dnnl_status_t DNNL_API dnnl_graph_graph_create_with_fpmath_mode(
dnnl_graph_graph_t* graph,
dnnl_engine_kind_t engine_kind,
dnnl_fpmath_mode_t mode
);
dnnl_status_t DNNL_API dnnl_graph_graph_destroy(dnnl_graph_graph_t graph);
dnnl_status_t DNNL_API dnnl_graph_add_op(
dnnl_graph_graph_t graph,
dnnl_graph_op_t op
);
dnnl_status_t DNNL_API dnnl_graph_graph_finalize(dnnl_graph_graph_t graph);
dnnl_status_t DNNL_API dnnl_graph_graph_is_finalized(
dnnl_graph_graph_t graph,
uint8_t* finalized
);
dnnl_status_t DNNL_API dnnl_graph_graph_filter(
dnnl_graph_graph_t graph,
dnnl_graph_partition_policy_t policy
);
dnnl_status_t DNNL_API dnnl_graph_graph_get_partition_num(
const_dnnl_graph_graph_t graph,
size_t* num
);
dnnl_status_t DNNL_API dnnl_graph_graph_get_partitions(
dnnl_graph_graph_t graph,
size_t num,
dnnl_graph_partition_t* partitions
);
Detailed Documentation
Graph represents a computational DAG with a set of operations.
dnnl::graph::graph::add_op() adds an operation and its input and output logical tensors into a graph. The library accumulates the operations and logical tensors and constructs and validates the graph as an internal state. A graph object is associated to a specific engine kind. The partitions returned from the graph will inherit the engine kind of the graph.
Typedefs
typedef struct dnnl_graph_graph* dnnl_graph_graph_t
A graph handle.
typedef const struct dnnl_graph_graph* const_dnnl_graph_graph_t
A constant graph handle.
Global Functions
dnnl_status_t DNNL_API dnnl_graph_graph_create(
dnnl_graph_graph_t* graph,
dnnl_engine_kind_t engine_kind
)
Creates a new empty graph.
A graph is associated to a specific engine kind. The partitions returned from the graph will inherit the engine kind of the graph.
Parameters:
graph |
The handle of output graph. |
engine_kind |
The target engine kind. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_graph_create_with_fpmath_mode(
dnnl_graph_graph_t* graph,
dnnl_engine_kind_t engine_kind,
dnnl_fpmath_mode_t mode
)
Creates a new empty graph with an engine kind and a floating-point math mode.
All partitions returned from the graph will inherit the engine kind and floating-point math mode.
Parameters:
graph |
The handle of output graph. |
engine_kind |
The kind for engine. |
mode |
The floating-point math mode. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_graph_destroy(dnnl_graph_graph_t graph)
Destroys a graph.
Parameters:
graph |
The graph to be destroyed. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_add_op(
dnnl_graph_graph_t graph,
dnnl_graph_op_t op
)
Adds an operation into a graph.
The API will return failure if the operator has already been added to the graph or the operation cannot pass the schema check in the library (eg. input and output numbers and data types, the attributes of the operation, etc.).
Parameters:
graph |
The target graph. |
op |
The operation to be added. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_graph_finalize(dnnl_graph_graph_t graph)
Finalizes a graph.
It means users have finished adding operations into the graph and the graph is ready for partitioning. Adding a new operation into a finalized graph will return failures. Similarly, partitioning on a un-finalized graph will also return failures.
Parameters:
graph |
The target graph to be finalized. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_graph_is_finalized(
dnnl_graph_graph_t graph,
uint8_t* finalized
)
Checks if a graph is finalized.
Parameters:
graph |
The target graph to be finalized. |
finalized |
Output the finalization status. 0 means then graph is not finalized. Other values means the graph is finalized. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_graph_filter(
dnnl_graph_graph_t graph,
dnnl_graph_partition_policy_t policy
)
Filters a graph.
Partitions will be claimed internally according to the capability of the library, the engine kind, and the policy.
Parameters:
graph |
The target graph. |
policy |
The partition policy. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_graph_get_partition_num(
const_dnnl_graph_graph_t graph,
size_t* num
)
Returns the number of partitions of a graph.
The API should be called after a partition is already filtered. Otherwise, the output number is zero.
Parameters:
graph |
The graph. |
num |
Output the number of partitions. |
Returns:
dnnl_success on success or a status describing the error otherwise.
dnnl_status_t DNNL_API dnnl_graph_graph_get_partitions(
dnnl_graph_graph_t graph,
size_t num,
dnnl_graph_partition_t* partitions
)
Returns the partitions from a filtered graph.
Output partition instances will be written into the parameter partitions. Users need to make sure partitions is valid and has enough space to accept the partition instances. Each output partition instance should be destroyed via dnnl_graph_partition_destroy explicitly after use.
Parameters:
graph |
The target graph. |
num |
The number of partitions. |
partitions |
Output the partitions. |
Returns:
dnnl_success on success or a status describing the error otherwise.