class dnnl::graph::partition¶
Overview¶
A partition object. More…
#include <dnnl_graph.hpp> class partition: public partition_handle { public: // enums enum policy; // construction partition(); partition(dnnl_graph_partition_t p); partition(const op& aop, engine::kind ekind); // methods size_t get_ops_num() const; std::vector<size_t> get_ops() const; size_t get_id() const; compiled_partition compile( const std::vector<logical_tensor>& inputs, const std::vector<logical_tensor>& outputs, const engine& e ) const; bool is_supported() const; std::vector<logical_tensor> get_input_ports() const; std::vector<logical_tensor> get_output_ports() const; engine::kind get_engine_kind() const; };
Detailed Documentation¶
A partition object.
Construction¶
partition(dnnl_graph_partition_t p)
Constructs a partition object.
Parameters:
p |
A raw pointer to the C API handle |
partition(const op& aop, engine::kind 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.
Parameters:
aop |
An operation used to create the partition. |
ekind |
Engine kind. |
Methods¶
size_t get_ops_num() const
Returns the number of operations contained in the partition.
Returns:
Number of operations.
std::vector<size_t> get_ops() const
Returns all operation IDs contained in the partition.
Returns:
An unordered set of operation IDs.
size_t get_id() const
Returns the unique ID of the partition.
Partition ID is generated by the library internally. The ID can be used for debugging purpose or verbose.
Returns:
ID of the partition.
compiled_partition compile( const std::vector<logical_tensor>& inputs, const std::vector<logical_tensor>& outputs, const engine& e ) const
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:
inputs |
A list of input logical tensors. |
outputs |
A list of output logical tensors. |
e |
The engine used to compile the partition. |
Returns:
A compiled partition.
bool is_supported() const
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.
Returns:
true
if this partition is supported or false
if this partition isn’t supported by the library
std::vector<logical_tensor> get_input_ports() const
Returns a list of input logical tensors from the partition.
Returns:
A list of input logical tensors.
std::vector<logical_tensor> get_output_ports() const
Returns a list of output logical tensors from the partition.
Returns:
A list of output logical tensor.
engine::kind get_engine_kind() const
Returns the engine kind of the partition.
Returns:
The engine kind