Visible to Intel only — GUID: GUID-4B560A00-9511-47EA-9888-8A96B7F468EB
Visible to Intel only — GUID: GUID-4B560A00-9511-47EA-9888-8A96B7F468EB
class dnnl::graph::logical_tensor
Overview
Logical tensor object. More…
#include <dnnl_graph.hpp>
class logical_tensor
{
public:
// typedefs
typedef dnnl_dim_t dim;
typedef std::vector<dim> dims;
// enums
enum data_type;
enum layout_type;
enum property_type;
// construction
logical_tensor();
logical_tensor(const dnnl_graph_logical_tensor_t& c_data);
logical_tensor(const logical_tensor& other);
logical_tensor(
size_t tid,
data_type dtype,
int32_t ndims,
layout_type ltype,
property_type ptype = property_type::undef
);
logical_tensor(
size_t tid,
data_type dtype,
layout_type ltype = layout_type::undef
);
logical_tensor(
size_t tid,
data_type dtype,
const dims& adims,
layout_type ltype,
property_type ptype = property_type::undef
);
logical_tensor(
size_t tid,
data_type dtype,
const dims& adims,
const dims& strides,
property_type ptype = property_type::undef
);
logical_tensor(
size_t tid,
data_type dtype,
const dims& adims,
size_t lid,
property_type ptype = property_type::undef
);
// methods
logical_tensor& operator = (const logical_tensor& other);
dims get_dims() const;
size_t get_id() const;
data_type get_data_type() const;
property_type get_property_type() const;
layout_type get_layout_type() const;
size_t get_layout_id() const;
dims get_strides() const;
size_t get_mem_size() const;
bool is_equal(const logical_tensor& lt) const;
};
Detailed Documentation
Logical tensor object.
Typedefs
typedef dnnl_dim_t dim
Integer type for representing dimension sizes and indices.
typedef std::vector<dim> dims
Vector of dimensions.
Implementations are free to force a limit on the vector’s length.
Construction
logical_tensor()
default constructor construct an empty object
logical_tensor(const dnnl_graph_logical_tensor_t& c_data)
Constructs a logical tensor object.
logical_tensor(const logical_tensor& other)
Copy.
logical_tensor(
size_t tid,
data_type dtype,
int32_t ndims,
layout_type ltype,
property_type ptype = property_type::undef
)
Constructs a logical tensor object with ID, data type, ndims, layout type, and property type.
Parameters:
tid |
Logical tensor ID. |
dtype |
Elements data type. |
ndims |
Number of dimensions. -1 means unknown (see DNNL_GRAPH_UNKNOWN_NDIMS) and 0 means a scalar tensor. |
ltype |
Layout type. |
ptype |
Property type. |
logical_tensor(
size_t tid,
data_type dtype,
layout_type ltype = layout_type::undef
)
Delegated constructor.
Parameters:
tid |
Logical tensor ID. |
dtype |
Elements data type. |
ltype |
Layout type. |
logical_tensor(
size_t tid,
data_type dtype,
const dims& adims,
layout_type ltype,
property_type ptype = property_type::undef
)
Constructs a logical tensor object with basic information and detailed dims.
Parameters:
tid |
Logical tensor ID. |
dtype |
Elements data type. |
adims |
Logical tensor dimensions. DNNL_GRAPH_UNKNOWN_DIM means the size of that dimension is unknown. 0 is used to define zero-dimension tensor. |
ltype |
Layout type. If it’s strided, the strides field in the output logical tensor will be deduced accordingly. |
ptype |
Property type. |
logical_tensor(
size_t tid,
data_type dtype,
const dims& adims,
const dims& strides,
property_type ptype = property_type::undef
)
Constructs a logical tensor object with detailed dims and strides.
The layout_type of the output logical tensor object will always be strided.
Parameters:
tid |
Logical tensor ID. |
dtype |
Elements data type. |
adims |
Logical tensor dimensions. DNNL_GRAPH_UNKNOWN_DIM means the size of that dimension is unknown. 0 is used to define zero-dimension tensor. |
strides |
Logical tensor strides. DNNL_GRAPH_UNKNOWN_DIM means the stride of the dimension is unknown. The library currently doesn’t support other negative stride values. |
ptype |
Property type. |
logical_tensor(
size_t tid,
data_type dtype,
const dims& adims,
size_t lid,
property_type ptype = property_type::undef
)
Constructs a logical tensor object with detailed dims and an opaque layout ID.
layout_type of the output logical tensor object will always be opaque.
Parameters:
tid |
Logical tensor ID. |
dtype |
Elements data type. |
adims |
Logical tensor dimensions. DNNL_GRAPH_UNKNOWN_DIM means the size of that dimension is unknown. 0 is used to define zero-dimension tensor. |
lid |
Opaque layout id. |
ptype |
Property type |
Methods
logical_tensor& operator = (const logical_tensor& other)
Assign.
dims get_dims() const
Returns dimensions of a logical tensor.
Returns:
A vector describing the size of each dimension.
size_t get_id() const
Returns the unique id of a logical tensor.
Returns:
An integer value describing the ID.
data_type get_data_type() const
Returns the data type of a logical tensor.
Returns:
The data type.
property_type get_property_type() const
Returns the property type of a logical tensor.
Returns:
The property type.
layout_type get_layout_type() const
Returns the layout type of a logical tensor.
Returns:
The layout type.
size_t get_layout_id() const
Returns the layout ID of a logical tensor.
The API should be called on a logical tensor with opaque layout type. Otherwise, an exception will be raised.
Returns:
Layout ID.
dims get_strides() const
Returns the strides of a logical tensor.
The API should be called on a logical tensor with strided layout type. Otherwise, an exception will be raised.
Returns:
A vector describing the stride size of each dimension.
size_t get_mem_size() const
Returns memory size in bytes required by this logical tensor.
Returns:
The memory size in bytes.
bool is_equal(const logical_tensor& lt) const
Compares if two logical tenors are equal.
Users can decide accordingly if layout reordering is needed for two logical tensors. The method will return true for below two circumstances:
the two logical tensors are equal regarding each field in the struct, eg. id, ndims, dims, layout type, property, etc.
If all other fields are equal but the layout types in two logical tensors are different, the method will return true when the underlying memory layout is the same. For example, one logical tensor has strided layout type while the other one has opaque layout type, but underneath, both layouts are NHWC, the method will still return true for this case.
Parameters:
lt |
The input logical tensor to be compared. |
Returns:
true if the two logical tensors are equal. false otherwise