[OV2.0] Calculate model layout based on 'tensor' layout and convert steps (#9550)

* Calculate model layout based on 'tensor' layout and convert steps

Previously, 'model layout' is set to '...' by default,
thus no shape conversion happened when tensor layout is set to 'NHWC', then there was explicit convert_layout "NCHW"

Now "model layout" is calculated based on tensor layout and conversion steps:
Examples:
 1) Tensor: NHWC, Convert: NCHW. Result: NCHW
 2) Tensor: NHWC, Convert: 0312. Result: NCHW

* Fix for set_shape + resize case
This commit is contained in:
Mikhail Nosov authored and GitHub committed 2022-01-12 10:52:02 +03:00
1 parent c1d7535044
commit 26a78fcb5d
5 files changed
+125 -15

No files matched your search

@@ -858,6 +858,28 @@ static RefPreprocessParams set_shape_custom_crop() {
return res;
}
static RefPreprocessParams set_shape_with_resize() {
RefPreprocessParams res("set_shape_with_resize");
res.function = []() {
auto f = create_simple_function(element::f32, PartialShape{1, 3, 1, 1});
auto p = PrePostProcessor(f);
p.input().tensor().set_shape({1, 2, 2, 3}).set_layout("NHWC");
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
p.input().model().set_layout("NCHW");
p.build();
return f;
};
auto input_size = 1 * 2 * 2 * 3;
std::vector<float> input_values(input_size);
std::iota(input_values.begin(), input_values.end(), 0);
res.inputs.emplace_back(element::f32, Shape{1, 2, 2, 3}, std::vector<float> {1, 2, 3,
1, 2, 3,
1, 2, 3,
1, 2, 3});
res.expected.emplace_back(Shape{1, 3, 1, 1}, element::f32, std::vector<float>{ 1, 2, 3});
return res;
}
static RefPreprocessParams postprocess_2_inputs_basic() {
RefPreprocessParams res("postprocess_2_inputs_basic");
res.function = []() {
@@ -1133,6 +1155,7 @@ std::vector<RefPreprocessParams> allPreprocessTests() {
convert_color_i420_to_bgr_three_planes(),
convert_color_i420_single_plane(),
set_shape_custom_crop(),
set_shape_with_resize(),
postprocess_2_inputs_basic(),
post_convert_layout_by_dims(),
post_convert_layout_by_dims_multi(),