class dnnl::graph::graph¶
Overview¶
A graph object. More…
#include <dnnl_graph.hpp> class graph: public graph_handle { public: // construction graph(engine::kind engine_kind); graph(engine::kind engine_kind, fpmath_mode mode); // methods status add_op(const op& op, bool allow_exception = true); void finalize(); bool is_finalized() const; std::vector<partition> get_partitions(partition::policy policy = partition::policy::fusion); };
Detailed Documentation¶
A graph object.
Construction¶
graph(engine::kind engine_kind)
Constructs a graph with an engine kind.
Parameters:
engine_kind |
Engine kind. |
graph(engine::kind engine_kind, fpmath_mode 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:
engine_kind |
Engine kind. |
mode |
Floating-point math mode. |
Methods¶
status add_op(const op& op, bool allow_exception = true)
Adds an op into the graph to construct a computational DAG.
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:
op |
An operation to be added. |
allow_exception |
A flag indicating whether the method is allowed to throw an exception if it fails to add the op to the graph. |
Returns:
status::success or a status describing the error otherwise.
void finalize()
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.
bool is_finalized() const
Checks if a graph is finalized.
Returns:
True if the graph is finalized or false if the graph is not finalized.
std::vector<partition> get_partitions(partition::policy policy = partition::policy::fusion)
Gets filtered partitions from a graph.
Partitions will be claimed internally according to the capability of the library, the engine kind of the graph, and the policy.
Parameters:
policy |
Partition policy, defaults to policy dnnl::graph::partition::policy::fusion. |
Returns:
A vector storing the partitions.