struct dnnl_graph_logical_tensor_t¶
Overview¶
Logical tensor. More…
#include <dnnl_graph_types.h> struct dnnl_graph_logical_tensor_t { // fields size_t id; int ndims; dnnl_dims_t dims; dnnl_data_type_t data_type; dnnl_graph_tensor_property_t property; dnnl_graph_layout_type_t layout_type; dnnl_dims_t strides; size_t layout_id; union dnnl_graph_logical_tensor_t::@3 layout; };
Detailed Documentation¶
Logical tensor.
It is based on an ID, a number of dimensions, dimensions themselves, element data type, tensor property and tensor memory layout.
Fields¶
size_t id
Unique id of each logical tensor.
The library uses logical tensor IDs to build up the connections between operations if the output of one operation has the same ID as the input of another operation.
int ndims
Number of dimensions.
-1 means unknown (DNNL_GRAPH_UNKNOWN_NDIMS). 0 is used to define scalar tensor.
dnnl_dims_t dims
Size of each dimension.
DNNL_GRAPH_UNKNOWN_DIM means the size of that dimension is unknown. 0 is used to define zero-dimension tensor. The library supports to deduce output shapes according to input shapes during compilation. Unlike memory descriptor in oneDNN primitive API, the order of dimensions is not defined in logical tensor. It is defined by the operations which respect the order through the attributes dnnl_graph_op_attr_data_format or dnnl_graph_op_attr_weights_format. For example, for a Convolution with data_format=NXC
, it means the first element of dims of activation tensor is mini-batch size, the last effective element of dims is channel size, and other elements between them are spatial dimensions.
dnnl_data_type_t data_type
Data type of the tensor elements.
dnnl_graph_tensor_property_t property
Property type of the tensor.
dnnl_graph_layout_type_t layout_type
Layout type of the tensor.
dnnl_dims_t strides
The field is valid when layout_type
is dnnl_graph_layout_type_strided.
DNNL_GRAPH_UNKNOWN_DIM means the stride of the dimension is unknown. The library currently doesn’t support other negative stride values.
size_t layout_id
The field is valid when layout_type
is dnnl_graph_layout_type_opaque.
An opaque layout ID is usually generated by a partition which is compiled with layout type any.