class ov::Layout¶
Overview¶
ov::Layout represents the text information of tensor’s dimensions/axes. E.g. layout NCHW means that 4D tensor {-1, 3, 480, 640} will have: More…
#include <layout.hpp>
class Layout
{
public:
// construction
Layout();
Layout(const char \* layoutStr);
Layout(const std::string& layoutStr);
// methods
bool operator == (const Layout& rhs) const;
bool operator != (const Layout& rhs) const;
bool has_name(const std::string& dimensionName) const;
std::int64_t get_index_by_name(const std::string& dimensionName) const;
std::string to_string() const;
bool empty() const;
static Layout scalar();
};Detailed Documentation¶
ov::Layout represents the text information of tensor’s dimensions/axes. E.g. layout NCHW means that 4D tensor {-1, 3, 480, 640} will have:
0:
N = -1: batch dimension is dynamic1:
C = 3: number of channels is ‘3’2:
H = 480: image height is 4803:
W = 640: image width is 640
Examples: ov::Layout can be specified for:
Preprocessing purposes. E.g.
To apply normalization (means/scales) it is usually required to set ‘C’ dimension in a layout.
To resize the image to specified width/height it is needed to set ‘H’ and ‘W’ dimensions in a layout
To transpose image - source and target layout can be set (see
ov::preprocess::PreProcessSteps::convert_layout)
To set/get model’s batch (see
ov::get_batch/ ov::set_batch) it is required in general to specify ‘N’ dimension in layout for appropriate inputs
Refer also to ov::layout namespace for various additional helper functions of ov::Layout
Construction¶
Layout()Constructs a dynamic Layout with no layout information.
Layout(const char \* layoutStr)Constructs a Layout with static or dynamic layout information based on string representation.
Parameters:
layoutStr |
The string used to construct Layout from. The string representation can be in the following form:
|
Methods¶
bool operator == (const Layout& rhs) constComparison operator (equal)
bool operator != (const Layout& rhs) constComparison operator (not equal)
bool has_name(const std::string& dimensionName) constChecks if dimension with specified name is in layout.
Returns:
true if layout has information about dimension index with a given name
std::int64_t get_index_by_name(const std::string& dimensionName) constGets index of dimension with a specified name.
Parameters:
if dimension name is not found in a layout |
Returns:
Index of given dimension name
std::string to_string() constString representation of Layout.
bool empty() constReturns ‘true’ if layout has no information, i.e. equals to Layout()
static Layout scalar()Constructs layout representing scalar.