[OV2.0] Preprocessing api cleanup (#8898)
* Removed 'inline' Preprocessing API Even though this API provided a way to specify all pre/post-processing in one line - it was considered inconvinient With 'getters' API preprocessing code looks more clear for user, so old' inline' API is removed * Fix pyopenvino build issues * Update after merged PR#8717
This commit is contained in:
@@ -21,12 +21,12 @@ namespace {
|
||||
|
||||
struct RefPreprocessParams {
|
||||
RefPreprocessParams(const std::string& val): name(val) {}
|
||||
std::function<std::shared_ptr<ov::Function>()> function;
|
||||
std::vector<Tensor> inputs;
|
||||
std::vector<Tensor> expected;
|
||||
float abs_threshold = 0.01f;
|
||||
float rel_threshold = 0.01f;
|
||||
std::string name;
|
||||
std::function<std::shared_ptr<ov::Function>()> function;
|
||||
std::vector<Tensor> inputs;
|
||||
std::vector<Tensor> expected;
|
||||
float abs_threshold = 0.01f;
|
||||
float rel_threshold = 0.01f;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class ReferencePreprocessTest : public testing::TestWithParam<RefPreprocessParams>, public CommonReferenceTest {
|
||||
@@ -95,7 +95,8 @@ static RefPreprocessParams simple_mean_scale() {
|
||||
RefPreprocessParams res("simple_mean_scale");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, Shape{1, 3, 2, 2});
|
||||
f = PrePostProcessor(f).input(InputInfo().preprocess(PreProcessSteps().mean(1.f).scale(2.f))).build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().preprocess().mean(1.f).scale(2.f); p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 3, 2, 2}, element::f32, std::vector<float>{1., 3., 5., 7., 9., 11., 13., 15., 17., 19., 21., 23.});
|
||||
@@ -107,7 +108,8 @@ static RefPreprocessParams scale_then_mean() {
|
||||
RefPreprocessParams res("scale_then_mean");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, Shape{1, 3, 2, 2});
|
||||
f = PrePostProcessor(f).input(InputInfo().preprocess(PreProcessSteps().scale(2.0f).mean(2.0f))).build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().preprocess().scale(2.0f).mean(2.0f); p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -120,14 +122,15 @@ static RefPreprocessParams convert_only() {
|
||||
RefPreprocessParams res("convert_only");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, Shape{1, 1, 2, 2});
|
||||
f = PrePostProcessor(f).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_element_type(element::i16))
|
||||
.preprocess(PreProcessSteps()
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_element_type(element::i16);
|
||||
p.input().preprocess()
|
||||
.convert_element_type(element::f32)
|
||||
.scale(3.f)
|
||||
.convert_element_type(element::u8)
|
||||
.convert_element_type(element::f32)))
|
||||
.build();
|
||||
.convert_element_type(element::f32);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 1, 2, 2}, element::i16, std::vector<int16_t>{2, 3, 4, 5});
|
||||
@@ -139,14 +142,14 @@ static RefPreprocessParams convert_element_type_and_scale() {
|
||||
RefPreprocessParams res("convert_element_type_and_scale");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, Shape{1, 3, 2, 2});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_element_type(element::i16))
|
||||
.preprocess(PreProcessSteps()
|
||||
.convert_element_type(element::f32)
|
||||
.scale(2.f)
|
||||
.convert_element_type(element::u8)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_element_type(element::i16);
|
||||
p.input().preprocess()
|
||||
.convert_element_type(element::f32)
|
||||
.scale(2.f)
|
||||
.convert_element_type(element::u8);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -161,11 +164,11 @@ static RefPreprocessParams tensor_element_type_and_scale() {
|
||||
RefPreprocessParams res("tensor_element_type_and_scale");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::i8, Shape{1, 3, 1, 1});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_element_type(element::f32))
|
||||
.preprocess(PreProcessSteps().scale(2.0f).convert_element_type(element::i8)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_element_type(element::f32);
|
||||
p.input().preprocess().scale(2.0f).convert_element_type(element::i8);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -178,13 +181,13 @@ static RefPreprocessParams custom_preprocessing() {
|
||||
RefPreprocessParams res("custom_preprocessing");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::i32, Shape{1, 3, 1, 1});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo().preprocess(PreProcessSteps().custom([](const Output<Node>& node) {
|
||||
auto abs = std::make_shared<op::v0::Abs>(node);
|
||||
abs->set_friendly_name(node.get_node_shared_ptr()->get_friendly_name() + "/abs");
|
||||
return abs;
|
||||
})))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().preprocess().custom([](const Output<Node>& node) {
|
||||
auto abs = std::make_shared<op::v0::Abs>(node);
|
||||
abs->set_friendly_name(node.get_node_shared_ptr()->get_friendly_name() + "/abs");
|
||||
return abs;
|
||||
});
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -193,42 +196,24 @@ static RefPreprocessParams custom_preprocessing() {
|
||||
return res;
|
||||
}
|
||||
|
||||
static RefPreprocessParams test_lvalue() {
|
||||
RefPreprocessParams res("test_lvalue");
|
||||
static RefPreprocessParams test_multiple() {
|
||||
RefPreprocessParams res("test_multiple");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::i8, Shape{1, 3, 1, 1});
|
||||
auto p = PrePostProcessor(f);
|
||||
auto p1 = std::move(p);
|
||||
p = std::move(p1);
|
||||
auto inputInfo = InputInfo();
|
||||
auto inputInfo2 = std::move(inputInfo);
|
||||
inputInfo = std::move(inputInfo2);
|
||||
{
|
||||
auto inputTensorInfo = InputTensorInfo();
|
||||
auto inputTensorInfo2 = std::move(inputTensorInfo);
|
||||
inputTensorInfo = std::move(inputTensorInfo2);
|
||||
auto &same = inputTensorInfo.set_element_type(element::f32);
|
||||
same.set_layout("?CHW");
|
||||
inputInfo.tensor(std::move(same));
|
||||
}
|
||||
{
|
||||
auto preprocessSteps = PreProcessSteps();
|
||||
auto preprocessSteps2 = std::move(preprocessSteps);
|
||||
preprocessSteps = std::move(preprocessSteps2);
|
||||
preprocessSteps.mean(1.f);
|
||||
preprocessSteps.scale(2.f);
|
||||
preprocessSteps.mean({1.f, 2.f, 3.f});
|
||||
preprocessSteps.scale({2.f, 3.f, 4.f});
|
||||
preprocessSteps.custom([](const Output<Node> &node) {
|
||||
auto abs = std::make_shared<op::v0::Abs>(node);
|
||||
abs->set_friendly_name(node.get_node_shared_ptr()->get_friendly_name() + "/abs");
|
||||
return abs;
|
||||
});
|
||||
auto &same = preprocessSteps.convert_element_type(element::i8);
|
||||
inputInfo.preprocess(std::move(same));
|
||||
}
|
||||
p.input(std::move(inputInfo));
|
||||
f = p.build();
|
||||
p1.input().tensor().set_element_type(element::f32).set_layout("?CHW");
|
||||
p1.input().preprocess().mean(1.f);
|
||||
p1.input().preprocess().scale(2.f);
|
||||
p1.input().preprocess().mean({1.f, 2.f, 3.f});
|
||||
p1.input().preprocess().scale({2.f, 3.f, 4.f});
|
||||
p1.input().preprocess().custom([](const Output<Node> &node) {
|
||||
auto abs = std::make_shared<op::v0::Abs>(node);
|
||||
abs->set_friendly_name(node.get_node_shared_ptr()->get_friendly_name() + "/abs");
|
||||
return abs;
|
||||
});
|
||||
p1.input().preprocess().convert_element_type(element::i8);
|
||||
f = p1.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -241,16 +226,12 @@ static RefPreprocessParams test_2_inputs_basic() {
|
||||
RefPreprocessParams res("test_2_inputs_basic");
|
||||
res.function = []() {
|
||||
auto f = create_n_inputs<2>(element::f32, Shape{1, 3, 1, 1});
|
||||
f = PrePostProcessor(f).input(InputInfo(0)
|
||||
.preprocess(
|
||||
PreProcessSteps()
|
||||
.mean(1.f)))
|
||||
.input(
|
||||
InputInfo("tensor_input2")
|
||||
.preprocess(PreProcessSteps()
|
||||
.mean(1.f)
|
||||
.scale(2.0f)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input(0).preprocess().mean(1.f);
|
||||
p.input("tensor_input2").preprocess()
|
||||
.mean(1.f)
|
||||
.scale(2.0f);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -265,11 +246,11 @@ static RefPreprocessParams mean_scale_vector_tensor_layout() {
|
||||
RefPreprocessParams res("mean_scale_vector_tensor_layout");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 3, 2, 1});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("NC??"))
|
||||
.preprocess(PreProcessSteps().mean({1.f, 2.f, 3.f}).scale({2.f, 3.f, 4.f})))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_layout("NC??");
|
||||
p.input().preprocess().mean({1.f, 2.f, 3.f}).scale({2.f, 3.f, 4.f});
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -282,11 +263,11 @@ static RefPreprocessParams mean_scale_dynamic_layout() {
|
||||
RefPreprocessParams res("mean_scale_dynamic_layout");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 2, 1, 3});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("N...C"))
|
||||
.preprocess(PreProcessSteps().mean({1.f, 2.f, 3.f}).scale({2.f, 3.f, 4.f})))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_layout("N...C");
|
||||
p.input().preprocess().mean({1.f, 2.f, 3.f}).scale({2.f, 3.f, 4.f});
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -299,13 +280,12 @@ static RefPreprocessParams resize_to_network_height() {
|
||||
RefPreprocessParams res("resize_to_network_height");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 2, 1, 1});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_dynamic_shape())
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_LINEAR))
|
||||
.network(InputNetworkInfo().set_layout("NHWC"))
|
||||
)
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_spatial_dynamic_shape();
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||
p.input().network().set_layout("NHWC");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(element::f32, Shape{1, 4, 1, 1}, std::vector<float>{0., 2., 4., 6.});
|
||||
@@ -317,12 +297,12 @@ static RefPreprocessParams resize_to_network_width() {
|
||||
RefPreprocessParams res("resize_to_network_width");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{Dimension::dynamic(), 1, 2, 2});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_dynamic_shape())
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_LINEAR))
|
||||
.network(InputNetworkInfo().set_layout("NCHW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_spatial_dynamic_shape();
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||
p.input().network().set_layout("NCHW");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(element::f32, Shape{1, 1, 2, 6}, std::vector<float>{0., 1., 2., 3., 4., 5.,
|
||||
@@ -335,14 +315,12 @@ static RefPreprocessParams resize_from_spatial_dims() {
|
||||
RefPreprocessParams res("resize_from_spatial_dims");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{Dimension::dynamic(), 1, 1, 1});
|
||||
auto t = InputTensorInfo();
|
||||
t.set_spatial_static_shape(1, 4);
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(std::move(t))
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_CUBIC))
|
||||
.network(InputNetworkInfo().set_layout("NCHW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_spatial_static_shape(1, 4);
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_CUBIC);
|
||||
p.input().network().set_layout("NCHW");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(element::f32, Shape{1, 1, 1, 7}, std::vector<float>{0., 0.25, 1., 2.25, 4., 6.25, 9});
|
||||
@@ -354,13 +332,13 @@ static RefPreprocessParams resize_i8() {
|
||||
RefPreprocessParams res("resize_i8");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::i8, PartialShape{1, 3, 1, 1});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo()
|
||||
.set_spatial_dynamic_shape())
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_LINEAR))
|
||||
.network(InputNetworkInfo().set_layout("NCHW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor()
|
||||
.set_spatial_dynamic_shape();
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||
p.input().network().set_layout("NCHW");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(element::i8, Shape{1, 3, 2, 2}, std::vector<int8_t>{0, 0, 0, 0,
|
||||
@@ -374,12 +352,12 @@ static RefPreprocessParams resize_to_network_width_height() {
|
||||
RefPreprocessParams res("resize_to_network_width_height");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 1, 4, 4});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_static_shape(5, 5))
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_NEAREST))
|
||||
.network(InputNetworkInfo().set_layout("...HW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_spatial_static_shape(5, 5);
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_NEAREST);
|
||||
p.input().network().set_layout("...HW");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -404,12 +382,12 @@ static RefPreprocessParams resize_to_specified_width_height() {
|
||||
RefPreprocessParams res("resize_to_specified_width_height");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 1, Dimension::dynamic(), Dimension::dynamic()});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_dynamic_shape())
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_NEAREST, 4, 4))
|
||||
.network(InputNetworkInfo().set_layout("...HW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor().set_spatial_dynamic_shape();
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_NEAREST, 4, 4);
|
||||
p.input().network().set_layout("...HW");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -430,52 +408,16 @@ static RefPreprocessParams resize_to_specified_width_height() {
|
||||
return res;
|
||||
}
|
||||
|
||||
static RefPreprocessParams resize_lvalues() {
|
||||
RefPreprocessParams res("resize_lvalues");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{Dimension::dynamic(), 1, 1, 2});
|
||||
f->get_parameters().front()->set_layout("NCHW");
|
||||
auto t = InputTensorInfo();
|
||||
t.set_spatial_dynamic_shape();
|
||||
auto s = PreProcessSteps();
|
||||
s.resize(ResizeAlgorithm::RESIZE_LINEAR, 1, 6); // to specified shape
|
||||
s.resize(ResizeAlgorithm::RESIZE_LINEAR); // to network's shape
|
||||
auto n = InputNetworkInfo();
|
||||
n.set_layout("NCHW");
|
||||
auto i = InputInfo();
|
||||
i.tensor(std::move(t));
|
||||
i.preprocess(std::move(s));
|
||||
i.network(std::move(n));
|
||||
f = PrePostProcessor(f)
|
||||
.input(std::move(i))
|
||||
.build();
|
||||
return f;
|
||||
};
|
||||
// clang-format off
|
||||
res.inputs.emplace_back(element::f32, Shape{1, 1, 1, 18}, std::vector<float>{0., 0., 0.,
|
||||
1., 1., 1.,
|
||||
2., 2., 2.,
|
||||
3., 3., 3.,
|
||||
4., 4., 4.,
|
||||
5., 5., 5.});
|
||||
// clang-format on
|
||||
res.expected.emplace_back(Shape{1, 1, 2, 1}, element::f32, std::vector<float>{1., 4.});
|
||||
return res;
|
||||
}
|
||||
|
||||
static RefPreprocessParams convert_layout_nhwc_to_nchw_lvalue() {
|
||||
RefPreprocessParams res("convert_layout_nhwc_to_nchw_lvalue");
|
||||
static RefPreprocessParams convert_layout_nhwc_to_nchw() {
|
||||
RefPreprocessParams res("convert_layout_nhwc_to_nchw");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, {1, 3, 2, 2});
|
||||
f->get_parameters()[0]->set_layout("NCHW");
|
||||
auto p = PreProcessSteps();
|
||||
p.convert_layout("NCHW");
|
||||
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("NHWC"))
|
||||
.preprocess(std::move(p)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_layout("NHWC");
|
||||
p.input().preprocess().convert_layout("NCHW");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 2, 2, 3}, element::u8, std::vector<uint8_t>{1, 2, 3, // [H=0, W=0, RGB]
|
||||
@@ -493,13 +435,10 @@ static RefPreprocessParams convert_layout_nhwc_to_net_no_tensor_shape() {
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, {1, 3, 2, 2});
|
||||
f->get_parameters()[0]->set_layout("NCHW");
|
||||
auto p = PreProcessSteps();
|
||||
p.convert_layout();
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("NHWC"))
|
||||
.preprocess(std::move(p)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_layout("NHWC");
|
||||
p.input().preprocess().convert_layout();
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 2, 2, 3}, element::u8, std::vector<uint8_t>{1, 2, 3, // [H=0, W=0, RGB]
|
||||
@@ -516,10 +455,9 @@ static RefPreprocessParams convert_layout_by_dims() {
|
||||
RefPreprocessParams res("convert_layout_by_dims");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, {1, 3, 2, 2});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.preprocess(PreProcessSteps().convert_layout({0, 3, 1, 2})))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().preprocess().convert_layout({0, 3, 1, 2});
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 2, 2, 3}, element::u8, std::vector<uint8_t>{1, 2, 3, // [H=0, W=0, RGB]
|
||||
@@ -536,12 +474,10 @@ static RefPreprocessParams convert_layout_by_dims_multi() {
|
||||
RefPreprocessParams res("convert_layout_by_dims_multi");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, {1, 3, 2, 2});
|
||||
auto p = PreProcessSteps();
|
||||
p.convert_layout({0, 1, 3, 2}); // NHWC->NHCW
|
||||
p.convert_layout({0, 2, 1, 3}); // NHCW->NCHW
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo().preprocess(std::move(p)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().preprocess().convert_layout({0, 1, 3, 2}) // NHWC->NHCW
|
||||
.convert_layout({0, 2, 1, 3}); // NHCW->NCHW
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 2, 2, 3}, element::f32, std::vector<float>{1, 2, 3, // [H=0, W=0]
|
||||
@@ -558,14 +494,12 @@ static RefPreprocessParams convert_layout_by_dims_multi_layout() {
|
||||
RefPreprocessParams res("convert_layout_by_dims_multi_layout");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, {1, 3, 2, 2});
|
||||
auto p = PreProcessSteps();
|
||||
p.convert_layout({0, 1, 3, 2}); // NHWC->NHCW
|
||||
p.mean({1, 2, 2}); // Apply means to 'C' channel
|
||||
p.convert_layout({0, 2, 1, 3}); // NHCW->NCHW
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo().tensor(InputTensorInfo().set_layout("N??C"))
|
||||
.preprocess(std::move(p)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_layout("N??C");
|
||||
p.input().preprocess().convert_layout({0, 1, 3, 2}) // NHWC->NHCW
|
||||
.mean({1, 2, 2}) // Apply means to 'C' channel
|
||||
.convert_layout({0, 2, 1, 3}); // NHCW->NCHW
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 2, 2, 3}, element::f32, std::vector<float>{1, 2, 3, // [H=0, W=0, RGB]
|
||||
@@ -582,16 +516,16 @@ static RefPreprocessParams resize_and_convert_layout() {
|
||||
RefPreprocessParams res("resize_and_convert_layout");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 2, 2, 2});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo()
|
||||
.set_layout("NCHW")
|
||||
.set_spatial_dynamic_shape())
|
||||
.preprocess(PreProcessSteps()
|
||||
.resize(ResizeAlgorithm::RESIZE_LINEAR)
|
||||
.convert_layout())
|
||||
.network(InputNetworkInfo().set_layout("NHWC")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor()
|
||||
.set_layout("NCHW")
|
||||
.set_spatial_dynamic_shape();
|
||||
p.input().preprocess()
|
||||
.resize(ResizeAlgorithm::RESIZE_LINEAR)
|
||||
.convert_layout();
|
||||
p.input().network().set_layout("NHWC");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -620,13 +554,13 @@ static RefPreprocessParams convert_color_nv12_to_bgr_two_planes() {
|
||||
res.rel_threshold = 1.f; // Ignore relative pixel values comparison (100%)
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, PartialShape{1, 4, 4, 3});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo()
|
||||
.set_color_format(ColorFormat::NV12_TWO_PLANES))
|
||||
.preprocess(PreProcessSteps()
|
||||
.convert_color(ColorFormat::BGR)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor()
|
||||
.set_color_format(ColorFormat::NV12_TWO_PLANES);
|
||||
p.input().preprocess()
|
||||
.convert_color(ColorFormat::BGR);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -659,13 +593,13 @@ static RefPreprocessParams convert_color_nv12_single_plane() {
|
||||
res.rel_threshold = 1.f; // Ignore relative pixel values comparison (100%)
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 4, 4, 3});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo()
|
||||
.set_color_format(ColorFormat::NV12_SINGLE_PLANE))
|
||||
.preprocess(PreProcessSteps()
|
||||
.convert_color(ColorFormat::RGB)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor()
|
||||
.set_color_format(ColorFormat::NV12_SINGLE_PLANE);
|
||||
p.input().preprocess()
|
||||
.convert_color(ColorFormat::RGB);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -680,7 +614,7 @@ static RefPreprocessParams convert_color_nv12_single_plane() {
|
||||
255, 0, 0, 255, 0, 0, 0, 255, 0, 0, 255, 0, // RRGG
|
||||
0, 0, 255, 0, 0, 255, 255, 0, 0, 255, 0, 0, // BBRR
|
||||
0, 0, 255, 0, 0, 255, 255, 0, 0, 255, 0, 0, // BBRR
|
||||
};
|
||||
};
|
||||
auto out_shape = Shape{1, 4, 4, 3};
|
||||
// clang-format on
|
||||
res.inputs.emplace_back(element::f32, input_shape, input);
|
||||
@@ -694,19 +628,19 @@ static RefPreprocessParams convert_color_nv12_layout_resize() {
|
||||
res.rel_threshold = 1.f; // Ignore relative pixel values comparison (100%)
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 3, 2, 2});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo()
|
||||
.set_color_format(ColorFormat::NV12_SINGLE_PLANE)
|
||||
.set_element_type(element::u8)
|
||||
.set_spatial_dynamic_shape())
|
||||
.preprocess(PreProcessSteps()
|
||||
.convert_color(ColorFormat::RGB)
|
||||
.convert_layout()
|
||||
.convert_element_type(element::f32)
|
||||
.resize(ResizeAlgorithm::RESIZE_NEAREST))
|
||||
.network(InputNetworkInfo().set_layout("NCHW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor()
|
||||
.set_color_format(ColorFormat::NV12_SINGLE_PLANE)
|
||||
.set_element_type(element::u8)
|
||||
.set_spatial_dynamic_shape();
|
||||
p.input().preprocess()
|
||||
.convert_color(ColorFormat::RGB)
|
||||
.convert_layout()
|
||||
.convert_element_type(element::f32)
|
||||
.resize(ResizeAlgorithm::RESIZE_NEAREST);
|
||||
p.input().network().set_layout("NCHW");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -734,16 +668,16 @@ static RefPreprocessParams element_type_before_convert_color_nv12() {
|
||||
res.rel_threshold = 1.f; // Ignore relative pixel values comparison (100%)
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 2, 2, 3});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo()
|
||||
.tensor(InputTensorInfo()
|
||||
.set_element_type(element::u8)
|
||||
.set_color_format(ColorFormat::NV12_TWO_PLANES))
|
||||
.preprocess(PreProcessSteps()
|
||||
.convert_element_type(element::f32)
|
||||
.convert_color(ColorFormat::RGB))
|
||||
.network(InputNetworkInfo().set_layout("NHWC")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input()
|
||||
.tensor()
|
||||
.set_element_type(element::u8)
|
||||
.set_color_format(ColorFormat::NV12_TWO_PLANES);
|
||||
p.input().preprocess()
|
||||
.convert_element_type(element::f32)
|
||||
.convert_color(ColorFormat::RGB);
|
||||
p.input().network().set_layout("NHWC");
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -836,15 +770,15 @@ static RefPreprocessParams postprocess_2_inputs_basic() {
|
||||
RefPreprocessParams res("postprocess_2_inputs_basic");
|
||||
res.function = []() {
|
||||
auto f = create_n_inputs<2>(element::f32, Shape{1, 3, 1, 2});
|
||||
f = PrePostProcessor(f)
|
||||
.output(OutputInfo("tensor_output1")
|
||||
.network(OutputNetworkInfo().set_layout("NCHW"))
|
||||
.postprocess(PostProcessSteps().convert_layout())
|
||||
.tensor(OutputTensorInfo().set_layout("NHWC")))
|
||||
.output(OutputInfo("tensor_output2")
|
||||
.postprocess(PostProcessSteps().convert_element_type())
|
||||
.tensor(OutputTensorInfo().set_element_type(element::u8)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.output("tensor_output1")
|
||||
.network().set_layout("NCHW");
|
||||
p.output("tensor_output1").postprocess().convert_layout();
|
||||
p.output("tensor_output1").tensor().set_layout("NHWC");
|
||||
p.output("tensor_output2")
|
||||
.postprocess().convert_element_type();
|
||||
p.output("tensor_output2").tensor().set_element_type(element::u8);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 3, 1, 2}, element::f32, std::vector<float>{1.1, 2.1, 3.1, 4.1, 5.1, 6.1});
|
||||
@@ -858,10 +792,10 @@ static RefPreprocessParams post_convert_layout_by_dims() {
|
||||
RefPreprocessParams res("post_convert_layout_by_dims");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, {1, 2, 2, 3});
|
||||
f = PrePostProcessor(f)
|
||||
.output(OutputInfo()
|
||||
.postprocess(PostProcessSteps().convert_layout({0, 3, 1, 2})))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.output()
|
||||
.postprocess().convert_layout({0, 3, 1, 2});
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 2, 2, 3}, element::u8, std::vector<uint8_t>{1, 2, 3, // [H=0, W=0, RGB]
|
||||
@@ -878,12 +812,10 @@ static RefPreprocessParams post_convert_layout_by_dims_multi() {
|
||||
RefPreprocessParams res("post_convert_layout_by_dims_multi");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, {1, 2, 2, 3});
|
||||
auto p = PostProcessSteps();
|
||||
p.convert_layout({0, 1, 3, 2}); // NHWC->NHCW
|
||||
p.convert_layout({0, 2, 1, 3}); // NHCW->NCHW
|
||||
f = PrePostProcessor(f)
|
||||
.output(OutputInfo().postprocess(std::move(p)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.output().postprocess().convert_layout({0, 1, 3, 2}); // NHWC->NHCW;
|
||||
p.output().postprocess().convert_layout({0, 2, 1, 3}); // NHCW->NCHW;
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 2, 2, 3}, element::f32, std::vector<float>{1, 2, 3, // [H=0, W=0]
|
||||
@@ -900,20 +832,19 @@ static RefPreprocessParams pre_and_post_processing() {
|
||||
RefPreprocessParams res("pre_and_post_processing");
|
||||
res.function = []() {
|
||||
auto f = create_n_inputs<2>(element::f32, Shape{1, 3, 1, 2});
|
||||
f = PrePostProcessor(f)
|
||||
.input(InputInfo(0)
|
||||
.tensor(InputTensorInfo().set_element_type(element::u8))
|
||||
.preprocess(PreProcessSteps().convert_element_type(element::f32).mean(1.f)))
|
||||
.input(InputInfo(1)
|
||||
.preprocess(PreProcessSteps().scale(2.f)))
|
||||
.output(OutputInfo("tensor_output1")
|
||||
.network(OutputNetworkInfo().set_layout("NCHW"))
|
||||
.postprocess(PostProcessSteps().convert_layout())
|
||||
.tensor(OutputTensorInfo().set_layout("NHWC")))
|
||||
.output(OutputInfo("tensor_output2")
|
||||
.postprocess(PostProcessSteps().convert_element_type())
|
||||
.tensor(OutputTensorInfo().set_element_type(element::u8)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input(0)
|
||||
.tensor().set_element_type(element::u8);
|
||||
p.input(0).preprocess().convert_element_type(element::f32).mean(1.f);
|
||||
p.input(1).preprocess().scale(2.f);
|
||||
p.output("tensor_output1")
|
||||
.network().set_layout("NCHW");
|
||||
p.output("tensor_output1").postprocess().convert_layout();
|
||||
p.output("tensor_output1").tensor().set_layout("NHWC");
|
||||
p.output("tensor_output2")
|
||||
.postprocess().convert_element_type();
|
||||
p.output("tensor_output2").tensor().set_element_type(element::u8);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
res.inputs.emplace_back(Shape{1, 3, 1, 2}, element::u8, std::vector<uint8_t>{1, 2, 3, 4, 5, 6});
|
||||
@@ -927,9 +858,10 @@ static RefPreprocessParams rgb_to_bgr() {
|
||||
RefPreprocessParams res("rgb_to_bgr");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, Shape{2, 1, 1, 3});
|
||||
f = PrePostProcessor(f).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_color_format(ColorFormat::RGB))
|
||||
.preprocess(PreProcessSteps().convert_color(ColorFormat::BGR))).build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_color_format(ColorFormat::RGB);
|
||||
p.input().preprocess().convert_color(ColorFormat::BGR);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -942,9 +874,10 @@ static RefPreprocessParams bgr_to_rgb() {
|
||||
RefPreprocessParams res("bgr_to_rgb");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, Shape{2, 1, 1, 3});
|
||||
f = PrePostProcessor(f).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_color_format(ColorFormat::BGR))
|
||||
.preprocess(PreProcessSteps().convert_color(ColorFormat::RGB))).build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_color_format(ColorFormat::BGR);
|
||||
p.input().preprocess().convert_color(ColorFormat::RGB);
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -957,9 +890,10 @@ static RefPreprocessParams reverse_channels_nchw() {
|
||||
RefPreprocessParams res("reverse_channels_nchw");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 2, 2, 2});
|
||||
f = PrePostProcessor(f).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("NCHW"))
|
||||
.preprocess(PreProcessSteps().reverse_channels())).build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_layout("NCHW");
|
||||
p.input().preprocess().reverse_channels();
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -1004,14 +938,13 @@ static RefPreprocessParams color_cut_last_channel() {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static RefPreprocessParams reverse_channels_dyn_layout() {
|
||||
RefPreprocessParams res("reverse_channels_dyn_layout");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::f32, PartialShape{1, 1, 3, 2});
|
||||
f = PrePostProcessor(f).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_color_format(ColorFormat::BGR).set_layout("...CN"))
|
||||
.preprocess(PreProcessSteps().convert_color(ColorFormat::RGB))).build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_color_format(ColorFormat::BGR).set_layout("...CN");
|
||||
p.input().preprocess().convert_color(ColorFormat::RGB); p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -1024,12 +957,13 @@ static RefPreprocessParams reverse_dyn_shape() {
|
||||
RefPreprocessParams res("reverse_dyn_shape");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, PartialShape{Dimension::dynamic(),
|
||||
Dimension::dynamic(),
|
||||
Dimension::dynamic(),
|
||||
Dimension::dynamic()});
|
||||
f = PrePostProcessor(f).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("NCHW"))
|
||||
.preprocess(PreProcessSteps().reverse_channels())).build();
|
||||
Dimension::dynamic(),
|
||||
Dimension::dynamic(),
|
||||
Dimension::dynamic()});
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_layout("NCHW");
|
||||
p.input().preprocess().reverse_channels();
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -1042,11 +976,10 @@ static RefPreprocessParams reverse_fully_dyn_shape() {
|
||||
RefPreprocessParams res("reverse_fully_dyn_shape");
|
||||
res.function = []() {
|
||||
auto f = create_simple_function(element::u8, PartialShape::dynamic());
|
||||
auto p = PreProcessSteps();
|
||||
p.reverse_channels();
|
||||
f = PrePostProcessor(f).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("...C??"))
|
||||
.preprocess(std::move(p))).build();
|
||||
auto p = PrePostProcessor(f);
|
||||
p.input().tensor().set_layout("...C??");
|
||||
p.input().preprocess().reverse_channels();
|
||||
p.build();
|
||||
return f;
|
||||
};
|
||||
|
||||
@@ -1057,47 +990,46 @@ static RefPreprocessParams reverse_fully_dyn_shape() {
|
||||
|
||||
std::vector<RefPreprocessParams> allPreprocessTests() {
|
||||
return std::vector<RefPreprocessParams> {
|
||||
simple_mean_scale(),
|
||||
scale_then_mean(),
|
||||
convert_only(),
|
||||
convert_element_type_and_scale(),
|
||||
tensor_element_type_and_scale(),
|
||||
custom_preprocessing(),
|
||||
test_lvalue(),
|
||||
test_2_inputs_basic(),
|
||||
mean_scale_vector_tensor_layout(),
|
||||
mean_scale_dynamic_layout(),
|
||||
resize_to_network_height(),
|
||||
resize_to_network_width(),
|
||||
resize_from_spatial_dims(),
|
||||
resize_i8(),
|
||||
resize_to_network_width_height(),
|
||||
resize_to_specified_width_height(),
|
||||
resize_lvalues(),
|
||||
convert_layout_nhwc_to_nchw_lvalue(),
|
||||
convert_layout_nhwc_to_net_no_tensor_shape(),
|
||||
convert_layout_by_dims(),
|
||||
convert_layout_by_dims_multi(),
|
||||
convert_layout_by_dims_multi_layout(),
|
||||
resize_and_convert_layout(),
|
||||
convert_color_nv12_to_bgr_two_planes(),
|
||||
convert_color_nv12_single_plane(),
|
||||
convert_color_nv12_layout_resize(),
|
||||
element_type_before_convert_color_nv12(),
|
||||
convert_color_i420_to_bgr_three_planes(),
|
||||
convert_color_i420_single_plane(),
|
||||
postprocess_2_inputs_basic(),
|
||||
post_convert_layout_by_dims(),
|
||||
post_convert_layout_by_dims_multi(),
|
||||
pre_and_post_processing(),
|
||||
rgb_to_bgr(),
|
||||
bgr_to_rgb(),
|
||||
color_cut_last_channel(),
|
||||
reverse_channels_nchw(),
|
||||
reverse_channels_dyn_layout(),
|
||||
reverse_dyn_shape(),
|
||||
reverse_fully_dyn_shape()
|
||||
};
|
||||
simple_mean_scale(),
|
||||
scale_then_mean(),
|
||||
convert_only(),
|
||||
convert_element_type_and_scale(),
|
||||
tensor_element_type_and_scale(),
|
||||
custom_preprocessing(),
|
||||
test_multiple(),
|
||||
test_2_inputs_basic(),
|
||||
mean_scale_vector_tensor_layout(),
|
||||
mean_scale_dynamic_layout(),
|
||||
resize_to_network_height(),
|
||||
resize_to_network_width(),
|
||||
resize_from_spatial_dims(),
|
||||
resize_i8(),
|
||||
resize_to_network_width_height(),
|
||||
resize_to_specified_width_height(),
|
||||
convert_layout_nhwc_to_nchw(),
|
||||
convert_layout_nhwc_to_net_no_tensor_shape(),
|
||||
convert_layout_by_dims(),
|
||||
convert_layout_by_dims_multi(),
|
||||
convert_layout_by_dims_multi_layout(),
|
||||
resize_and_convert_layout(),
|
||||
convert_color_nv12_to_bgr_two_planes(),
|
||||
convert_color_nv12_single_plane(),
|
||||
convert_color_nv12_layout_resize(),
|
||||
element_type_before_convert_color_nv12(),
|
||||
convert_color_i420_to_bgr_three_planes(),
|
||||
convert_color_i420_single_plane(),
|
||||
postprocess_2_inputs_basic(),
|
||||
post_convert_layout_by_dims(),
|
||||
post_convert_layout_by_dims_multi(),
|
||||
pre_and_post_processing(),
|
||||
rgb_to_bgr(),
|
||||
bgr_to_rgb(),
|
||||
color_cut_last_channel(),
|
||||
reverse_channels_nchw(),
|
||||
reverse_channels_dyn_layout(),
|
||||
reverse_dyn_shape(),
|
||||
reverse_fully_dyn_shape()
|
||||
};
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferencePreprocessTest,
|
||||
|
||||
@@ -57,7 +57,9 @@ static std::shared_ptr<Function> create_simple_function_yuv(const PartialShape&
|
||||
|
||||
TEST_F(ReferencePreprocessLegacyTest, mean) {
|
||||
function = create_simple_function(element::f32, Shape{1, 3, 2, 2});
|
||||
function = PrePostProcessor(function).input(InputInfo().preprocess(PreProcessSteps().mean(1.f))).build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().preprocess().mean(1.f);
|
||||
p.build();
|
||||
|
||||
auto f2 = create_simple_function(element::f32, Shape{1, 3, 2, 2});
|
||||
legacy_network = InferenceEngine::CNNNetwork(f2);
|
||||
@@ -75,7 +77,9 @@ TEST_F(ReferencePreprocessLegacyTest, mean) {
|
||||
|
||||
TEST_F(ReferencePreprocessLegacyTest, mean_scale) {
|
||||
function = create_simple_function(element::f32, Shape{1, 3, 20, 20});
|
||||
function = PrePostProcessor(function).input(InputInfo().preprocess(PreProcessSteps().scale(2.f))).build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().preprocess().scale(2.f);
|
||||
p.build();
|
||||
|
||||
auto f2 = create_simple_function(element::f32, Shape{1, 3, 20, 20});
|
||||
legacy_network = InferenceEngine::CNNNetwork(f2);
|
||||
@@ -96,11 +100,11 @@ TEST_F(ReferencePreprocessLegacyTest, resize) {
|
||||
auto f2 = create_simple_function(element::f32, Shape{1, 3, 5, 5});
|
||||
legacy_network = InferenceEngine::CNNNetwork(f2);
|
||||
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_layout("NCHW").set_spatial_static_shape(42, 30))
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_LINEAR))
|
||||
.network(InputNetworkInfo().set_layout("NCHW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_layout("NCHW").set_spatial_static_shape(42, 30);
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||
p.input().network().set_layout("NCHW");
|
||||
p.build();
|
||||
|
||||
auto &preProcess = legacy_network.getInputsInfo().begin()->second->getPreProcess();
|
||||
preProcess.setResizeAlgorithm(InferenceEngine::ResizeAlgorithm::RESIZE_BILINEAR);
|
||||
@@ -177,12 +181,11 @@ public:
|
||||
inputData.clear();
|
||||
legacy_input_blobs.clear();
|
||||
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_color_format(
|
||||
ColorFormat::NV12_SINGLE_PLANE))
|
||||
.preprocess(PreProcessSteps().convert_color(ColorFormat::BGR))
|
||||
.network(InputNetworkInfo().set_layout("NCHW")))
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_color_format(ColorFormat::NV12_SINGLE_PLANE);
|
||||
p.input().preprocess().convert_color(ColorFormat::BGR);
|
||||
p.input().network().set_layout("NCHW");
|
||||
p.build();
|
||||
|
||||
const auto ¶m = function->get_parameters()[0];
|
||||
inputData.emplace_back(param->get_element_type(), param->get_shape(), ov20_input_yuv.data());
|
||||
|
||||
@@ -109,11 +109,10 @@ TEST_F(PreprocessOpenCVReferenceTest_YUV, convert_nv12_full_color_range) {
|
||||
|
||||
inputData.clear();
|
||||
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_color_format(
|
||||
ColorFormat::NV12_SINGLE_PLANE))
|
||||
.preprocess(PreProcessSteps().convert_color(ColorFormat::BGR)))
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_color_format(ColorFormat::NV12_SINGLE_PLANE);
|
||||
p.input().preprocess().convert_color(ColorFormat::BGR);
|
||||
function = p.build();
|
||||
|
||||
const auto ¶m = function->get_parameters()[0];
|
||||
inputData.emplace_back(param->get_element_type(), param->get_shape(), ov20_input_yuv.data());
|
||||
@@ -138,12 +137,10 @@ TEST_F(PreprocessOpenCVReferenceTest_YUV, convert_nv12_colored) {
|
||||
|
||||
inputData.clear();
|
||||
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_color_format(
|
||||
ColorFormat::NV12_SINGLE_PLANE))
|
||||
.preprocess(PreProcessSteps().convert_color(ColorFormat::BGR))
|
||||
)
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_color_format(ColorFormat::NV12_SINGLE_PLANE);
|
||||
p.input().preprocess().convert_color(ColorFormat::BGR);
|
||||
function = p.build();
|
||||
|
||||
const auto ¶m = function->get_parameters()[0];
|
||||
inputData.emplace_back(param->get_element_type(), param->get_shape(), input_yuv.data());
|
||||
@@ -165,12 +162,11 @@ TEST_F(PreprocessOpenCVReferenceTest, resize_u8_simple_linear) {
|
||||
|
||||
inputData.clear();
|
||||
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_static_shape(2, 2))
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_LINEAR))
|
||||
.network(InputNetworkInfo().set_layout("NCHW"))
|
||||
)
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_spatial_static_shape(2, 2);
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||
p.input().network().set_layout("NCHW");
|
||||
function = p.build();
|
||||
|
||||
const auto ¶m = function->get_parameters()[0];
|
||||
inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data());
|
||||
@@ -204,12 +200,11 @@ TEST_F(PreprocessOpenCVReferenceTest, resize_u8_large_picture_linear) {
|
||||
|
||||
inputData.clear();
|
||||
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_static_shape(input_height, input_width))
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_LINEAR))
|
||||
.network(InputNetworkInfo().set_layout("NCHW"))
|
||||
)
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_spatial_static_shape(input_height, input_width);
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||
p.input().network().set_layout("NCHW");
|
||||
function = p.build();
|
||||
|
||||
const auto ¶m = function->get_parameters()[0];
|
||||
inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data());
|
||||
@@ -242,12 +237,11 @@ TEST_F(PreprocessOpenCVReferenceTest, resize_f32_large_picture_linear) {
|
||||
|
||||
inputData.clear();
|
||||
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_static_shape(input_height, input_width))
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_LINEAR))
|
||||
.network(InputNetworkInfo().set_layout("NCHW"))
|
||||
)
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_spatial_static_shape(input_height, input_width);
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||
p.input().network().set_layout("NCHW");
|
||||
function = p.build();
|
||||
|
||||
const auto ¶m = function->get_parameters()[0];
|
||||
inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data());
|
||||
@@ -271,12 +265,11 @@ TEST_F(PreprocessOpenCVReferenceTest, DISABLED_resize_f32_large_picture_cubic_sm
|
||||
auto element_type = element::f32;
|
||||
auto input_img = std::vector<float> {1.f, 2.f, 3.f, 4.f, 4.f, 3.f, 2.f, 1.f, 1.f, 2.f, 3.f, 4.f, 4.f, 3.f, 2.f, 1.f};
|
||||
function = create_simple_function(element_type, func_shape);
|
||||
function = PrePostProcessor(function).input(InputInfo()
|
||||
.tensor(InputTensorInfo().set_spatial_static_shape(input_height, input_width))
|
||||
.preprocess(PreProcessSteps().resize(ResizeAlgorithm::RESIZE_CUBIC))
|
||||
.network(InputNetworkInfo().set_layout("NCHW"))
|
||||
)
|
||||
.build();
|
||||
auto p = PrePostProcessor(function);
|
||||
p.input().tensor().set_spatial_static_shape(input_height, input_width);
|
||||
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_CUBIC);
|
||||
p.input().network().set_layout("NCHW");
|
||||
function = p.build();
|
||||
|
||||
inputData.emplace_back(element_type, input_shape, input_img.data());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user