Preprocessing - added test for dynamic spatial shapes (resize) (#8980)
* Preprocessing - added test for dynamic spatial shapes (resize) * Applied review comments * Remove unnecessary change * Revert signature to keep compatibility with kmb plugin * Try fix centos
This commit is contained in:
parent
980904c9ec
commit
757b757a20
@ -94,5 +94,7 @@ std::vector<std::string> disabledTestPatterns() {
|
|||||||
R"(smoke_PrePostProcess.*cvt_color_i420.*)",
|
R"(smoke_PrePostProcess.*cvt_color_i420.*)",
|
||||||
// Unsupported
|
// Unsupported
|
||||||
R"(smoke_Behavior/InferRequestSetBlobByType.setInputBlobsByType/BlobType=Batched_Device=GPU_Config=().*)",
|
R"(smoke_Behavior/InferRequestSetBlobByType.setInputBlobsByType/BlobType=Batched_Device=GPU_Config=().*)",
|
||||||
|
// TODO: Issue 72624
|
||||||
|
R"(smoke_PrePostProcess.*resize_dynamic.*)",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ inline std::vector<preprocess_func> GPU_smoke_preprocess_functions() {
|
|||||||
preprocess_func(resize_nearest, "resize_nearest", 0.01f),
|
preprocess_func(resize_nearest, "resize_nearest", 0.01f),
|
||||||
preprocess_func(resize_linear_nhwc, "resize_linear_nhwc", 0.01f),
|
preprocess_func(resize_linear_nhwc, "resize_linear_nhwc", 0.01f),
|
||||||
preprocess_func(resize_cubic, "resize_cubic", 0.01f),
|
preprocess_func(resize_cubic, "resize_cubic", 0.01f),
|
||||||
|
preprocess_func(resize_dynamic, "resize_dynamic", 0.01f, { ov::Shape {1, 3, 123, 123} }),
|
||||||
preprocess_func(convert_layout_by_dims, "convert_layout_by_dims", 0.01f),
|
preprocess_func(convert_layout_by_dims, "convert_layout_by_dims", 0.01f),
|
||||||
preprocess_func(resize_and_convert_layout, "resize_and_convert_layout", 0.01f),
|
preprocess_func(resize_and_convert_layout, "resize_and_convert_layout", 0.01f),
|
||||||
preprocess_func(cvt_color_nv12_to_rgb_single_plane, "cvt_color_nv12_to_rgb_single_plane", 1.f),
|
preprocess_func(cvt_color_nv12_to_rgb_single_plane, "cvt_color_nv12_to_rgb_single_plane", 1.f),
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "../base/layer_test_utils.hpp"
|
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||||
#include "ngraph_functions/builders.hpp"
|
#include "ngraph_functions/builders.hpp"
|
||||||
#include "ngraph_functions/preprocess/preprocess_builders.hpp"
|
#include "ngraph_functions/preprocess/preprocess_builders.hpp"
|
||||||
#include "ngraph_functions/utils/ngraph_helpers.hpp"
|
#include "ngraph_functions/utils/ngraph_helpers.hpp"
|
||||||
@ -21,7 +21,7 @@ using preprocessParamsTuple = std::tuple<
|
|||||||
std::string>; // Device name
|
std::string>; // Device name
|
||||||
|
|
||||||
class PrePostProcessTest : public testing::WithParamInterface<preprocessParamsTuple>,
|
class PrePostProcessTest : public testing::WithParamInterface<preprocessParamsTuple>,
|
||||||
virtual public LayerTestsUtils::LayerTestsCommon {
|
virtual public ov::test::SubgraphBaseTest {
|
||||||
public:
|
public:
|
||||||
static std::string getTestCaseName(const testing::TestParamInfo<preprocessParamsTuple> &obj);
|
static std::string getTestCaseName(const testing::TestParamInfo<preprocessParamsTuple> &obj);
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ void SubgraphBaseTest::run() {
|
|||||||
init_ref_function(functionRefs, targetStaticShapeVec);
|
init_ref_function(functionRefs, targetStaticShapeVec);
|
||||||
}
|
}
|
||||||
generate_inputs(targetStaticShapeVec);
|
generate_inputs(targetStaticShapeVec);
|
||||||
infer();
|
|
||||||
validate();
|
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
throw std::runtime_error("Incorrect target static shape: " +
|
throw std::runtime_error("Incorrect target static shape: " +
|
||||||
CommonTestUtils::vec2str(targetStaticShapeVec) + " " + ex.what());
|
CommonTestUtils::vec2str(targetStaticShapeVec) + " " + ex.what());
|
||||||
}
|
}
|
||||||
|
infer();
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
status = LayerTestsUtils::PassRate::Statuses::PASSED;
|
status = LayerTestsUtils::PassRate::Statuses::PASSED;
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "shared_test_classes/subgraph/preprocess.hpp"
|
#include "shared_test_classes/subgraph/preprocess.hpp"
|
||||||
#include "ngraph_functions/preprocess/preprocess_builders.hpp"
|
#include "ngraph_functions/preprocess/preprocess_builders.hpp"
|
||||||
#include "openvino/core/preprocess/pre_post_process.hpp"
|
#include "openvino/core/preprocess/pre_post_process.hpp"
|
||||||
#include <ie_ngraph_utils.hpp>
|
|
||||||
|
|
||||||
using namespace ov;
|
using namespace ov;
|
||||||
using namespace ov::preprocess;
|
using namespace ov::preprocess;
|
||||||
@ -20,7 +19,7 @@ std::string PrePostProcessTest::getTestCaseName(
|
|||||||
std::tie(func, targetName) = obj.param;
|
std::tie(func, targetName) = obj.param;
|
||||||
|
|
||||||
std::ostringstream result;
|
std::ostringstream result;
|
||||||
result << "Func=" << std::get<1>(func) << "_";
|
result << "Func=" << func.m_name << "_";
|
||||||
result << "Device=" << targetName << "";
|
result << "Device=" << targetName << "";
|
||||||
return result.str();
|
return result.str();
|
||||||
}
|
}
|
||||||
@ -28,14 +27,20 @@ std::string PrePostProcessTest::getTestCaseName(
|
|||||||
void PrePostProcessTest::SetUp() {
|
void PrePostProcessTest::SetUp() {
|
||||||
preprocess_func func;
|
preprocess_func func;
|
||||||
std::tie(func, targetDevice) = GetParam();
|
std::tie(func, targetDevice) = GetParam();
|
||||||
function = (std::get<0>(func))();
|
function = func.m_function();
|
||||||
threshold = std::get<2>(func);
|
rel_threshold = func.m_accuracy;
|
||||||
functionRefs = ngraph::clone_function(*function);
|
functionRefs = ngraph::clone_function(*function);
|
||||||
abs_threshold = std::get<2>(func);
|
abs_threshold = func.m_accuracy;
|
||||||
|
if (func.m_shapes.empty()) {
|
||||||
|
for (const auto& input : function->inputs()) {
|
||||||
|
func.m_shapes.push_back(input.get_shape());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
init_input_shapes(ov::test::static_shapes_to_test_representation(func.m_shapes));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(PrePostProcessTest, CompareWithRefs) {
|
TEST_P(PrePostProcessTest, CompareWithRefs) {
|
||||||
Run();
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace SubgraphTestsDefinitions
|
} // namespace SubgraphTestsDefinitions
|
||||||
|
@ -10,7 +10,19 @@ namespace ov {
|
|||||||
namespace builder {
|
namespace builder {
|
||||||
namespace preprocess {
|
namespace preprocess {
|
||||||
|
|
||||||
using preprocess_func = std::tuple<std::function<std::shared_ptr<Function>()>, std::string, float>;
|
struct preprocess_func {
|
||||||
|
preprocess_func() = default;
|
||||||
|
preprocess_func(const std::function<std::shared_ptr<Function>()>& f,
|
||||||
|
const std::string& name,
|
||||||
|
float acc,
|
||||||
|
const std::vector<Shape>& shapes = {}):
|
||||||
|
m_function(f), m_name(name), m_accuracy(acc), m_shapes(shapes) {
|
||||||
|
}
|
||||||
|
std::function<std::shared_ptr<Function>()> m_function = nullptr;
|
||||||
|
std::string m_name = {};
|
||||||
|
float m_accuracy = 0.01f;
|
||||||
|
std::vector<Shape> m_shapes = {};
|
||||||
|
};
|
||||||
|
|
||||||
inline std::vector<preprocess_func> generic_preprocess_functions();
|
inline std::vector<preprocess_func> generic_preprocess_functions();
|
||||||
|
|
||||||
@ -368,6 +380,17 @@ inline std::shared_ptr<Function> cvt_color_bgrx_to_bgr() {
|
|||||||
return p.build();
|
return p.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::shared_ptr<Function> resize_dynamic() {
|
||||||
|
using namespace ov::preprocess;
|
||||||
|
auto function = create_preprocess_1input(element::f32, PartialShape{1, 3, 20, 20});
|
||||||
|
auto p = PrePostProcessor(function);
|
||||||
|
p.input().tensor().set_spatial_dynamic_shape();
|
||||||
|
p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR);
|
||||||
|
p.input().network().set_layout("NCHW");
|
||||||
|
function = p.build();
|
||||||
|
return function;
|
||||||
|
}
|
||||||
|
|
||||||
inline std::vector<preprocess_func> generic_preprocess_functions() {
|
inline std::vector<preprocess_func> generic_preprocess_functions() {
|
||||||
return std::vector<preprocess_func> {
|
return std::vector<preprocess_func> {
|
||||||
preprocess_func(mean_only, "mean_only", 0.01f),
|
preprocess_func(mean_only, "mean_only", 0.01f),
|
||||||
@ -388,6 +411,7 @@ inline std::vector<preprocess_func> generic_preprocess_functions() {
|
|||||||
preprocess_func(resize_nearest, "resize_nearest", 0.01f),
|
preprocess_func(resize_nearest, "resize_nearest", 0.01f),
|
||||||
preprocess_func(resize_linear_nhwc, "resize_linear_nhwc", 0.01f),
|
preprocess_func(resize_linear_nhwc, "resize_linear_nhwc", 0.01f),
|
||||||
preprocess_func(resize_cubic, "resize_cubic", 0.01f),
|
preprocess_func(resize_cubic, "resize_cubic", 0.01f),
|
||||||
|
preprocess_func(resize_dynamic, "resize_dynamic", 0.01f, { Shape {1, 3, 123, 123} }),
|
||||||
preprocess_func(convert_layout_by_dims, "convert_layout_by_dims", 0.01f),
|
preprocess_func(convert_layout_by_dims, "convert_layout_by_dims", 0.01f),
|
||||||
preprocess_func(resize_and_convert_layout, "resize_and_convert_layout", 0.01f),
|
preprocess_func(resize_and_convert_layout, "resize_and_convert_layout", 0.01f),
|
||||||
preprocess_func(resize_and_convert_layout_i8, "resize_and_convert_layout_i8", 0.01f),
|
preprocess_func(resize_and_convert_layout_i8, "resize_and_convert_layout_i8", 0.01f),
|
||||||
|
Loading…
Reference in New Issue
Block a user