Remove NV12 and I420 blobs and deprecate some legacy API (#17919)

* Remove NV12 and I420 blobs and deprecate some legacy API

* Fixed some errors

* Remove NV12 blobs

* Remote NV12 conversion

* Fixed other warnings

* Suppress version

* Fix some warnings

* Fixed version

* Try to fix some warnings

* Suppress warnings in C header

* Suppress warnings in C

* Fixed Windows exceptions

* Try to fix warnings

* Try to fix C bindings build

* Suppress InferRequest

* Fixed some build issues

* Fixed some errors
This commit is contained in:
Ilya Churaev 2023-06-12 21:15:02 +04:00 committed by GitHub
parent 90a0e5f81a
commit df44f92a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 203 additions and 1823 deletions

View File

@ -227,34 +227,6 @@ Using Image Scaling
Converting Color Space
++++++++++++++++++++++
**Inference Engine API**
.. tab-set::
.. tab-item:: C++
:sync: cpp
.. doxygensnippet:: docs/snippets/ov_preprocessing_migration.cpp
:language: cpp
:fragment: color_space
.. tab-item:: Python
:sync: py
.. doxygensnippet:: docs/snippets/ov_preprocessing_migration.py
:language: python
:fragment: color_space
.. tab-item:: C
:sync: c
.. doxygensnippet:: docs/snippets/ov_preprocessing_migration.c
:language: c
:fragment: c_api_ppp
**API 2.0**

View File

@ -111,15 +111,6 @@ inputInfo->setLayout(InferenceEngine::Layout::NHWC);
//! [conversions]
}
{
//! [color_space]
auto preProcess = network.getInputsInfo()[operation_name]->getPreProcess();
// Inference Engine supposes NV12 as two inputs which need to be passed
// as InferenceEngine::NV12Blob composed of two Y and UV planes
preProcess.setColorFormat(InferenceEngine::NV12);
//! [color_space]
}
{
//! [image_scale]
auto preProcess = network.getInputsInfo()[operation_name]->getPreProcess();

View File

@ -90,14 +90,6 @@ inputInfo.setLayout(ie.Layout.NHWC)
# for shapes with 4 dimensions
#! [conversions]
#! [color_space]
preProcess = network.getInputsInfo()[operation_name].getPreProcess()
# Inference Engine supposes NV12 as two inputs which need to be passed
# as InferenceEngine::NV12Blob composed of two Y and UV planes
preProcess.setColorFormat(ie.NV12)
#! [color_space]
#! [image_scale]
preProcess = network.getInputsInfo()[operation_name].getPreProcess()
# Inference Engine supposes input for resize is always in NCHW layout

View File

@ -4,6 +4,9 @@
set(TARGET_NAME openvino_c)
# Suppress warnings due to catch macro with legacy exception types
ov_deprecated_no_errors()
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB_RECURSE HEADERS ${OpenVINO_C_API_SOURCE_DIR}/include/*.h)

View File

@ -17,7 +17,8 @@
#define CATCH_IE_EXCEPTION(StatusCode, ExceptionType) \
catch (const InferenceEngine::ExceptionType&) { \
return ov_status_e::StatusCode; \
}
} \
#define CATCH_OV_EXCEPTION(StatusCode, ExceptionType) \
catch (const ov::ExceptionType&) { \
return ov_status_e::StatusCode; \
@ -41,7 +42,7 @@
CATCH_IE_EXCEPTION(INFER_CANCELLED, InferCancelled) \
catch (...) { \
return ov_status_e::UNKNOW_EXCEPTION; \
}
} \
#define GET_PROPERTY_FROM_ARGS_LIST \
std::string property_key = va_arg(args_ptr, char*); \

View File

@ -2,6 +2,8 @@
# SPDX-License-Identifier: Apache-2.0
#
ov_deprecated_no_errors()
add_subdirectory(src)
if(ENABLE_TESTS AND ENABLE_GAPI_PREPROCESSING)

View File

@ -14,6 +14,7 @@
namespace InferenceEngine {
IE_SUPPRESS_DEPRECATED_START
/**
* @brief This class stores pre-process information for exact input
*/

View File

@ -19,6 +19,7 @@
namespace InferenceEngine {
IE_SUPPRESS_DEPRECATED_START
/**
* @brief This class stores pre-process information for exact input
*/
@ -132,4 +133,5 @@ inline PreProcessDataPtr CreatePreprocDataHelper() {
return std::make_shared<PreProcessDataPlugin>();
}
IE_SUPPRESS_DEPRECATED_END
} // namespace InferenceEngine

View File

@ -135,50 +135,6 @@ std::vector<std::vector<cv::gapi::own::Mat>> bind_to_blob(const Blob::Ptr& blob,
return result;
}
std::vector<std::vector<cv::gapi::own::Mat>> bind_to_blob(const NV12Blob::Ptr& inBlob,
int batch_size) {
const auto& y_blob = inBlob->y();
const auto& uv_blob = inBlob->uv();
// convert Y and UV plane blobs to Mats _separately_
auto batched_y_plane_mats = bind_to_blob(y_blob, batch_size);
auto batched_uv_plane_mats = bind_to_blob(uv_blob, batch_size);
// combine corresponding Y and UV mats into 2-element vectors of (Y, UV) pairs
std::vector<std::vector<cv::gapi::own::Mat>> batched_input_plane_mats(batch_size);
for (int i = 0; i < batch_size; ++i) {
auto& input = batched_input_plane_mats[i];
input.emplace_back(std::move(batched_y_plane_mats[i][0]));
input.emplace_back(std::move(batched_uv_plane_mats[i][0]));
}
return batched_input_plane_mats;
}
std::vector<std::vector<cv::gapi::own::Mat>> bind_to_blob(const I420Blob::Ptr& inBlob,
int batch_size) {
const auto& y_blob = inBlob->y();
const auto& u_blob = inBlob->u();
const auto& v_blob = inBlob->v();
// convert Y and UV plane blobs to Mats _separately_
auto batched_y_plane_mats = bind_to_blob(y_blob, batch_size);
auto batched_u_plane_mats = bind_to_blob(u_blob, batch_size);
auto batched_v_plane_mats = bind_to_blob(v_blob, batch_size);
// combine corresponding Y and UV mats into 2-element vectors of (Y, U, V) triple
std::vector<std::vector<cv::gapi::own::Mat>> batched_input_plane_mats(batch_size);
for (int i = 0; i < batch_size; ++i) {
auto& input = batched_input_plane_mats[i];
input.emplace_back(std::move(batched_y_plane_mats[i][0]));
input.emplace_back(std::move(batched_u_plane_mats[i][0]));
input.emplace_back(std::move(batched_v_plane_mats[i][0]));
}
return batched_input_plane_mats;
}
template<typename... Ts, int... IIs>
std::vector<cv::GMat> to_vec_impl(std::tuple<Ts...> &&gmats, cv::detail::Seq<IIs...>) {
return { std::get<IIs>(gmats)... };
@ -259,16 +215,6 @@ void validateColorFormats(const G::Desc &in_desc,
if (desc.d.C != 4) throw_invalid_number_of_channels();
break;
}
IE_SUPPRESS_DEPRECATED_START
case ColorFormat::NV12: {
if (desc.d.C != 2) throw_invalid_number_of_channels();
break;
}
case ColorFormat::I420: {
if (desc.d.C != 3) throw_invalid_number_of_channels();
break;
}
IE_SUPPRESS_DEPRECATED_END
default: break;
}
@ -287,12 +233,6 @@ void validateColorFormats(const G::Desc &in_desc,
IE_THROW() << "Network's expected color format is unspecified";
}
IE_SUPPRESS_DEPRECATED_START
if (output_color_format == ColorFormat::NV12 || output_color_format == ColorFormat::I420) {
IE_THROW() << "NV12/I420 network's color format is not supported [by G-API]";
}
IE_SUPPRESS_DEPRECATED_END
verify_layout(in_layout, "Input blob");
verify_layout(out_layout, "Network's blob");
@ -340,63 +280,11 @@ void validateTensorDesc(const TensorDesc& desc) {
void validateBlob(const MemoryBlob::Ptr &) {}
void validateBlob(const NV12Blob::Ptr &inBlob) {
const auto& y_blob = inBlob->y();
const auto& uv_blob = inBlob->uv();
if (!y_blob || !uv_blob) {
IE_THROW() << "Invalid underlying blobs in NV12Blob";
}
validateTensorDesc(uv_blob->getTensorDesc());
}
void validateBlob(const I420Blob::Ptr &inBlob) {
const auto& y_blob = inBlob->y();
const auto& u_blob = inBlob->u();
const auto& v_blob = inBlob->v();
if (!y_blob || !u_blob || !v_blob) {
IE_THROW() << "Invalid underlying blobs in I420Blob";
}
validateTensorDesc(u_blob->getTensorDesc());
validateTensorDesc(v_blob->getTensorDesc());
}
const std::pair<const TensorDesc&, Layout> getTensorDescAndLayout(const MemoryBlob::Ptr &blob) {
const auto& desc = blob->getTensorDesc();
return {desc, desc.getLayout()};
}
// use Y plane tensor descriptor's dims for tracking if update is needed. Y and U V planes are
// strictly bound to each other: if one is changed, the other must be changed as well. precision
// is always U8 and layout is always planar (NCHW)
const std::pair<const TensorDesc&, Layout> getTensorDescAndLayout(const NV12Blob::Ptr &blob) {
return {blob->y()->getTensorDesc(), Layout::NCHW};
}
const std::pair<const TensorDesc&, Layout> getTensorDescAndLayout(const I420Blob::Ptr &blob) {
return {blob->y()->getTensorDesc(), Layout::NCHW};
}
G::Desc getGDesc(G::Desc in_desc_y, const NV12Blob::Ptr &) {
auto nv12_desc = G::Desc{};
nv12_desc.d = in_desc_y.d;
nv12_desc.d.C = 2;
nv12_desc.prec = in_desc_y.prec;
return nv12_desc;
}
G::Desc getGDesc(G::Desc in_desc_y, const I420Blob::Ptr &) {
auto i420_desc = G::Desc{};
i420_desc.d = in_desc_y.d;
i420_desc.d.C = 3;
i420_desc.prec = in_desc_y.prec;
return i420_desc;
}
G::Desc getGDesc(G::Desc in_desc_y, const MemoryBlob::Ptr &) {
return in_desc_y;
}
@ -502,11 +390,7 @@ public:
{ {ColorFormat::RGBX, ColorFormat::RGB}, dropLastChan },
{ {ColorFormat::BGRX, ColorFormat::BGR}, dropLastChan },
{ {ColorFormat::RGBX, ColorFormat::BGR}, dropLastChanAndReverse },
{ {ColorFormat::BGRX, ColorFormat::RGB}, dropLastChanAndReverse },
{ {ColorFormat::NV12, ColorFormat::BGR}, NV12toBGR },
{ {ColorFormat::NV12, ColorFormat::RGB}, NV12toRGB },
{ {ColorFormat::I420, ColorFormat::BGR}, I420toBGR },
{ {ColorFormat::I420, ColorFormat::RGB}, I420toRGB }
{ {ColorFormat::BGRX, ColorFormat::RGB}, dropLastChanAndReverse }
};
IE_SUPPRESS_DEPRECATED_END
}
@ -575,36 +459,23 @@ cv::GComputation buildGraph(const G::Desc &in_desc,
// 1. Requires interleaved image of type CV_8UC3/CV_8UC4 (except for NV12/I420 input)
// 2. Supports bilinear resize only
// 3. Supports NV12/I420 -> RGB/BGR color transformations
IE_SUPPRESS_DEPRECATED_START
const bool nv12_input = (input_color_format == ColorFormat::NV12);
const bool i420_input = (input_color_format == ColorFormat::I420);
IE_SUPPRESS_DEPRECATED_END
const bool specific_yuv420_input_handling = (nv12_input || i420_input)
&& (output_color_format == ColorFormat::RGB || output_color_format == ColorFormat::BGR);
const auto io_color_formats = std::make_tuple(input_color_format, output_color_format);
const bool drop_channel = (io_color_formats == std::make_tuple(ColorFormat::RGBX, ColorFormat::RGB)) ||
(io_color_formats == std::make_tuple(ColorFormat::BGRX, ColorFormat::BGR));
const bool specific_case_of_preproc = ((in_layout == NHWC || specific_yuv420_input_handling)
&& (in_desc.d.C == 3 || specific_yuv420_input_handling || drop_channel)
const bool specific_case_of_preproc = ((in_layout == NHWC)
&& (in_desc.d.C == 3 || drop_channel)
&& ((in_desc.prec == CV_8U) && (in_desc.prec == out_desc.prec))
&& (algorithm == RESIZE_BILINEAR)
&& (input_color_format == ColorFormat::RAW
|| input_color_format == output_color_format
|| drop_channel
|| specific_yuv420_input_handling));
|| drop_channel));
if (specific_case_of_preproc) {
const auto input_sz = cv::gapi::own::Size(in_desc.d.W, in_desc.d.H);
const auto scale_sz = cv::gapi::own::Size(out_desc.d.W, out_desc.d.H);
// convert color format to RGB in case of NV12 input
std::vector<cv::GMat> color_converted_input;
if (nv12_input) {
color_converted_input.emplace_back(gapi::NV12toRGB::on(inputs[0], inputs[1]));
} else if (i420_input) {
color_converted_input.emplace_back(gapi::I420toRGB::on(inputs[0], inputs[1], inputs[2]));
} else {
color_converted_input = inputs;
}
color_converted_input = inputs;
auto planes = drop_channel ?
to_vec(gapi::ScalePlanes4:: on(
@ -616,11 +487,6 @@ cv::GComputation buildGraph(const G::Desc &in_desc,
planes.pop_back();
}
// if color conversion is done, output is RGB. but if BGR is required, reverse the planes
if (specific_yuv420_input_handling && output_color_format == ColorFormat::BGR) {
std::reverse(planes.begin(), planes.end());
}
std::vector<cv::GMat> outputs;
if (out_layout == NHWC) {
outputs.emplace_back(gapi::Merge3::on(planes[0], planes[1], planes[2]));
@ -772,10 +638,8 @@ PreprocEngine::Update PreprocEngine::needUpdate(const CallDesc &newCallOrig) con
void PreprocEngine::checkApplicabilityGAPI(const Blob::Ptr &src, const Blob::Ptr &dst) {
// Note: src blob is the ROI blob, dst blob is the network's input blob
// src is either a memory blob, an NV12, or an I420 blob
const bool yuv420_blob = src->is<NV12Blob>() || src->is<I420Blob>();
if (!src->is<MemoryBlob>() && !yuv420_blob) {
IE_THROW() << "Unsupported input blob type: expected MemoryBlob, NV12Blob or I420Blob";
if (!src->is<MemoryBlob>()) {
IE_THROW() << "Unsupported input blob type: expected MemoryBlob";
}
// dst is always a memory blob
@ -787,7 +651,7 @@ void PreprocEngine::checkApplicabilityGAPI(const Blob::Ptr &src, const Blob::Ptr
const auto &dst_dims = dst->getTensorDesc().getDims();
// dimensions sizes must be equal if both blobs are memory blobs
if (!yuv420_blob && src_dims.size() != dst_dims.size()) {
if (src_dims.size() != dst_dims.size()) {
IE_THROW() << "Preprocessing is not applicable. Source and destination blobs "
"have different number of dimensions.";
}
@ -997,39 +861,12 @@ void PreprocEngine::preprocessWithGAPI(const Blob::Ptr &inBlob, Blob::Ptr &outBl
IE_THROW() << "Unsupported network's input blob type: expected MemoryBlob";
}
// FIXME: refactor the code below. there must be a better way to handle the difference
// if input color format is not NV12, a MemoryBlob is expected. otherwise, NV12Blob is expected
switch (in_fmt) {
IE_SUPPRESS_DEPRECATED_START
case ColorFormat::NV12: {
auto inNV12Blob = as<NV12Blob>(inBlob);
if (!inNV12Blob) {
IE_THROW() << "Unsupported input blob for color format " << in_fmt
<< ": expected NV12Blob";
}
return preprocessBlob(inNV12Blob, outMemoryBlob, algorithm, in_fmt, out_fmt, omp_serial,
batch_size);
}
case ColorFormat::I420: {
auto inI420Blob = as<I420Blob>(inBlob);
if (!inI420Blob) {
IE_THROW() << "Unsupported input blob for color format " << in_fmt
<< ": expected I420Blob";
}
return preprocessBlob(inI420Blob, outMemoryBlob, algorithm, in_fmt, out_fmt, omp_serial,
batch_size);
}
IE_SUPPRESS_DEPRECATED_END
default:
auto inMemoryBlob = as<MemoryBlob>(inBlob);
if (!inMemoryBlob) {
IE_THROW() << "Unsupported input blob for color format " << in_fmt
<< ": expected MemoryBlob";
}
return preprocessBlob(inMemoryBlob, outMemoryBlob, algorithm, in_fmt, out_fmt, omp_serial,
batch_size);
auto inMemoryBlob = as<MemoryBlob>(inBlob);
if (!inMemoryBlob) {
IE_THROW() << "Unsupported input blob for color format " << in_fmt
<< ": expected MemoryBlob";
}
return preprocessBlob(inMemoryBlob, outMemoryBlob, algorithm, in_fmt, out_fmt, omp_serial,
batch_size);
}
} // namespace InferenceEngine

View File

@ -132,7 +132,6 @@ cv::String colorFormatToString(InferenceEngine::ColorFormat f) {
case ColorFormat::BGR: return "BGR";
case ColorFormat::RGBX: return "RGBX";
case ColorFormat::BGRX: return "BGRX";
case ColorFormat::NV12: return "NV12";
default: IE_THROW() << "Unrecognized color format";
}
}
@ -177,8 +176,6 @@ cv::ColorConversionCodes toCvtColorCode(InferenceEngine::ColorFormat in,
{{ColorFormat::BGR, ColorFormat::RGBX}, cv::COLOR_BGR2RGBA},
{{ColorFormat::BGR, ColorFormat::BGRX}, cv::COLOR_BGR2BGRA},
{{ColorFormat::BGR, ColorFormat::RGB}, cv::COLOR_BGR2RGB},
{{ColorFormat::NV12, ColorFormat::BGR}, cv::COLOR_YUV2BGR_NV12},
{{ColorFormat::NV12, ColorFormat::RGB}, cv::COLOR_YUV2RGB_NV12}
};
IE_SUPPRESS_DEPRECATED_END
return types.at(std::make_pair(in, out));
@ -965,92 +962,6 @@ TEST_P(ColorConvertTestIE, AccuracyTest)
}
}
TEST_P(ColorConvertYUV420TestIE, AccuracyTest)
{
using namespace InferenceEngine;
const int depth = CV_8U;
auto in_fmt = ColorFormat::NV12;
const auto out_fmt = ColorFormat::BGR; // for now, always BGR
auto out_layout = Layout::ANY;
cv::Size size;
double tolerance = 0.0;
std::tie(in_fmt, out_layout, size, tolerance) = GetParam();
cv::Mat in_mat_y(size, CV_MAKE_TYPE(depth, 1));
cv::Mat in_mat_uv(cv::Size(size.width / 2, size.height / 2), CV_MAKE_TYPE(depth, 2));
cv::Scalar mean = cv::Scalar::all(127);
cv::Scalar stddev = cv::Scalar::all(40.f);
cv::randn(in_mat_y, mean, stddev);
cv::randn(in_mat_uv, mean / 2, stddev / 2);
int out_type = CV_MAKE_TYPE(depth, numChannels(out_fmt));
cv::Mat out_mat(size, out_type);
cv::Mat out_mat_ocv(size, out_type);
// Inference Engine code ///////////////////////////////////////////////////
size_t out_channels = out_mat.channels();
CV_Assert(3 == out_channels || 4 == out_channels);
ASSERT_TRUE(in_mat_y.isContinuous() && out_mat.isContinuous());
auto make_nv12_blob = [&](){
auto y_blob = img2Blob<Precision::U8>(in_mat_y, Layout::NHWC);
auto uv_blob = img2Blob<Precision::U8>(in_mat_uv, Layout::NHWC);
return make_shared_blob<NV12Blob>(y_blob, uv_blob);
};
auto make_I420_blob = [&](){
cv::Mat in_mat_u(cv::Size(size.width / 2, size.height / 2), CV_MAKE_TYPE(depth, 1));
cv::Mat in_mat_v(cv::Size(size.width / 2, size.height / 2), CV_MAKE_TYPE(depth, 1));
std::array<cv::Mat, 2> in_uv = {in_mat_u, in_mat_v};
cv::split(in_mat_uv, in_uv);
auto y_blob = img2Blob<Precision::U8>(in_mat_y, Layout::NHWC);
auto u_blob = img2Blob<Precision::U8>(in_mat_u, Layout::NHWC);
auto v_blob = img2Blob<Precision::U8>(in_mat_v, Layout::NHWC);
return make_shared_blob<I420Blob>(y_blob, u_blob, v_blob);
};
Blob::Ptr in_blob = (in_fmt == ColorFormat::NV12) ? Blob::Ptr{make_nv12_blob()} : Blob::Ptr {make_I420_blob()};
auto out_blob = img2Blob<Precision::U8>(out_mat, out_layout);
PreProcessDataPtr preprocess = CreatePreprocDataHelper();
preprocess->setRoiBlob(in_blob);
PreProcessInfo info;
info.setColorFormat(in_fmt);
// test once to warm-up cache
preprocess->execute(out_blob, info, false);
Blob2Img<Precision::U8>(out_blob, out_mat, out_layout);
#if PERF_TEST
const auto in_layout = Layout::NCHW;
// iterate testing, and print performance
test_ms([&](){ preprocess->execute(out_blob, info, false); },
100, "Color Convert IE %s %s %s %dx%d %s->%s",
depthToString(depth).c_str(),
layoutToString(in_layout).c_str(), layoutToString(out_layout).c_str(),
size.width, size.height,
colorFormatToString(in_fmt).c_str(), colorFormatToString(out_fmt).c_str());
#endif
// OpenCV code /////////////////////////////////////////////////////////////
{
//for both I420 and NV12 use NV12 as I420 is not supported by OCV
cv::cvtColorTwoPlane(in_mat_y, in_mat_uv, out_mat_ocv, toCvtColorCode(ColorFormat::NV12, out_fmt));
}
// Comparison //////////////////////////////////////////////////////////////
{
EXPECT_LE(cv::norm(out_mat_ocv, out_mat, cv::NORM_INF), tolerance);
}
}
TEST_P(SplitTestIE, AccuracyTest)
{
const auto params = GetParam();
@ -1199,151 +1110,6 @@ TEST_P(MergeTestIE, AccuracyTest)
EXPECT_LE(cv::norm(out_mat_ocv, out_mat, cv::NORM_INF), tolerance);
}
TEST_P(PreprocTest, Performance)
{
using namespace InferenceEngine;
std::pair<Precision, Precision> precisions;
ResizeAlgorithm interp;
Layout in_layout, out_layout;
std::pair<int, int> ocv_channels{-1, -1};
std::pair<cv::Size, cv::Size> sizes;
ColorFormat in_fmt = ColorFormat::RAW;
ColorFormat out_fmt = ColorFormat::BGR;
std::tie(precisions, interp, in_fmt, in_layout, out_layout, ocv_channels, sizes) = GetParam();
Precision in_prec, out_prec;
std::tie(in_prec, out_prec) = precisions;
cv::Size in_size, out_size;
std::tie(in_size, out_size) = sizes;
int in_ocv_chan = -1, out_ocv_chan = -1;
std::tie(in_ocv_chan, out_ocv_chan) = ocv_channels;
#if defined(__arm__) || defined(__aarch64__)
double tolerance = in_prec == Precision::U8 || in_prec == Precision::U16 || out_prec == Precision::U8 ? 4 : 0.015;
#else
double tolerance = in_prec == Precision::U8 || in_prec == Precision::U16 || out_prec == Precision::U8 ? 1 : 0.015;
#endif
auto precision_to_depth = [](Precision::ePrecision prec) -> int{
switch (prec)
{
case Precision::U8: return CV_8U;
case Precision::U16: return CV_16U;
case Precision::FP32: return CV_32F;
default:
throw std::logic_error("Unsupported configuration");
}
return -1;
};
const int in_ocv_type = CV_MAKETYPE(precision_to_depth(in_prec), in_ocv_chan);
const int out_ocv_type = CV_MAKETYPE(precision_to_depth(out_prec), out_ocv_chan);
initMatrixRandU(in_ocv_type, in_size, out_ocv_type, false);
cv::Mat out_mat(out_size, out_ocv_type);
// convert input mat to correct color format if required. note that NV12 being a planar case is
// handled separately
if (in_fmt != ColorFormat::RAW && in_fmt != ColorFormat::BGR && in_fmt != ColorFormat::NV12) {
cv::cvtColor(in_mat1, in_mat1, toCvtColorCode(in_fmt));
}
// create additional cv::Mat in NV12 case
if (in_fmt == ColorFormat::NV12) {
in_mat2 = cv::Mat(cv::Size(in_mat1.cols / 2, in_mat1.rows / 2), CV_8UC2);
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255));
}
auto create_blob = [](Precision::ePrecision prec, ColorFormat fmt, Layout layout, cv::Mat& m1, cv::util::optional<cv::Mat> m2 = {}){
Blob::Ptr blob;
switch (prec)
{
case Precision::U8:
if (fmt == ColorFormat::NV12) {
auto y_blob = img2Blob<Precision::U8>(m1, Layout::NHWC);
auto uv_blob = img2Blob<Precision::U8>(m2.value(), Layout::NHWC);
blob = make_shared_blob<NV12Blob>(y_blob, uv_blob);
} else {
blob = img2Blob<Precision::U8>(m1, layout);
}
break;
case Precision::U16:
blob = img2Blob<Precision::U16>(m1, layout);
break;
case Precision::FP32:
blob = img2Blob<Precision::FP32>(m1, layout);
break;
default:
throw std::logic_error("Unsupported configuration");
}
return blob;
};
auto in_blob = create_blob(in_prec, in_fmt, in_layout, in_mat1, cv::util::make_optional(in_mat2));
auto out_blob = create_blob(out_prec, out_fmt, out_layout, out_mat);
PreProcessDataPtr preprocess = CreatePreprocDataHelper();
preprocess->setRoiBlob(in_blob);
PreProcessInfo info;
info.setResizeAlgorithm(interp);
info.setColorFormat(in_fmt);
// test once to warm-up cache
preprocess->execute(out_blob, info, false);
switch (out_prec)
{
case Precision::U8: Blob2Img<Precision::U8> (out_blob, out_mat, out_layout); break;
case Precision::FP32: Blob2Img<Precision::FP32>(out_blob, out_mat, out_layout); break;
case Precision::U16: Blob2Img<Precision::U16>(out_blob, out_mat, out_layout); break;
default: FAIL() << "Unsupported configuration";
}
cv::Mat ocv_out_mat(in_mat1);
if (in_fmt != ColorFormat::RAW && in_fmt != out_fmt && in_fmt != ColorFormat::NV12) {
cv::cvtColor(ocv_out_mat, ocv_out_mat, toCvtColorCode(in_fmt, out_fmt));
} else if (in_fmt == ColorFormat::NV12) {
cv::cvtColorTwoPlane(ocv_out_mat, in_mat2, ocv_out_mat, toCvtColorCode(in_fmt, out_fmt));
}
auto cv_interp = interp == RESIZE_AREA ? cv::INTER_AREA : cv::INTER_LINEAR;
cv::resize(ocv_out_mat, ocv_out_mat, out_size, 0, 0, cv_interp);
if (in_prec != out_prec) {
cv::Mat ocv_converted;
ocv_out_mat.convertTo(ocv_converted, out_ocv_type);
ocv_out_mat = ocv_converted;
}
EXPECT_LE(cv::norm(ocv_out_mat, out_mat, cv::NORM_INF), tolerance);
#if PERF_TEST
// iterate testing, and print performance
const auto in_type_str = depthToString(precision_to_depth(in_prec));
const auto out_type_str = depthToString(precision_to_depth(out_prec));
const auto interp_str = interp == RESIZE_AREA ? "AREA"
: interp == RESIZE_BILINEAR ? "BILINEAR" : "?";
const auto in_layout_str = layoutToString(in_layout);
const auto out_layout_str = layoutToString(out_layout);
test_ms([&]() { preprocess->execute(out_blob, info, false); },
300,
"Preproc %s %s %s %d %s %dx%d %d %s %dx%d %s->%s",
in_type_str.c_str(),
out_type_str.c_str(),
interp_str,
in_ocv_chan,
in_layout_str.c_str(), in_size.width, in_size.height,
out_ocv_chan,
out_layout_str.c_str(), out_size.width, out_size.height,
colorFormatToString(in_fmt).c_str(), colorFormatToString(out_fmt).c_str());
#endif // PERF_TEST
}
TEST_P(MeanValueGAPI, AccuracyTest)
{
const auto params = GetParam();

View File

@ -268,22 +268,6 @@ INSTANTIATE_TEST_SUITE_P(ColorConvertFluid_4ch, ColorConvertTestIE,
Values(TEST_SIZES),
Values(0)));
IE_SUPPRESS_DEPRECATED_START
INSTANTIATE_TEST_SUITE_P(ColorConvertYUV420Fluid, ColorConvertYUV420TestIE,
Combine(Values(InferenceEngine::NV12, InferenceEngine::I420),
Values(InferenceEngine::NHWC, InferenceEngine::NCHW),
Values(cv::Size(3840, 2160),
cv::Size(1920, 1080),
cv::Size(1280, 720),
cv::Size(1280, 960),
cv::Size( 960, 720),
cv::Size( 640, 480),
cv::Size( 320, 200),
cv::Size( 300, 300),
cv::Size( 150, 150)),
Values(1)));
IE_SUPPRESS_DEPRECATED_END
INSTANTIATE_TEST_SUITE_P(Reorder_HWC2CHW, ColorConvertTestIE,
Combine(Values(CV_8U, CV_32F, CV_16S, CV_16F),
Values(InferenceEngine::ColorFormat::BGR),
@ -404,18 +388,6 @@ INSTANTIATE_TEST_SUITE_P(ColorFormats_4ch, PreprocTest,
Values(std::make_pair(4, 3)),
Values(TEST_SIZES_PREPROC)));
IE_SUPPRESS_DEPRECATED_START
INSTANTIATE_TEST_SUITE_P(ColorFormat_NV12, PreprocTest,
Combine(Values(U8toU8),
Values(IE::ResizeAlgorithm::RESIZE_BILINEAR, IE::ResizeAlgorithm::RESIZE_AREA),
Values(IE::ColorFormat::NV12),
Values(IE::Layout::NCHW),
Values(IE::Layout::NHWC, IE::Layout::NCHW),
Values(std::make_pair(1, 3)),
Values(TEST_SIZES_PREPROC)));
IE_SUPPRESS_DEPRECATED_END
INSTANTIATE_TEST_SUITE_P(PlainPrecisionConversions, PreprocTest,
Combine(Values(std::make_pair(IE::Precision::U16,IE::Precision::FP32),
std::make_pair(IE::Precision::FP32,IE::Precision::U16)

View File

@ -208,9 +208,9 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
bin_stream.open(weights_path.c_str(), std::ios::binary);
if (!bin_stream.is_open())
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
IE_THROW() << "Weights file " + ov::util::wstring_to_string(weights_path) + " cannot be opened!";
OPENVINO_THROW("Weights file ", ov::util::wstring_to_string(weights_path), " cannot be opened!");
#else
IE_THROW() << "Weights file " + weights_path + " cannot be opened!";
OPENVINO_THROW("Weights file ", weights_path, " cannot be opened!");
#endif
bin_stream.seekg(0, std::ios::end);

View File

@ -20,6 +20,6 @@ void RTInfoDeserializer::on_adapter(const std::string& name, ValueAccessor<void>
str_to_set_of_strings(val, ss);
a->set(ss);
} else {
IE_THROW() << "Not implemented";
OPENVINO_NOT_IMPLEMENTED;
}
}

View File

@ -25,7 +25,7 @@ void str_to_container(const std::string& value, T& res) {
std::string field;
while (getline(ss, field, ',')) {
if (field.empty())
IE_THROW() << "Cannot get vector of parameters! \"" << value << "\" is incorrect";
OPENVINO_THROW("Cannot get vector of parameters! \"", value, "\" is incorrect");
std::stringstream fs(field);
typename T::value_type val;
fs >> val;

View File

@ -16,6 +16,7 @@
#include "ie_common.h"
namespace InferenceEngine {
IE_SUPPRESS_DEPRECATED_START
/**
* @brief A description buffer wrapping StatusCode and ResponseDesc
@ -119,4 +120,5 @@ private:
}
}
};
IE_SUPPRESS_DEPRECATED_END
} // namespace InferenceEngine

View File

@ -42,6 +42,7 @@
* Exec order is predefined.
*/
IE_SUPPRESS_DEPRECATED_START
class MemorySolver {
public:
/** @brief Representation of edge (size and live time)*/
@ -224,3 +225,4 @@ private:
}
}
};
IE_SUPPRESS_DEPRECATED_END

View File

@ -50,7 +50,7 @@ struct SoPtr {
template <typename U>
SoPtr(const SoPtr<U>& that) : _ptr{std::dynamic_pointer_cast<T>(that._ptr)},
_so{that._so} {
IE_ASSERT(_ptr != nullptr);
OPENVINO_ASSERT(_ptr != nullptr);
}
/**

View File

@ -29,6 +29,8 @@
namespace InferenceEngine {
IE_SUPPRESS_DEPRECATED_START
class IInferRequestInternal;
namespace details {
@ -271,7 +273,6 @@ public:
bool operator==(const InferRequest&) const noexcept;
};
IE_SUPPRESS_DEPRECATED_START
/**
* @private
*/

View File

@ -23,6 +23,7 @@
#include "ie_parameter.hpp"
IE_SUPPRESS_DEPRECATED_START
namespace InferenceEngine {
namespace gpu {
@ -91,3 +92,4 @@ protected:
} // namespace gpu
} // namespace InferenceEngine
IE_SUPPRESS_DEPRECATED_END

View File

@ -130,36 +130,6 @@ public:
}
};
/**
* @brief This function is used to obtain a NV12 compound blob object from NV12 DXGI video decoder output.
* The resulting compound contains two remote blobs for Y and UV planes of the surface.
* @param height Height of Y plane
* @param width Widht of Y plane
* @param ctx A pointer to remote context
* @param nv12_surf A ID3D11Texture2D instance to create NV12 blob from
* @return NV12 remote blob
*/
OPENVINO_DEPRECATED("This function is deprecated and will be removed in 2023.1 release")
static inline Blob::Ptr make_shared_blob_nv12(size_t height,
size_t width,
RemoteContext::Ptr ctx,
ID3D11Texture2D* nv12_surf) {
// despite of layout, blob dimensions always follow in N,C,H,W order
TensorDesc desc(Precision::U8, {1, 1, height, width}, Layout::NHWC);
ParamMap blobParams = {{GPU_PARAM_KEY(SHARED_MEM_TYPE), GPU_PARAM_VALUE(VA_SURFACE)},
{GPU_PARAM_KEY(DEV_OBJECT_HANDLE), static_cast<gpu_handle_param>(nv12_surf)},
{GPU_PARAM_KEY(VA_PLANE), uint32_t(0)}};
Blob::Ptr y_blob = std::dynamic_pointer_cast<Blob>(ctx->CreateBlob(desc, blobParams));
TensorDesc uvdesc(Precision::U8, {1, 2, height / 2, width / 2}, Layout::NHWC);
blobParams[GPU_PARAM_KEY(MEM_HANDLE)] = static_cast<gpu_handle_param>(nv12_surf);
blobParams[GPU_PARAM_KEY(VA_PLANE)] = uint32_t(1);
Blob::Ptr uv_blob = std::dynamic_pointer_cast<Blob>(ctx->CreateBlob(uvdesc, blobParams));
return InferenceEngine::make_shared_blob<NV12Blob>(y_blob, uv_blob);
}
/**
* @brief This function is used to obtain remote context object from ID3D11Device
* @param core Inference Engine Core object instance

View File

@ -238,41 +238,6 @@ public:
}
};
/**
* @brief This function is used to construct a NV12 compound blob object from two cl::Image2D wrapper objects.
* The resulting compound contains two remote blobs for Y and UV planes of the surface.
* @param ctx RemoteContext plugin object derived from ClContext class.
* @param nv12_image_plane_y cl::Image2D object containing Y plane data.
* @param nv12_image_plane_uv cl::Image2D object containing UV plane data.
* @return A shared remote blob instance
*/
OPENVINO_DEPRECATED("This function is deprecated and will be removed in 2023.1 release")
static inline Blob::Ptr make_shared_blob_nv12(RemoteContext::Ptr ctx,
cl::Image2D& nv12_image_plane_y,
cl::Image2D& nv12_image_plane_uv) {
auto casted = std::dynamic_pointer_cast<ClContext>(ctx);
if (nullptr == casted) {
IE_THROW() << "Invalid remote context passed";
}
size_t width = nv12_image_plane_y.getImageInfo<CL_IMAGE_WIDTH>();
size_t height = nv12_image_plane_y.getImageInfo<CL_IMAGE_HEIGHT>();
// despite of layout, blob dimensions always follow in N,C,H,W order
TensorDesc ydesc(Precision::U8, {1, 1, height, width}, Layout::NHWC);
ParamMap blobParams = {{GPU_PARAM_KEY(SHARED_MEM_TYPE), GPU_PARAM_VALUE(OCL_IMAGE2D)},
{GPU_PARAM_KEY(MEM_HANDLE), static_cast<gpu_handle_param>(nv12_image_plane_y.get())}};
Blob::Ptr y_blob = std::dynamic_pointer_cast<Blob>(casted->CreateBlob(ydesc, blobParams));
TensorDesc uvdesc(Precision::U8, {1, 2, height / 2, width / 2}, Layout::NHWC);
blobParams[GPU_PARAM_KEY(MEM_HANDLE)] = static_cast<gpu_handle_param>(nv12_image_plane_uv.get());
Blob::Ptr uv_blob = std::dynamic_pointer_cast<Blob>(casted->CreateBlob(uvdesc, blobParams));
Blob::Ptr res = make_shared_blob<NV12Blob>(y_blob, uv_blob);
return res;
}
/**
* @brief This function is used to obtain remote context object from user-supplied OpenCL context handle
* @param core A reference to Inference Engine Core object

View File

@ -101,34 +101,6 @@ public:
}
};
/**
* @brief This function is used to obtain a NV12 compound blob object from NV12 VA decoder output.
* The resulting compound contains two remote blobs for Y and UV planes of the surface.
* @param height A height of Y plane
* @param width A width of Y plane
* @param ctx A remote context instance
* @param nv12_surf NV12 `VASurfaceID` to create NV12 from
* @return A remote NV12 blob wrapping `VASurfaceID`
*/
OPENVINO_DEPRECATED("This function is deprecated and will be removed in 2023.1 release")
static inline Blob::Ptr make_shared_blob_nv12(size_t height,
size_t width,
RemoteContext::Ptr ctx,
VASurfaceID nv12_surf) {
// despite of layout, blob dimensions always follow in N, C, H, W order
TensorDesc ydesc(Precision::U8, {1, 1, height, width}, Layout::NHWC);
ParamMap blobParams = {{GPU_PARAM_KEY(SHARED_MEM_TYPE), GPU_PARAM_VALUE(VA_SURFACE)},
{GPU_PARAM_KEY(DEV_OBJECT_HANDLE), nv12_surf},
{GPU_PARAM_KEY(VA_PLANE), uint32_t(0)}};
Blob::Ptr y_blob = std::dynamic_pointer_cast<Blob>(ctx->CreateBlob(ydesc, blobParams));
TensorDesc uvdesc(Precision::U8, {1, 2, height / 2, width / 2}, Layout::NHWC);
blobParams[GPU_PARAM_KEY(VA_PLANE)] = uint32_t(1);
Blob::Ptr uv_blob = std::dynamic_pointer_cast<Blob>(ctx->CreateBlob(uvdesc, blobParams));
return InferenceEngine::make_shared_blob<NV12Blob>(y_blob, uv_blob);
}
/**
* @brief This function is used to obtain remote context object from VA display handle
* @param core Inference Engine Core object

View File

@ -9,6 +9,16 @@
#pragma once
#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED)
# define IE_LEGACY_HEADER_INCLUDED
# ifdef _MSC_VER
# pragma message( \
"The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# else
# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# endif
#endif
#if defined(OPENVINO_STATIC_LIBRARY) || defined(USE_STATIC_IE) || (defined(__GNUC__) && (__GNUC__ < 4))
# define INFERENCE_ENGINE_API(...) extern "C" __VA_ARGS__
# define INFERENCE_ENGINE_API_CPP(...) __VA_ARGS__

View File

@ -9,6 +9,16 @@
*/
#pragma once
#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED)
# define IE_LEGACY_HEADER_INCLUDED
# ifdef _MSC_VER
# pragma message( \
"The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# else
# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# endif
#endif
#include <algorithm>
#include <cstdlib>
#include <iterator>
@ -22,6 +32,7 @@
#include "ie_api.h"
IE_SUPPRESS_DEPRECATED_START
#ifndef NDEBUG
# include <cassert>
#endif
@ -58,7 +69,7 @@ using DataWeakPtr = std::weak_ptr<Data>;
* @union UserValue
* @brief The method holds the user values to enable binding of data per graph node.
*/
union UserValue {
union INFERENCE_ENGINE_1_0_DEPRECATED UserValue {
int v_int; //!< An integer value
float v_float; //!< A floating point value
void* v_ptr; //!< A pointer to a void
@ -68,7 +79,7 @@ union UserValue {
* @enum Layout
* @brief Layouts that the inference engine supports
*/
enum Layout : uint8_t {
enum INFERENCE_ENGINE_1_0_DEPRECATED Layout : uint8_t {
ANY = 0, //!< "any" layout
// I/O data layouts
@ -107,7 +118,7 @@ enum Layout : uint8_t {
* @param p A layout value to print to a stream
* @return A reference to the `out` stream
*/
inline std::ostream& operator<<(std::ostream& out, const Layout& p) {
INFERENCE_ENGINE_1_0_DEPRECATED inline std::ostream& operator<<(std::ostream& out, const Layout& p) {
switch (p) {
#define PRINT_LAYOUT(name) \
case name: \
@ -143,18 +154,12 @@ inline std::ostream& operator<<(std::ostream& out, const Layout& p) {
* @enum ColorFormat
* @brief Extra information about input color format for preprocessing
*/
enum ColorFormat : uint32_t {
enum INFERENCE_ENGINE_1_0_DEPRECATED ColorFormat : uint32_t {
RAW = 0u, ///< Plain blob (default), no extra color processing required
RGB, ///< RGB color format
BGR, ///< BGR color format, default in OpenVINO
RGBX, ///< RGBX color format with X ignored during inference
BGRX, ///< BGRX color format with X ignored during inference
NV12 INFERENCE_ENGINE_ENUM_DEPRECATED(
"This type is deprecated and will be removed in 2023.1 release"), ///< NV12 color format represented as
///< compound Y+UV blob
I420 INFERENCE_ENGINE_ENUM_DEPRECATED(
"This type is deprecated and will be removed in 2023.1 release"), ///< I420 color format represented as
///< compound Y+U+V blob
};
/**
@ -163,7 +168,7 @@ enum ColorFormat : uint32_t {
* @param fmt A color format value to print to a stream
* @return A reference to the `out` stream
*/
inline std::ostream& operator<<(std::ostream& out, const ColorFormat& fmt) {
INFERENCE_ENGINE_1_0_DEPRECATED inline std::ostream& operator<<(std::ostream& out, const ColorFormat& fmt) {
switch (fmt) {
#define PRINT_COLOR_FORMAT(name) \
case name: \
@ -175,10 +180,6 @@ inline std::ostream& operator<<(std::ostream& out, const ColorFormat& fmt) {
PRINT_COLOR_FORMAT(BGR);
PRINT_COLOR_FORMAT(RGBX);
PRINT_COLOR_FORMAT(BGRX);
IE_SUPPRESS_DEPRECATED_START
PRINT_COLOR_FORMAT(NV12);
PRINT_COLOR_FORMAT(I420);
IE_SUPPRESS_DEPRECATED_END
#undef PRINT_COLOR_FORMAT
default:
@ -195,11 +196,11 @@ inline std::ostream& operator<<(std::ostream& out, const ColorFormat& fmt) {
* If the layer is executed using tiling, the sum time per each tile is indicated as the total execution time.
* Due to parallel execution, the total execution time for all layers might be greater than the total inference time.
*/
struct InferenceEngineProfileInfo {
struct INFERENCE_ENGINE_1_0_DEPRECATED InferenceEngineProfileInfo {
/**
* @brief Defines the general status of the layer
*/
enum LayerStatus {
enum INFERENCE_ENGINE_1_0_DEPRECATED LayerStatus {
NOT_RUN, //!< A layer is not executed
OPTIMIZED_OUT, //!< A layer is optimized out during graph optimization phase
EXECUTED //!< A layer is executed
@ -239,7 +240,7 @@ struct InferenceEngineProfileInfo {
* @enum StatusCode
* @brief This enum contains codes for all possible return values of the interface functions
*/
enum StatusCode : int {
enum INFERENCE_ENGINE_1_0_DEPRECATED StatusCode : int {
OK = 0,
GENERAL_ERROR = -1,
NOT_IMPLEMENTED = -2,
@ -263,7 +264,7 @@ enum StatusCode : int {
* @struct ResponseDesc
* @brief Represents detailed information for an error
*/
struct ResponseDesc {
struct INFERENCE_ENGINE_1_0_DEPRECATED ResponseDesc {
/**
* @brief A character buffer that holds the detailed information for an error.
*/
@ -273,7 +274,7 @@ struct ResponseDesc {
/**
* @brief Response structure encapsulating information about supported layer
*/
struct QueryNetworkResult {
struct INFERENCE_ENGINE_1_0_DEPRECATED QueryNetworkResult {
/**
* @brief A map of supported layers:
* - key - a layer name
@ -303,7 +304,7 @@ using ConstOutputsDataMap = std::map<std::string, CDataPtr>;
using OutputsDataMap = std::map<std::string, DataPtr>;
namespace details {
struct INFERENCE_ENGINE_DEPRECATED("Use InferRequest::Exception") INFERENCE_ENGINE_API_CLASS(InferenceEngineException)
struct INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(InferenceEngineException)
: public std::runtime_error {
using std::runtime_error::runtime_error;
bool hasStatus() const {
@ -317,7 +318,8 @@ struct INFERENCE_ENGINE_DEPRECATED("Use InferRequest::Exception") INFERENCE_ENGI
* @brief Base Inference Engine exception class
*/
IE_SUPPRESS_DEPRECATED_START
struct INFERENCE_ENGINE_API_CLASS(Exception) : public details::InferenceEngineException {
struct INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(Exception)
: public details::InferenceEngineException {
using InferenceEngineException::InferenceEngineException;
};
IE_SUPPRESS_DEPRECATED_END
@ -328,17 +330,18 @@ template <typename ExceptionType>
struct ExceptionTraits;
}
#define INFERENCE_ENGINE_DECLARE_EXCEPTION(ExceptionType, statusCode) \
struct INFERENCE_ENGINE_API_CLASS(ExceptionType) final : public InferenceEngine::Exception { \
using Exception::Exception; \
}; \
namespace details { \
template <> \
struct ExceptionTraits<ExceptionType> { \
static const char* string() { \
return "[ " #statusCode " ]"; \
} \
}; \
#define INFERENCE_ENGINE_DECLARE_EXCEPTION(ExceptionType, statusCode) \
struct INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(ExceptionType) final \
: public InferenceEngine::Exception { \
using Exception::Exception; \
}; \
namespace details { \
template <> \
struct INFERENCE_ENGINE_1_0_DEPRECATED ExceptionTraits<ExceptionType> { \
static const char* string() { \
return "[ " #statusCode " ]"; \
} \
}; \
}
/// @endcond
@ -392,13 +395,13 @@ namespace details {
/**
* @brief Rethrow a copy of exception. UShould be used in catch blocks
*/
[[noreturn]] INFERENCE_ENGINE_API_CPP(void) Rethrow();
[[noreturn]] INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CPP(void) Rethrow();
/**
* @brief Tag struct used to throw exception
*/
template <typename ExceptionType>
struct ThrowNow final {
struct INFERENCE_ENGINE_1_0_DEPRECATED ThrowNow final {
[[noreturn]] void operator<<=(const std::ostream& ostream) {
std::ostringstream stream;
stream << ostream.rdbuf();
@ -510,3 +513,4 @@ struct NullStream {
#else
# define __PRETTY_FUNCTION__ __PRETTY_FUNCTION__
#endif
IE_SUPPRESS_DEPRECATED_END

View File

@ -9,6 +9,16 @@
*/
#pragma once
#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED)
# define IE_LEGACY_HEADER_INCLUDED
# ifdef _MSC_VER
# pragma message( \
"The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# else
# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# endif
#endif
#include <initializer_list>
#include <memory>
#include <vector>
@ -23,7 +33,7 @@ namespace InferenceEngine {
* Compound blob is a wrapper blob over references to underlying blobs. These blobs should share
* some properties and can be grouped into a single entity.
*/
class INFERENCE_ENGINE_API_CLASS(CompoundBlob) : public Blob {
class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(CompoundBlob) : public Blob {
public:
/**
* @brief A smart pointer to the CompoundBlob object
@ -116,168 +126,12 @@ protected:
const std::shared_ptr<IAllocator>& getAllocator() const noexcept override;
};
/**
* @brief Represents a blob that contains two planes (Y and UV) in NV12 color format
*/
class INFERENCE_ENGINE_DEPRECATED("This class is deprecated and will be removed in 2023.1 release")
INFERENCE_ENGINE_API_CLASS(NV12Blob)
: public CompoundBlob {
public:
/**
* @brief A smart pointer to the NV12Blob object
*/
using Ptr = std::shared_ptr<NV12Blob>;
/**
* @brief A smart pointer to the const NV12Blob object
*/
using CPtr = std::shared_ptr<const NV12Blob>;
/**
* @brief Constructs NV12 blob from two planes Y and UV
*
* @param y Blob object that represents Y plane in NV12 color format
* @param uv Blob object that represents UV plane in NV12 color format
*/
NV12Blob(const Blob::Ptr& y, const Blob::Ptr& uv);
/**
* @brief Constructs NV12 blob from two planes Y and UV
*
* @param y Blob object that represents Y plane in NV12 color format
* @param uv Blob object that represents UV plane in NV12 color format
*/
NV12Blob(Blob::Ptr&& y, Blob::Ptr&& uv);
/**
* @brief Returns a shared pointer to Y plane
* @return Y plane
*/
virtual Blob::Ptr& y() noexcept;
/**
* @brief Returns a shared pointer to Y plane
* @return Y plane
*/
virtual const Blob::Ptr& y() const noexcept;
/**
* @brief Returns a shared pointer to UV plane
* @return UV plane
*/
virtual Blob::Ptr& uv() noexcept;
/**
* @brief Returns a shared pointer to UV plane
* @return UV plane
*/
virtual const Blob::Ptr& uv() const noexcept;
Blob::Ptr createROI(const ROI& roi) const override;
};
/**
* @brief Represents a blob that contains three planes (Y,U and V) in I420 color format
*/
class INFERENCE_ENGINE_DEPRECATED("This class is deprecated and will be removed in 2023.1 release")
INFERENCE_ENGINE_API_CLASS(I420Blob)
: public CompoundBlob {
public:
/**
* @brief A smart pointer to the I420Blob object
*/
using Ptr = std::shared_ptr<I420Blob>;
/**
* @brief A smart pointer to the const I420Blob object
*/
using CPtr = std::shared_ptr<const I420Blob>;
/**
* @brief Constructs I420 blob from three planes Y, U and V
* @param y Blob object that represents Y plane in I420 color format
* @param u Blob object that represents U plane in I420 color format
* @param v Blob object that represents V plane in I420 color format
*/
I420Blob(const Blob::Ptr& y, const Blob::Ptr& u, const Blob::Ptr& v);
/**
* @brief Constructs I420 blob from three planes Y, U and V
* @param y Blob object that represents Y plane in I420 color format
* @param u Blob object that represents U plane in I420 color format
* @param v Blob object that represents V plane in I420 color format
*/
I420Blob(Blob::Ptr&& y, Blob::Ptr&& u, Blob::Ptr&& v);
/**
* @brief Returns a reference to shared pointer to Y plane
*
* Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
* the I420Blob object is destroyed.
*
* @return reference to shared pointer object of Y plane
*/
Blob::Ptr& y() noexcept;
/**
* @brief Returns a constant reference to shared pointer to Y plane
*
* Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
* the I420Blob object is destroyed.
*
* @return constant reference to shared pointer object of Y plane*
*/
const Blob::Ptr& y() const noexcept;
/**
* @brief Returns a reference to shared pointer to U plane
*
* Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
* the I420Blob object is destroyed.
*
* @return reference to shared pointer object of U plane
*/
Blob::Ptr& u() noexcept;
/**
* @brief Returns a constant reference to shared pointer to U plane
*
* Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
* the I420Blob object is destroyed.
*
* @return constant reference to shared pointer object of U plane
*/
const Blob::Ptr& u() const noexcept;
/**
* @brief Returns a reference to shared pointer to V plane
*
* Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
* the I420Blob object is destroyed.
*
* @return reference to shared pointer object of V plane
*/
Blob::Ptr& v() noexcept;
/**
* @brief Returns a constant reference to shared pointer to V plane
*
* Please note that reference to Blob::Ptr is returned. I.e. the reference will be valid until
* the I420Blob object is destroyed.
*
* @return constant reference to shared pointer object of V plane
*/
const Blob::Ptr& v() const noexcept;
Blob::Ptr createROI(const ROI& roi) const override;
};
/**
* @brief This class represents a blob that contains other blobs - one per batch
* @details Plugin which supports BatchedBlob input should report BATCHED_BLOB
* in the OPTIMIZATION_CAPABILITIES metric.
*/
class INFERENCE_ENGINE_API_CLASS(BatchedBlob) : public CompoundBlob {
class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(BatchedBlob) : public CompoundBlob {
public:
/**
* @brief A smart pointer to the BatchedBlob object

View File

@ -10,6 +10,16 @@
*/
#pragma once
#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED)
# define IE_LEGACY_HEADER_INCLUDED
# ifdef _MSC_VER
# pragma message( \
"The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# else
# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# endif
#endif
#include <memory>
#include <vector>
@ -21,7 +31,7 @@ IE_SUPPRESS_DEPRECATED_START
/**
* @brief This structure stores info about pre-processing of network inputs (scale, mean image, ...)
*/
struct PreProcessChannel {
struct INFERENCE_ENGINE_1_0_DEPRECATED PreProcessChannel {
/** @brief Scale parameter for a channel */
float stdScale = 1;
@ -38,7 +48,7 @@ struct PreProcessChannel {
/**
* @brief Defines available types of mean
*/
enum MeanVariant {
enum INFERENCE_ENGINE_1_0_DEPRECATED MeanVariant {
MEAN_IMAGE, /**< mean value is specified for each input pixel */
MEAN_VALUE, /**< mean value is specified for each input channel */
NONE, /**< no mean value specified */
@ -48,12 +58,12 @@ enum MeanVariant {
* @enum ResizeAlgorithm
* @brief Represents the list of supported resize algorithms.
*/
enum ResizeAlgorithm { NO_RESIZE = 0, RESIZE_BILINEAR, RESIZE_AREA };
enum INFERENCE_ENGINE_1_0_DEPRECATED ResizeAlgorithm { NO_RESIZE = 0, RESIZE_BILINEAR, RESIZE_AREA };
/**
* @brief This class stores pre-process information for the input
*/
class PreProcessInfo {
class INFERENCE_ENGINE_1_0_DEPRECATED PreProcessInfo {
// Channel data
std::vector<PreProcessChannel::Ptr> _channelsInfo;
MeanVariant _variant = NONE;

View File

@ -10,6 +10,16 @@
#pragma once
#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED)
# define IE_LEGACY_HEADER_INCLUDED
# ifdef _MSC_VER
# pragma message( \
"The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# else
# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# endif
#endif
#include "cpp/ie_cnn_network.h"
#include "ie_api.h"
@ -42,5 +52,6 @@ namespace InferenceEngine {
If "false, then the transformation leaves existed initializing subgraph for ReadValue operation.
* Loop operation by a given number. Does not affect TensorIterators.
*/
INFERENCE_ENGINE_API_CPP(void) lowLatency2(InferenceEngine::CNNNetwork& network, bool use_const_initializer = true);
INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CPP(void)
lowLatency2(InferenceEngine::CNNNetwork& network, bool use_const_initializer = true);
} // namespace InferenceEngine

View File

@ -9,6 +9,16 @@
*/
#pragma once
#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED)
# define IE_LEGACY_HEADER_INCLUDED
# ifdef _MSC_VER
# pragma message( \
"The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# else
# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# endif
#endif
/**
* @def IE_VERSION_MAJOR
* @brief Defines Inference Engine major version
@ -30,19 +40,20 @@
* @brief Inference Engine C++ API
*/
namespace InferenceEngine {
IE_SUPPRESS_DEPRECATED_START
/**
* @struct Version
* @brief Represents version information that describes plugins and the inference engine runtime library
*/
#pragma pack(push, 1)
struct Version {
struct INFERENCE_ENGINE_1_0_DEPRECATED Version {
IE_SUPPRESS_DEPRECATED_START
/**
* @deprecated Use IE_VERSION_[MAJOR|MINOR|PATCH] definitions, buildNumber property
* @brief An API version reflects the set of supported features
*/
struct ApiVersion {
struct INFERENCE_ENGINE_1_0_DEPRECATED ApiVersion {
INFERENCE_ENGINE_DEPRECATED("Use IE_VERSION_[MAJOR|MINOR|PATCH] definitions, buildNumber property")
int major; //!< A major version
INFERENCE_ENGINE_DEPRECATED("Use IE_VERSION_[MAJOR|MINOR|PATCH] definitions, buildNumber property")
@ -112,4 +123,5 @@ struct Version {
*/
INFERENCE_ENGINE_API(const Version*) GetInferenceEngineVersion() noexcept;
IE_SUPPRESS_DEPRECATED_END
} // namespace InferenceEngine

View File

@ -8,6 +8,16 @@
*/
#pragma once
#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED)
# define IE_LEGACY_HEADER_INCLUDED
# ifdef _MSC_VER
# pragma message( \
"The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# else
# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
# endif
#endif
#include "ie_compound_blob.h"
#include "ie_core.hpp"
#include "ie_transformations.hpp"

View File

@ -59,6 +59,7 @@ void VariableState::SetState(Blob::Ptr state) {
} // namespace InferenceEngine
IE_SUPPRESS_DEPRECATED_END
namespace ov {
VariableState::~VariableState() {

View File

@ -4,6 +4,7 @@
#include <cpp_interfaces/interface/ie_ivariable_state_internal.hpp>
IE_SUPPRESS_DEPRECATED_START
namespace InferenceEngine {
IVariableStateInternal::IVariableStateInternal(const std::string& name_) : name{name_} {}

View File

@ -19,6 +19,7 @@
#include <sys/stat.h>
#include "ie_common.h"
#include "openvino/core/except.hpp"
#include "openvino/util/file_util.hpp"
#ifndef _WIN32
@ -77,7 +78,7 @@ std::string getIELibraryPathA() {
if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPSTR>(getIELibraryPath),
&hm)) {
IE_THROW() << "GetModuleHandle returned " << GetLastError();
OPENVINO_THROW("GetModuleHandle returned ", GetLastError());
}
GetModuleFileNameA(hm, (LPSTR)ie_library_path, sizeof(ie_library_path));
return getPathName(std::string(ie_library_path));
@ -119,7 +120,7 @@ std::wstring getIELibraryPathW() {
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCWSTR>(getIELibraryPath),
&hm)) {
IE_THROW() << "GetModuleHandle returned " << GetLastError();
OPENVINO_THROW("GetModuleHandle returned ", GetLastError());
}
GetModuleFileNameW(hm, (LPWSTR)ie_library_path, sizeof(ie_library_path) / sizeof(ie_library_path[0]));
return getPathName(std::wstring(ie_library_path));

View File

@ -19,196 +19,7 @@ namespace InferenceEngine {
namespace {
TensorDesc verifyNV12BlobInput(const Blob::Ptr& y, const Blob::Ptr& uv) {
// Y and UV must be valid pointers
if (y == nullptr || uv == nullptr) {
IE_THROW() << "Y and UV planes must be valid Blob objects";
}
// both Y and UV must be MemoryBlob objects
if (!y->is<MemoryBlob>() || !uv->is<MemoryBlob>()) {
IE_THROW() << "Y and UV planes must be MemoryBlob objects";
}
// NOTE: having Blob::Ptr (shared_ptr) and checking Blob::is() status above ensures that the
// cast is always successful
auto yMemoryBlob = y->as<MemoryBlob>();
auto uvMemoryBlob = uv->as<MemoryBlob>();
// check Blob element size
if (yMemoryBlob->element_size() != uvMemoryBlob->element_size()) {
IE_THROW() << "Y and UV planes have different element sizes: " << yMemoryBlob->element_size()
<< " != " << uvMemoryBlob->element_size();
}
// check tensor descriptor parameters
const auto& yDesc = yMemoryBlob->getTensorDesc();
const auto& uvDesc = uvMemoryBlob->getTensorDesc();
// check precision
if (yDesc.getPrecision() != Precision::U8) {
IE_THROW() << "Y plane precision must be U8, actual: " << yDesc.getPrecision();
}
if (uvDesc.getPrecision() != Precision::U8) {
IE_THROW() << "UV plane precision must be U8, actual: " << uvDesc.getPrecision();
}
// check layout
if (yDesc.getLayout() != Layout::NHWC) {
IE_THROW() << "Y plane layout must be NHWC, actual: " << yDesc.getLayout();
}
if (uvDesc.getLayout() != Layout::NHWC) {
IE_THROW() << "UV plane layout must be NHWC, actual: " << uvDesc.getLayout();
}
// check dimensions
const auto& yDims = yDesc.getDims();
const auto& uvDims = uvDesc.getDims();
if (yDims.size() != 4 || uvDims.size() != 4) {
IE_THROW() << "Y and UV planes dimension sizes must be 4, actual: " << yDims.size() << "(Y plane) and "
<< uvDims.size() << "(UV plane)";
}
// check batch size
if (yDims[0] != uvDims[0]) {
IE_THROW() << "Y and UV planes must have the same batch size";
}
// check number of channels
if (yDims[1] != 1) {
IE_THROW() << "Y plane must have 1 channel, actual: " << yDims[1];
}
if (uvDims[1] != 2) {
IE_THROW() << "UV plane must have 2 channels, actual: " << uvDims[1];
}
// check height
if (yDims[2] != 2 * uvDims[2]) {
IE_THROW() << "The height of the Y plane must be equal to (2 * the height of the UV plane), actual: "
<< yDims[2] << "(Y plane) and " << uvDims[2] << "(UV plane)";
}
// check width
if (yDims[3] != 2 * uvDims[3]) {
IE_THROW() << "The width of the Y plane must be equal to (2 * the width of the UV plane), actual: " << yDims[3]
<< "(Y plane) and " << uvDims[3] << "(UV plane)";
}
return {Precision::U8, {}, Layout::NCHW};
}
TensorDesc verifyI420BlobInput(const Blob::Ptr& y, const Blob::Ptr& u, const Blob::Ptr& v) {
// Y and UV must be valid pointers
if (y == nullptr || u == nullptr || v == nullptr) {
IE_THROW() << "Y, U and V planes must be valid Blob objects";
}
// both Y and UV must be MemoryBlob objects
if (!y->is<MemoryBlob>() || !u->is<MemoryBlob>() || !v->is<MemoryBlob>()) {
IE_THROW() << "Y, U and V planes must be MemoryBlob objects";
}
// NOTE: having Blob::Ptr (shared_ptr) and checking Blob::is() status above ensures that the
// cast is always successful
auto yMemoryBlob = y->as<MemoryBlob>();
auto uMemoryBlob = u->as<MemoryBlob>();
auto vMemoryBlob = v->as<MemoryBlob>();
// check Blob element size
if (yMemoryBlob->element_size() != uMemoryBlob->element_size() ||
yMemoryBlob->element_size() != vMemoryBlob->element_size()) {
IE_THROW() << "Y and UV planes have different element sizes: " << yMemoryBlob->element_size()
<< " != " << uMemoryBlob->element_size() << " != " << vMemoryBlob->element_size();
}
// check tensor descriptor parameters
const auto& yDesc = yMemoryBlob->getTensorDesc();
const auto& uDesc = uMemoryBlob->getTensorDesc();
const auto& vDesc = vMemoryBlob->getTensorDesc();
// check precision
if (yDesc.getPrecision() != Precision::U8) {
IE_THROW() << "Y plane precision must be U8, actual: " << yDesc.getPrecision();
}
if (uDesc.getPrecision() != Precision::U8) {
IE_THROW() << "U plane precision must be U8, actual: " << uDesc.getPrecision();
}
if (vDesc.getPrecision() != Precision::U8) {
IE_THROW() << "V plane precision must be U8, actual: " << vDesc.getPrecision();
}
// check layout
if (yDesc.getLayout() != Layout::NHWC) {
IE_THROW() << "Y plane layout must be NHWC, actual: " << yDesc.getLayout();
}
if (uDesc.getLayout() != Layout::NHWC) {
IE_THROW() << "U plane layout must be NHWC, actual: " << uDesc.getLayout();
}
if (uDesc.getLayout() != Layout::NHWC) {
IE_THROW() << "V plane layout must be NHWC, actual: " << vDesc.getLayout();
}
// check dimensions
const auto& yDims = yDesc.getDims();
const auto& uDims = uDesc.getDims();
const auto& vDims = vDesc.getDims();
if (yDims.size() != 4 || uDims.size() != 4 || vDims.size() != 4) {
IE_THROW() << "Y,U and V planes dimension sizes must be 4, actual: " << yDims.size() << "(Y plane) and "
<< uDims.size() << "(U plane) " << vDims.size() << "(V plane)";
}
// check batch size
if (yDims[0] != uDims[0] || yDims[0] != vDims[0]) {
IE_THROW() << "Y, U and U planes must have the same batch size";
}
// check number of channels
if (yDims[1] != 1) {
IE_THROW() << "Y plane must have 1 channel, actual: " << yDims[1];
}
if (uDims[1] != 1) {
IE_THROW() << "U plane must have 1 channel, actual: " << uDims[1];
}
if (vDims[1] != 1) {
IE_THROW() << "V plane must have 1 channel, actual: " << vDims[1];
}
// check height
if (yDims[2] != 2 * uDims[2]) {
IE_THROW() << "The height of the Y plane must be equal to (2 * the height of the U plane), actual: " << yDims[2]
<< "(Y plane) and " << uDims[2] << "(U plane)";
}
if (yDims[2] != 2 * vDims[2]) {
IE_THROW() << "The height of the Y plane must be equal to (2 * the height of the UV plane), actual: "
<< yDims[2] << "(Y plane) and " << vDims[2] << "(V plane)";
}
// check width
if (yDims[3] != 2 * uDims[3]) {
IE_THROW() << "The width of the Y plane must be equal to (2 * the width of the UV plane), actual: " << yDims[3]
<< "(Y plane) and " << uDims[3] << "(U plane)";
}
if (yDims[3] != 2 * vDims[3]) {
IE_THROW() << "The width of the Y plane must be equal to (2 * the width of the UV plane), actual: " << yDims[3]
<< "(Y plane) and " << vDims[3] << "(V plane)";
}
return {Precision::U8, {}, Layout::NCHW};
}
TensorDesc getBlobTensorDesc(const Blob::Ptr& blob) {
if (auto nv12 = dynamic_cast<NV12Blob*>(blob.get())) {
auto yDesc = nv12->y()->getTensorDesc();
yDesc.getDims()[1] += 2;
return yDesc;
}
if (auto i420 = dynamic_cast<I420Blob*>(blob.get())) {
auto yDesc = i420->y()->getTensorDesc();
yDesc.getDims()[1] += 2;
return yDesc;
}
return blob->getTensorDesc();
}
@ -361,100 +172,6 @@ const std::shared_ptr<IAllocator>& CompoundBlob::getAllocator() const noexcept {
return _allocator;
};
NV12Blob::NV12Blob(const Blob::Ptr& y, const Blob::Ptr& uv) : CompoundBlob(verifyNV12BlobInput(y, uv)) {
this->_blobs = {y, uv};
}
NV12Blob::NV12Blob(Blob::Ptr&& y, Blob::Ptr&& uv) : CompoundBlob(verifyNV12BlobInput(y, uv)) {
this->_blobs = {std::move(y), std::move(uv)};
}
Blob::Ptr& NV12Blob::y() noexcept {
// NOTE: Y plane is a memory blob, which is checked in the constructor
return _blobs[0];
}
const Blob::Ptr& NV12Blob::y() const noexcept {
// NOTE: Y plane is a memory blob, which is checked in the constructor
return _blobs[0];
}
Blob::Ptr& NV12Blob::uv() noexcept {
// NOTE: UV plane is a memory blob, which is checked in the constructor
return _blobs[1];
}
const Blob::Ptr& NV12Blob::uv() const noexcept {
// NOTE: UV plane is a memory blob, which is checked in the constructor
return _blobs[1];
}
Blob::Ptr NV12Blob::createROI(const ROI& roi) const {
auto yROI = roi;
yROI.sizeX += yROI.sizeX % 2;
yROI.sizeY += yROI.sizeY % 2;
const auto uvROI = ROI(yROI.id, yROI.posX / 2, yROI.posY / 2, yROI.sizeX / 2, yROI.sizeY / 2);
const auto yRoiBlob = y()->createROI(yROI);
const auto uvRoiBlob = uv()->createROI(uvROI);
return std::make_shared<NV12Blob>(yRoiBlob, uvRoiBlob);
}
I420Blob::I420Blob(const Blob::Ptr& y, const Blob::Ptr& u, const Blob::Ptr& v)
: CompoundBlob(verifyI420BlobInput(y, u, v)) {
this->_blobs = {y, u, v};
}
I420Blob::I420Blob(Blob::Ptr&& y, Blob::Ptr&& u, Blob::Ptr&& v) : CompoundBlob(verifyI420BlobInput(y, u, v)) {
this->_blobs = {std::move(y), std::move(u), std::move(v)};
}
Blob::Ptr& I420Blob::y() noexcept {
// NOTE: Y plane is a memory blob, which is checked in the constructor
return _blobs[0];
}
const Blob::Ptr& I420Blob::y() const noexcept {
// NOTE: Y plane is a memory blob, which is checked in the constructor
return _blobs[0];
}
Blob::Ptr& I420Blob::u() noexcept {
// NOTE: U plane is a memory blob, which is checked in the constructor
return _blobs[1];
}
const Blob::Ptr& I420Blob::u() const noexcept {
// NOTE: U plane is a memory blob, which is checked in the constructor
return _blobs[1];
}
Blob::Ptr& I420Blob::v() noexcept {
// NOTE: V plane is a memory blob, which is checked in the constructor
return _blobs[2];
}
const Blob::Ptr& I420Blob::v() const noexcept {
// NOTE: V plane is a memory blob, which is checked in the constructor
return _blobs[2];
}
Blob::Ptr I420Blob::createROI(const ROI& roi) const {
auto yROI = roi;
yROI.sizeX += yROI.sizeX % 2;
yROI.sizeY += yROI.sizeY % 2;
const auto uvROI = ROI(yROI.id, yROI.posX / 2, yROI.posY / 2, yROI.sizeX / 2, yROI.sizeY / 2);
const auto yRoiBlob = y()->createROI(yROI);
const auto uRoiBlob = u()->createROI(uvROI);
const auto vRoiBlob = v()->createROI(uvROI);
return std::make_shared<I420Blob>(yRoiBlob, uRoiBlob, vRoiBlob);
}
BatchedBlob::BatchedBlob(const std::vector<Blob::Ptr>& blobs) : CompoundBlob(verifyBatchedBlobInput(blobs)) {
this->_blobs = blobs;
}

View File

@ -4,6 +4,7 @@
#include "ie_version.hpp"
IE_SUPPRESS_DEPRECATED_START
namespace InferenceEngine {
const Version* GetInferenceEngineVersion() noexcept {

View File

@ -18,6 +18,7 @@
#define OV_INFER_REQ_CALL_STATEMENT(...) \
OPENVINO_ASSERT(_impl != nullptr, "InferRequest was not initialized."); \
OPENVINO_SUPPRESS_DEPRECATED_START \
try { \
__VA_ARGS__; \
} catch (const ::InferenceEngine::RequestBusy& ex) { \
@ -26,7 +27,8 @@
OPENVINO_THROW(ex.what()); \
} catch (...) { \
OPENVINO_THROW("Unexpected exception"); \
}
} \
OPENVINO_SUPPRESS_DEPRECATED_END
namespace {
@ -229,6 +231,7 @@ void InferRequest::start_async() {
void InferRequest::wait() {
OPENVINO_ASSERT(_impl != nullptr, "InferRequest was not initialized.");
OPENVINO_SUPPRESS_DEPRECATED_START
try {
_impl->wait();
} catch (const ov::Cancelled&) {
@ -240,10 +243,12 @@ void InferRequest::wait() {
} catch (...) {
OPENVINO_THROW("Unexpected exception");
}
OPENVINO_SUPPRESS_DEPRECATED_END
}
bool InferRequest::wait_for(const std::chrono::milliseconds timeout) {
OPENVINO_ASSERT(_impl != nullptr, "InferRequest was not initialized.");
OPENVINO_SUPPRESS_DEPRECATED_START
try {
return _impl->wait_for(timeout);
} catch (const ie::InferCancelled& e) {
@ -253,6 +258,7 @@ bool InferRequest::wait_for(const std::chrono::milliseconds timeout) {
} catch (...) {
OPENVINO_THROW("Unexpected exception");
}
OPENVINO_SUPPRESS_DEPRECATED_END
}
void InferRequest::set_callback(std::function<void(std::exception_ptr)> callback) {

View File

@ -10,6 +10,7 @@ using namespace std;
using namespace InferenceEngine;
IE_SUPPRESS_DEPRECATED_START
using ResponseBufferTests = ::testing::Test;
TEST_F(ResponseBufferTests, canCreateResponseMessage) {

View File

@ -48,9 +48,6 @@ public:
}
};
class NV12BlobTests : public CompoundBlobTests {};
class I420BlobTests : public CompoundBlobTests {};
TEST(BlobConversionTests, canWorkWithMemoryBlob) {
Blob::Ptr blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 3, 4, 4}, NCHW));
ASSERT_TRUE(blob->is<MemoryBlob>());
@ -246,177 +243,3 @@ TEST_F(CompoundBlobTests, compoundBlobHoldsValidDataWhenUnderlyingBlobIsDestroye
ASSERT_NE(nullptr, mb0);
EXPECT_EQ(stored_value, mb0->rmap().as<const uint8_t*>()[0]);
}
IE_SUPPRESS_DEPRECATED_START
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromNullptrBlobs) {
Blob::Ptr valid = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC));
EXPECT_THROW(make_shared_blob<NV12Blob>(valid, nullptr), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(nullptr, valid), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromCompoundBlobs) {
Blob::Ptr blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC));
auto cblob = make_shared_blob<CompoundBlob>(std::vector<Blob::Ptr>({blob}));
EXPECT_THROW(make_shared_blob<NV12Blob>(cblob, blob), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(blob, cblob), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromPlanesWithDifferentElementSize) {
Blob::Ptr blob_u8 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC));
Blob::Ptr blob_float = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 2, 2, 2}, NHWC));
EXPECT_THROW(make_shared_blob<NV12Blob>(blob_u8, blob_float), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromPlanesWithNonU8Precision) {
Blob::Ptr float_y_blob = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 1, 4, 4}, NHWC));
Blob::Ptr float_uv_blob = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 2, 2, 2}, NHWC));
EXPECT_THROW(make_shared_blob<NV12Blob>(float_y_blob, float_uv_blob), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromPlanesWithInconsistentBatchSize) {
Blob::Ptr y = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC));
Blob::Ptr uv = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {2, 2, 2, 2}, NHWC));
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromPlanesWithWrongChannelNumber) {
Blob::Ptr y = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC));
Blob::Ptr uv = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 2, 2}, NHWC));
EXPECT_THROW(make_shared_blob<NV12Blob>(y, y), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(uv, uv), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(uv, y), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromPlanesWithWrongWidthRatio) {
Blob::Ptr y = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 6}, NHWC));
Blob::Ptr uv0 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 1, 3}, NHWC));
Blob::Ptr uv1 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 5, 3}, NHWC));
Blob::Ptr uv2 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 6, 3}, NHWC));
Blob::Ptr uv3 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 8, 3}, NHWC));
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv0), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv1), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv2), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv3), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, cannotCreateNV12BlobFromPlanesWithWrongHeightRatio) {
Blob::Ptr y = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 6}, NHWC));
Blob::Ptr uv0 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 3, 1}, NHWC));
Blob::Ptr uv1 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 3, 5}, NHWC));
Blob::Ptr uv2 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 3, 6}, NHWC));
Blob::Ptr uv3 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 3, 8}, NHWC));
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv0), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv1), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv2), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<NV12Blob>(y, uv3), InferenceEngine::Exception);
}
TEST_F(NV12BlobTests, canCreateNV12BlobFromTwoPlanes) {
Blob::Ptr y_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC));
Blob::Ptr uv_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 3, 4}, NHWC));
NV12Blob::Ptr nv12_blob = make_shared_blob<NV12Blob>(y_blob, uv_blob);
verifyCompoundBlob(nv12_blob, {y_blob, uv_blob});
EXPECT_EQ(y_blob, nv12_blob->y());
EXPECT_EQ(uv_blob, nv12_blob->uv());
}
TEST_F(NV12BlobTests, canCreateNV12BlobFromTwoMovedPlanes) {
NV12Blob::Ptr nv12_blob =
make_shared_blob<NV12Blob>(make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC)),
make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 3, 4}, NHWC)));
verifyCompoundBlob(nv12_blob);
}
TEST_F(I420BlobTests, canCreateI420BlobFromThreePlanes) {
Blob::Ptr y_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC));
Blob::Ptr u_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
Blob::Ptr v_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
I420Blob::Ptr i420_blob = make_shared_blob<I420Blob>(y_blob, u_blob, v_blob);
verifyCompoundBlob(i420_blob, {y_blob, u_blob, v_blob});
EXPECT_EQ(y_blob, i420_blob->y());
EXPECT_EQ(u_blob, i420_blob->u());
EXPECT_EQ(v_blob, i420_blob->v());
}
TEST_F(I420BlobTests, canCreateI420BlobFromThreeMovedPlanes) {
I420Blob::Ptr i420_blob =
make_shared_blob<I420Blob>(make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC)),
make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC)),
make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC)));
verifyCompoundBlob(i420_blob);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromNullptrBlobs) {
Blob::Ptr valid = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC));
EXPECT_THROW(make_shared_blob<I420Blob>(valid, nullptr, nullptr), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<I420Blob>(nullptr, valid, nullptr), InferenceEngine::Exception);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromCompoundBlobs) {
Blob::Ptr y_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC));
Blob::Ptr u_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
Blob::Ptr v_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
auto make_cblob = [](Blob::Ptr const& b) {
return make_shared_blob<CompoundBlob>(std::vector<Blob::Ptr>({b}));
};
auto c_y_blob = make_cblob(y_blob);
auto c_u_blob = make_cblob(u_blob);
auto c_v_blob = make_cblob(v_blob);
using ie_exception_t = InferenceEngine::Exception;
EXPECT_THROW(make_shared_blob<I420Blob>(c_y_blob, u_blob, v_blob), ie_exception_t);
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, c_u_blob, v_blob), ie_exception_t);
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, u_blob, c_v_blob), ie_exception_t);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromPlanesWithDifferentElementSize) {
Blob::Ptr y_blob_u8 = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC));
Blob::Ptr u_blob_float = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 1, 2, 2}, NHWC));
Blob::Ptr v_blob_float = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 1, 2, 2}, NHWC));
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob_u8, u_blob_float, v_blob_float), InferenceEngine::Exception);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromPlanesWithNonU8Precision) {
Blob::Ptr y_blob_float = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 1, 4, 4}, NHWC));
Blob::Ptr u_blob_float = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 1, 2, 2}, NHWC));
Blob::Ptr v_blob_float = make_shared_blob<float>(TensorDesc(Precision::FP32, {1, 1, 2, 2}, NHWC));
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob_float, u_blob_float, v_blob_float), InferenceEngine::Exception);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromPlanesWithInconsistentBatchSize) {
Blob::Ptr y_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC));
Blob::Ptr u_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {2, 1, 3, 4}, NHWC));
Blob::Ptr v_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, u_blob, v_blob), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, v_blob, u_blob), InferenceEngine::Exception);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromPlanesWithWrongChannelNumber) {
Blob::Ptr y_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC));
Blob::Ptr u_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 2, 3, 4}, NHWC));
Blob::Ptr v_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, u_blob, v_blob), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, v_blob, u_blob), InferenceEngine::Exception);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromPlanesWithWrongWidthRatio) {
Blob::Ptr y_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC));
Blob::Ptr u_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 2}, NHWC));
Blob::Ptr v_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, u_blob, v_blob), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, v_blob, u_blob), InferenceEngine::Exception);
}
TEST_F(I420BlobTests, cannotCreateI420BlobFromPlanesWithWrongHeightRatio) {
Blob::Ptr y_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 6, 8}, NHWC));
Blob::Ptr u_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 2, 4}, NHWC));
Blob::Ptr v_blob = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {1, 1, 3, 4}, NHWC));
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, u_blob, v_blob), InferenceEngine::Exception);
EXPECT_THROW(make_shared_blob<I420Blob>(y_blob, v_blob, u_blob), InferenceEngine::Exception);
}

View File

@ -9,6 +9,8 @@
#include "ie_common.h"
IE_SUPPRESS_DEPRECATED_START
// tests/unit/inference_engine/exception_test.cpp
TEST(ExceptionTests, CanThrowUsingMacro) {

View File

@ -11,6 +11,8 @@
using Box = MemorySolver::Box;
IE_SUPPRESS_DEPRECATED_START
TEST(MemSolverTest, CanConstruct) {
{ // Empty vector<Box>
MemorySolver ms(std::vector<Box>{});

View File

@ -12,9 +12,6 @@ const std::vector<FuncTestUtils::BlobType> BlobTypes = {
FuncTestUtils::BlobType::Compound,
FuncTestUtils::BlobType::Batched,
FuncTestUtils::BlobType::Memory,
// FuncTestUtils::BlobType::Remote,
FuncTestUtils::BlobType::I420,
FuncTestUtils::BlobType::NV12
};
const std::map<std::string, std::string> cpuConfig{}; //nothing special

View File

@ -26,8 +26,6 @@ namespace {
const char fp32_suffix[] = "_fp32";
const char cannot_set_compound[] = "cannot set compound blob: supported only for input pre-processing";
const char wrong_nv12_blob[] = "NV12 input blob is expected for input with NV12 color format";
const char unsupported_batched_blob[] = "Batched input blob is expected to contain NV12 blobs";
const char str_input_not_allocated[] = "Input data was not allocated.";
const char str_output_not_allocated[] = "Output data was not allocated.";
const char str_host_mem_not_allocated[] = "Failed to allocate host memory.";
@ -103,13 +101,6 @@ inline void checkAlloc(const Blob::Ptr& blob, const std::string& err_str) {
}
}
NV12Blob *getNV12BlobOrException(BatchedBlob *batched_ptr, int idx) {
auto nv12_ptr = batched_ptr->getBlob(idx)->as<NV12Blob>();
if (nv12_ptr == nullptr)
IE_THROW(NotImplemented) << unsupported_batched_blob;
return nv12_ptr;
}
void checkInputBlob(const Blob::Ptr &blob,
const std::string &name,
const InputInfo::Ptr foundInput,
@ -120,34 +111,17 @@ void checkInputBlob(const Blob::Ptr &blob,
IE_THROW(NotAllocated) << str_input_not_allocated;
}
if (ColorFormat::NV12 == foundInput->getPreProcess().getColorFormat() &&
nv12_two_inputs) {
if (auto nv12_ptr = blob->as<NV12Blob>()) {
checkAlloc(nv12_ptr->y(), str_input_not_allocated);
checkAlloc(nv12_ptr->uv(), str_input_not_allocated);
} else if (auto batched_ptr = blob->as<BatchedBlob>()) {
for (size_t i = 0; i < batched_ptr->size(); i++) {
auto nv12_ptr = getNV12BlobOrException(batched_ptr, static_cast<int>(i));
checkAlloc(nv12_ptr->y(), str_input_not_allocated);
checkAlloc(nv12_ptr->uv(), str_input_not_allocated);
}
} else {
IE_THROW(ParameterMismatch) << wrong_nv12_blob;
}
SizeVector dims = foundInput->getTensorDesc().getDims();
} else {
SizeVector dims = foundInput->getTensorDesc().getDims();
size_t refSize = foundInput->getTensorDesc().getLayout() != SCALAR
? details::product(dims)
: 1;
size_t refSize = foundInput->getTensorDesc().getLayout() != SCALAR
? details::product(dims)
: 1;
if (refSize != blob->size()) {
IE_THROW() << strNotMatched + ": got " << blob->size() << " expecting " << refSize;
}
checkAlloc(blob, str_input_not_allocated);
if (refSize != blob->size()) {
IE_THROW() << strNotMatched + ": got " << blob->size() << " expecting " << refSize;
}
checkAlloc(blob, str_input_not_allocated);
}
void checkOutputBlob(const Blob::Ptr &blob,
@ -285,49 +259,6 @@ void InferRequestLegacy::SetBlob(const std::string& name, const Blob::Ptr& data)
_deviceInputs[name] = data;
_inputs[name] = data;
} else {
auto nv12_ptr = data->as<NV12Blob>();
auto batched_ptr = data->as<BatchedBlob>();
bool is_batched = batched_ptr != nullptr;
bool is_nv12 = nv12_ptr != nullptr;
auto expected_batch = is_batched ? static_cast<int>(desc.getDims()[0]) : 1;
if (ColorFormat::NV12 == foundInput->getPreProcess().getColorFormat() &&
m_graph->get_config().get_property(ov::intel_gpu::nv12_two_inputs)) {
// try extracting Y and UV remote blobs from it
// and put them into appropriate network inputs
// that should then go into biplanar NV12 reorder
if (is_nv12 || is_batched) {
auto num_blobs = is_batched ? static_cast<int>(batched_ptr->size()) : 1;
for (auto i = 0; i < expected_batch; i++) {
std::string y_name = name + "_Y" + std::to_string(i);
std::string uv_name = name + "_UV" + std::to_string(i);
if (is_batched) {
int idx = i < num_blobs ? i : static_cast<int>(num_blobs)-1;
nv12_ptr = getNV12BlobOrException(batched_ptr, idx);
}
auto y_ptr = nv12_ptr->y()->as<gpu::ClBlob>();
if (y_ptr) {
auto y_impl = getBlobImpl(y_ptr);
if (!y_impl->is_allocated()) {
y_impl->allocate();
}
_deviceInputs[y_name] = nv12_ptr->y();
is_remote = true;
}
auto uv_ptr = nv12_ptr->uv()->as<gpu::ClBlob>();
if (uv_ptr) {
auto uv_impl = getBlobImpl(uv_ptr);
if (!uv_impl->is_allocated()) {
uv_impl->allocate();
}
_deviceInputs[uv_name] = nv12_ptr->uv();
is_remote = true;
}
}
}
}
if (is_remote)
_inputs[name] = data;
}
@ -727,30 +658,8 @@ void InferRequestLegacy::enqueue() {
std::string inputName = item.first;
Blob::Ptr& inputBlob = item.second;
auto nv12_ptr = inputBlob->as<NV12Blob>();
auto batched_ptr = inputBlob->as<BatchedBlob>();
bool is_batched = batched_ptr != nullptr;
bool is_nv12 = nv12_ptr != nullptr;
if (is_nv12 || is_batched) {
int num_blobs = is_batched ? static_cast<int>(batched_ptr->size()) : 1;
int expected_batch = is_batched
? static_cast<int>(_networkInputs.at(inputName)->getTensorDesc().getDims()[0])
: 1;
for (auto i = 0; i < expected_batch; i++) {
std::string y_name = inputName + "_Y" + std::to_string(i);
std::string uv_name = inputName + "_UV" + std::to_string(i);
if (is_batched) {
int idx = i < num_blobs ? i : num_blobs - 1;
nv12_ptr = getNV12BlobOrException(batched_ptr, idx);
}
prepare_input(y_name, nv12_ptr->y(), dependencies);
prepare_input(uv_name, nv12_ptr->uv(), dependencies);
}
} else {
// regular blob
prepare_input(inputName, inputBlob, dependencies);
}
// regular blob
prepare_input(inputName, inputBlob, dependencies);
}
cldnn::network::variables_states_map variables_states;
@ -1012,8 +921,7 @@ void InferRequestLegacy::allocate_inputs() {
std::string name = ni.first;
const TensorDesc& desc = ni.second->getTensorDesc();
bool is_nv12_input = ColorFormat::NV12 == ni.second->getPreProcess().getColorFormat() &&
m_graph->get_config().get_property(ov::intel_gpu::nv12_two_inputs);
bool is_nv12_input = false;
auto parameter = std::find_if(_parameters.begin(), _parameters.end(), [&](const std::shared_ptr<const ov::Node>& node) {
return node->get_friendly_name() == name;

View File

@ -205,95 +205,33 @@ static void CreateParameterOp(Program& p, const std::shared_ptr<ngraph::op::v0::
p.inputLayouts.insert({ inputInfo->name(), networkInputLayout });
p.add_primitive(*op, cldnn::input_layout(inputName, networkInputLayout));
} else {
if (ColorFormat::NV12 == preProcess.getColorFormat() && p.get_config().get_property(ov::intel_gpu::nv12_two_inputs)) {
// for NV12, create two input layouts with reorder instead of one,
// and then would expect compound blob in inferRequest
if (InferenceEngine::Layout::NCHW != l &&
(InferenceEngine::Precision::I8 != ip || InferenceEngine::Precision::U8 != ip)) {
IE_THROW() << "Unsupported layout (" << l << ") or precision "
<< ip.name() << ") for NV12 input " + inputInfo->name();
}
int height = input_pshape[2].get_length();
int width = input_pshape[3].get_length();
size_t batch = input_pshape[0].get_length();
std::vector<cldnn::input_info> reorders;
auto preprocessPrimID = "reorder:" + inputName + Program::m_preProcessTag;
cldnn::layout inputLayout(networkInputLayout);
inputLayout.data_type = DataTypeFromPrecision(ip);
p.inputLayouts.insert({ inputInfo->name(), inputLayout });
for (size_t i = 0; i < batch; i++) {
auto preprocessPrimID = "reorder:" + inputName + std::to_string(i) + Program::m_preProcessTag;
std::string y_name = inputName + "_Y" + std::to_string(i);
std::string uv_name = inputName + "_UV" + std::to_string(i);
p.add_primitive(*op, cldnn::input_layout(inputName, inputLayout));
cldnn::layout y_layout(DataTypeFromPrecision(ip),
cldnn::format::nv12, { 1, 1, width, height });
cldnn::layout uv_layout(DataTypeFromPrecision(ip),
cldnn::format::nv12, { 1, 2, width / 2, height / 2 });
auto inputY = cldnn::input_layout(y_name, y_layout);
auto inputUV = cldnn::input_layout(uv_name, uv_layout);
p.add_primitive(*op, inputY);
p.inputLayouts.insert({ inputInfo->name() + "_Y" + std::to_string(i), y_layout });
p.add_primitive(*op, inputUV);
p.inputLayouts.insert({ inputInfo->name() + "_UV" + std::to_string(i), uv_layout });
switch (preProcess.getMeanVariant()) {
case NONE:
case MEAN_VALUE: {
p.add_primitive(*op, cldnn::reorder(preprocessPrimID,
cldnn::input_info(y_name),
cldnn::input_info(uv_name),
networkInputLayout,
meanValues,
cldnn::reorder_mean_mode::subtract), {inputName});
break;
}
case MEAN_IMAGE: {
p.add_primitive(*op, cldnn::reorder(preprocessPrimID,
cldnn::input_info(y_name),
cldnn::input_info(uv_name),
networkInputLayout,
meanBlobID,
cldnn::reorder_mean_mode::subtract), {inputName});
break;
}
default: IE_THROW(Unexpected) << "Invalid mean variant in input " + inputName;
break;
}
reorders.push_back(cldnn::input_info(preprocessPrimID));
}
if (input_pshape[0].get_length() > 1) {
auto concatPrimID = "concat:" + inputName + Program::m_preProcessTag;
p.add_primitive(*op, cldnn::concatenation(concatPrimID, reorders, 0));
}
} else {
auto preprocessPrimID = "reorder:" + inputName + Program::m_preProcessTag;
cldnn::layout inputLayout(networkInputLayout);
inputLayout.data_type = DataTypeFromPrecision(ip);
p.inputLayouts.insert({ inputInfo->name(), inputLayout });
p.add_primitive(*op, cldnn::input_layout(inputName, inputLayout));
switch (preProcess.getMeanVariant()) {
case NONE:
case MEAN_VALUE: {
p.add_primitive(*op, cldnn::reorder(preprocessPrimID,
cldnn::input_info(inputName),
networkInputLayout,
meanValues,
cldnn::reorder_mean_mode::subtract), {inputName});
break;
}
case MEAN_IMAGE: {
p.add_primitive(*op, cldnn::reorder(preprocessPrimID,
cldnn::input_info(inputName),
networkInputLayout,
meanBlobID,
cldnn::reorder_mean_mode::subtract), {inputName});
break;
}
default: IE_THROW() << "Invalid mean variant in input " << inputName;
break;
}
switch (preProcess.getMeanVariant()) {
case NONE:
case MEAN_VALUE: {
p.add_primitive(*op, cldnn::reorder(preprocessPrimID,
cldnn::input_info(inputName),
networkInputLayout,
meanValues,
cldnn::reorder_mean_mode::subtract), {inputName});
break;
}
case MEAN_IMAGE: {
p.add_primitive(*op, cldnn::reorder(preprocessPrimID,
cldnn::input_info(inputName),
networkInputLayout,
meanBlobID,
cldnn::reorder_mean_mode::subtract), {inputName});
break;
}
default: IE_THROW() << "Invalid mean variant in input " << inputName;
break;
}
}
}

View File

@ -567,132 +567,6 @@ protected:
std::vector<std::shared_ptr<ngraph::Function>> fn_ptrs;
};
TEST_P(BatchedBlob_Test, canInputNV12) {
#if defined(ANDROID)
GTEST_SKIP();
#endif
const int height = 16;
const int width = 16;
// ------------------------------------------------------
// Prepare input data
const InferenceEngine::TensorDesc y_plane_desc(InferenceEngine::Precision::U8, {1, 1, height, width},
InferenceEngine::Layout::NHWC);
const InferenceEngine::TensorDesc uv_plane_desc(InferenceEngine::Precision::U8, {1, 2, height / 2, width / 2},
InferenceEngine::Layout::NHWC);
std::vector<InferenceEngine::Blob::Ptr> fake_image_data_y;
std::vector<InferenceEngine::Blob::Ptr> fake_image_data_uv;
for (size_t i = 0; i < num_batch; i++) {
fake_image_data_y.push_back(FuncTestUtils::createAndFillBlob(y_plane_desc, 50, 0, 1, static_cast<int32_t>(i)));
fake_image_data_uv.push_back(FuncTestUtils::createAndFillBlob(uv_plane_desc, 256, 0, 1, static_cast<int32_t>(i)));
}
auto ie = InferenceEngine::Core();
// ------------------------------------------------------
// inference using remote blob with batch
auto fn_ptr_remote = ngraph::builder::subgraph::makeConvPoolRelu({num_batch, 3, height, width});
CNNNetwork net_remote(fn_ptr_remote);
net_remote.getInputsInfo().begin()->second->setLayout(Layout::NCHW);
net_remote.getInputsInfo().begin()->second->setPrecision(Precision::U8);
net_remote.getInputsInfo().begin()->second->getPreProcess().setColorFormat(ColorFormat::NV12);
/* XXX: is it correct to set KEY_CLDNN_NV12_TWO_INPUTS in case of remote blob? */
auto exec_net_b = ie.LoadNetwork(net_remote, CommonTestUtils::DEVICE_GPU,
{ { GPUConfigParams::KEY_GPU_NV12_TWO_INPUTS, PluginConfigParams::YES}, {ov::hint::inference_precision.name(), "f32"} });
auto inf_req_remote = exec_net_b.CreateInferRequest();
auto cldnn_context = exec_net_b.GetContext();
cl_context ctx = std::dynamic_pointer_cast<ClContext>(cldnn_context)->get();
auto ocl_instance = std::make_shared<OpenCL>(ctx);
cl_int err;
std::vector<cl_mem> nv12_image_plane_y, nv12_image_plane_uv;
std::vector<cl::Image2D> img_y, img_uv;
std::vector<Blob::Ptr> blob_remote;
for (size_t i = 0; i < num_batch; i++) {
cl_image_format image_format;
cl_image_desc image_desc = { 0 };
image_format.image_channel_order = CL_R;
image_format.image_channel_data_type = CL_UNORM_INT8;
image_desc.image_type = CL_MEM_OBJECT_IMAGE2D;
image_desc.image_width = width;
image_desc.image_height = height;
nv12_image_plane_y.push_back(clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err));
ASSERT_EQ(err, 0);
image_format.image_channel_order = CL_RG;
image_desc.image_width = width / 2;
image_desc.image_height = height / 2;
nv12_image_plane_uv.push_back(clCreateImage(ocl_instance->_context.get(), CL_MEM_READ_WRITE, &image_format, &image_desc, NULL, &err));
ASSERT_EQ(err, 0);
size_t origin[3] = { 0, 0, 0 };
size_t y_region[3] = { (size_t)width, (size_t)height, 1 };
size_t uv_region[3] = { (size_t)width / 2, (size_t)height / 2, 1 };
err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_y[i],
true, origin, y_region, 0, 0, fake_image_data_y[i]->buffer(), 0, NULL, NULL);
ASSERT_EQ(err, 0);
err = clEnqueueWriteImage(ocl_instance->_queue.get(), nv12_image_plane_uv[i],
true, origin, uv_region, 0, 0, fake_image_data_uv[i]->buffer(), 0, NULL, NULL);
ASSERT_EQ(err, 0);
img_y.push_back(cl::Image2D(nv12_image_plane_y[i]));
img_uv.push_back(cl::Image2D(nv12_image_plane_uv[i]));
blob_remote.push_back(make_shared_blob_nv12(cldnn_context, img_y[i], img_uv[i]));
}
if (num_batch == 1) {
inf_req_remote.SetBlob(net_remote.getInputsInfo().begin()->first, blob_remote[0]);
} else {
auto batched_blob = make_shared_blob<BatchedBlob>(blob_remote);
inf_req_remote.SetBlob(net_remote.getInputsInfo().begin()->first, batched_blob);
}
inf_req_remote.Infer();
auto outputBlob_shared = inf_req_remote.GetBlob(net_remote.getOutputsInfo().begin()->first);
// ------------------------------------------------------
// Setup to inference using local blob with batch=1
auto fn_ptr_local = ngraph::builder::subgraph::makeConvPoolRelu({1, 3, height, width});
CNNNetwork net_local(fn_ptr_local);
net_local.getInputsInfo().begin()->second->setLayout(Layout::NCHW);
net_local.getInputsInfo().begin()->second->setPrecision(Precision::U8);
net_local.getInputsInfo().begin()->second->getPreProcess().setColorFormat(ColorFormat::NV12);
auto exec_net_b1 = ie.LoadNetwork(net_local, CommonTestUtils::DEVICE_GPU, {{ov::hint::inference_precision.name(), "f32"}});
auto inf_req_local = exec_net_b1.CreateInferRequest();
// Run regular input for each image and compare against batched blob
for (size_t i = 0; i < num_batch; i++) {
auto y_blob = make_shared_blob<uint8_t>(y_plane_desc, fake_image_data_y[i]->buffer().as<uint8_t *>());
auto uv_blob = make_shared_blob<uint8_t>(uv_plane_desc, fake_image_data_uv[i]->buffer().as<uint8_t *>());
auto blob = make_shared_blob<NV12Blob>(y_blob, uv_blob);
inf_req_local.SetBlob(net_local.getInputsInfo().begin()->first, blob);
inf_req_local.Infer();
auto output_blob_local = inf_req_local.GetBlob(net_local.getOutputsInfo().begin()->first);
// This network generates [1, size] tensor whether batch=1 or 2. So need to split
auto split_shared_blob = make_shared_blob<float_t>(output_blob_local->getTensorDesc(),
outputBlob_shared->buffer().as<float_t *>() + output_blob_local->size() * i);
ASSERT_EQ(output_blob_local->size(), split_shared_blob->size());
float thr = 0.1f;
FuncTestUtils::compareBlobs(output_blob_local, split_shared_blob, thr, "", false);
}
}
const std::vector<size_t> num_batches{1, 2, 4};
INSTANTIATE_TEST_SUITE_P(smoke_RemoteBlob, BatchedBlob_Test, ::testing::ValuesIn(num_batches), BatchedBlob_Test::getTestCaseName);

View File

@ -228,71 +228,6 @@ TEST_F(DX11RemoteCtx_Test, smoke_make_shared_context) {
}
}
TEST_F(DX11CachedTexture_Test, smoke_make_shared_nv12_blob_cached) {
#if defined(ANDROID)
GTEST_SKIP();
#endif
using namespace InferenceEngine;
using namespace InferenceEngine::gpu;
auto ie = InferenceEngine::Core();
auto remote_context = make_shared_context(ie, CommonTestUtils::DEVICE_GPU,
device_ptr);
ASSERT_TRUE(remote_context);
const size_t total_run_number = 4;
for (size_t i = 0; i < total_run_number; i++) {
for (const auto& t : dx11_textures) {
auto blob = make_shared_blob_nv12(texture_description.Height,
texture_description.Width,
remote_context, t);
ASSERT_TRUE(blob);
ASSERT_NO_THROW(blob->allocate());
}
}
}
TEST_F(DX11CachedTexture_Test, _make_shared_nv12_blob_cached_inference) {
#if defined(ANDROID)
GTEST_SKIP();
#endif
using namespace InferenceEngine;
using namespace InferenceEngine::gpu;
// inference using remote blob with batch
auto fn_ptr_remote = ngraph::builder::subgraph::makeConvPoolRelu({1, 3, texture_description.Height, texture_description.Width});
auto ie = InferenceEngine::Core();
CNNNetwork net(fn_ptr_remote);
net.getInputsInfo().begin()->second->setLayout(Layout::NCHW);
net.getInputsInfo().begin()->second->setPrecision(Precision::U8);
net.getInputsInfo().begin()->second->getPreProcess().setColorFormat(ColorFormat::NV12);
auto remote_context = make_shared_context(ie, CommonTestUtils::DEVICE_GPU, device_ptr);
Blob::Ptr nv12_blob = make_shared_blob_nv12(texture_description.Height,
texture_description.Width,
remote_context, dx11_textures[0]);
ASSERT_TRUE(remote_context);
const size_t total_run_number = 4;
{
auto exec_net = ie.LoadNetwork(net, remote_context,
{ { GPUConfigParams::KEY_GPU_NV12_TWO_INPUTS, PluginConfigParams::YES} });
// inference using shared nv12 blob
auto inf_req_shared = exec_net.CreateInferRequest();
auto dims = net.getInputsInfo().begin()->second->getTensorDesc().getDims();
size_t imSize = dims[1] * dims[2] * dims[3];
const size_t iteration_count = 10;
for (size_t i = 0; i < iteration_count; i++) {
inf_req_shared.SetBlob(net.getInputsInfo().begin()->first, nv12_blob);
inf_req_shared.Infer();
auto outputBlob_shared = inf_req_shared.GetBlob(net.getOutputsInfo().begin()->first);
}
}
}
TEST_F(DX11CachedTexture_Test, smoke_make_shared_nv12_tensor_cached) {
#if defined(ANDROID)
GTEST_SKIP();

View File

@ -12,9 +12,6 @@ const std::vector<FuncTestUtils::BlobType> BlobTypes = {
FuncTestUtils::BlobType::Compound,
FuncTestUtils::BlobType::Batched,
FuncTestUtils::BlobType::Memory,
// FuncTestUtils::BlobType::Remote,
FuncTestUtils::BlobType::I420,
FuncTestUtils::BlobType::NV12
};
auto gpuConfig = []() {

View File

@ -14,8 +14,6 @@
#include "base_reference_cnn_test.hpp"
#include "ngraph_functions/builders.hpp"
#ifdef ENABLE_GAPI_PREPROCESSING
using namespace ov;
using namespace ov::preprocess;
using namespace reference_tests;
@ -170,155 +168,3 @@ TEST_F(ReferencePreprocessLegacyTest, rgbx_to_bgr) {
Exec();
}
class ConvertNV12WithLegacyTest: public ReferencePreprocessLegacyTest {
public:
// Create OV20 function with pre-processing + legacy network + reference NV12 inputs
void SetupAndExec(size_t height, size_t width, std::vector<uint8_t>& ov20_input_yuv) {
function = create_simple_function_yuv(Shape{1, 3, height, width});
auto f2 = create_simple_function_yuv(Shape{1, 3, height, width});
legacy_network = InferenceEngine::CNNNetwork(f2);
inputData.clear();
legacy_input_blobs.clear();
auto p = PrePostProcessor(function);
p.input().tensor().set_color_format(ColorFormat::NV12_SINGLE_PLANE);
p.input().preprocess().convert_color(ColorFormat::BGR);
p.input().model().set_layout("NCHW");
p.build();
const auto &param = function->get_parameters()[0];
inputData.emplace_back(param->get_element_type(), param->get_shape(), ov20_input_yuv.data());
// Legacy way
legacy_network.getInputsInfo().begin()->second->setLayout(InferenceEngine::Layout::NCHW);
legacy_network.getInputsInfo().begin()->second->setPrecision(InferenceEngine::Precision::U8);
auto &preProcess = legacy_network.getInputsInfo().begin()->second->getPreProcess();
preProcess.setColorFormat(InferenceEngine::NV12);
// Fill legacy blob
auto legacy_input_y = std::vector<uint8_t>(ov20_input_yuv.begin(),
ov20_input_yuv.begin() + ov20_input_yuv.size() * 2 / 3);
auto legacy_input_uv = std::vector<uint8_t>(ov20_input_yuv.begin() + ov20_input_yuv.size() * 2 / 3,
ov20_input_yuv.end());
const InferenceEngine::TensorDesc y_plane_desc(InferenceEngine::Precision::U8,
{1, 1, height, width},
InferenceEngine::Layout::NHWC);
const InferenceEngine::TensorDesc uv_plane_desc(InferenceEngine::Precision::U8,
{1, 2, height / 2, width / 2},
InferenceEngine::Layout::NHWC);
auto y_blob = InferenceEngine::make_shared_blob<uint8_t>(y_plane_desc, legacy_input_y.data());
auto uv_blob = InferenceEngine::make_shared_blob<uint8_t>(uv_plane_desc, legacy_input_uv.data());
legacy_input_blobs["input1"] = InferenceEngine::make_shared_blob<InferenceEngine::NV12Blob>(y_blob, uv_blob);
// Exec now
Exec();
}
void Validate() override {
threshold = 1.f;
abs_threshold = 1.f;
// No pixels with deviation of more than 1 color step
ReferencePreprocessLegacyTest::Validate();
// Less than 2% of deviations with 1 color step. 2% is experimental value
// For very precise (acceptable) float calculations - 1.4% deviation with G-API/OpenCV is observed
LayerTestsDefinitions::NV12TestUtils::ValidateColors(outputs_legacy[0].data<float>(),
outputs_ov20[0].data<float>(), outputs_legacy[0].get_size(), 0.02);
}
};
TEST_F(ConvertNV12WithLegacyTest, convert_nv12_full_color_range) {
size_t height = 128;
size_t width = 128;
int b_step = 5;
int b_dim = 255 / b_step + 1;
// Test various possible r/g/b values within dimensions
auto ov20_input_yuv = LayerTestsDefinitions::NV12TestUtils::color_test_image(height, width, b_step);
SetupAndExec(height * b_dim, width, ov20_input_yuv);
}
TEST_F(ConvertNV12WithLegacyTest, convert_nv12_colored) {
auto input_yuv = std::vector<uint8_t> {235, 81, 235, 81, 109, 184};
SetupAndExec(2, 2, input_yuv);
}
//------------ I420 Legacy tests --------------
class ConvertI420WithLegacyTest: public ReferencePreprocessLegacyTest {
public:
// Create OV20 function with pre-processing + legacy network + reference I420 inputs
void SetupAndExec(size_t height, size_t width, std::vector<uint8_t>& ov20_input_yuv) {
function = create_simple_function_yuv(Shape{1, 3, height, width});
auto f2 = create_simple_function_yuv(Shape{1, 3, height, width});
legacy_network = InferenceEngine::CNNNetwork(f2);
inputData.clear();
legacy_input_blobs.clear();
auto p = PrePostProcessor(function);
auto& input_info = p.input();
input_info.tensor().set_color_format(ColorFormat::I420_SINGLE_PLANE);
input_info.preprocess().convert_color(ColorFormat::BGR);
input_info.model().set_layout("NCHW");
function = p.build();
const auto &param = function->get_parameters()[0];
inputData.emplace_back(param->get_element_type(), param->get_shape(), ov20_input_yuv.data());
// Legacy way
legacy_network.getInputsInfo().begin()->second->setLayout(InferenceEngine::Layout::NCHW);
legacy_network.getInputsInfo().begin()->second->setPrecision(InferenceEngine::Precision::U8);
auto &preProcess = legacy_network.getInputsInfo().begin()->second->getPreProcess();
preProcess.setColorFormat(InferenceEngine::I420);
// Fill legacy blob
auto legacy_input_y = std::vector<uint8_t>(ov20_input_yuv.begin(),
ov20_input_yuv.begin() + ov20_input_yuv.size() * 2 / 3);
auto legacy_input_u = std::vector<uint8_t>(ov20_input_yuv.begin() + ov20_input_yuv.size() * 2 / 3,
ov20_input_yuv.begin() + ov20_input_yuv.size() * 5 / 6);
auto legacy_input_v = std::vector<uint8_t>(ov20_input_yuv.begin() + ov20_input_yuv.size() * 5 / 6,
ov20_input_yuv.end());
const InferenceEngine::TensorDesc y_plane_desc(InferenceEngine::Precision::U8,
{1, 1, height, width},
InferenceEngine::Layout::NHWC);
const InferenceEngine::TensorDesc uv_plane_desc(InferenceEngine::Precision::U8,
{1, 1, height / 2, width / 2},
InferenceEngine::Layout::NHWC);
auto y_blob = InferenceEngine::make_shared_blob<uint8_t>(y_plane_desc, legacy_input_y.data());
auto u_blob = InferenceEngine::make_shared_blob<uint8_t>(uv_plane_desc, legacy_input_u.data());
auto v_blob = InferenceEngine::make_shared_blob<uint8_t>(uv_plane_desc, legacy_input_v.data());
legacy_input_blobs["input1"] = InferenceEngine::make_shared_blob<InferenceEngine::I420Blob>(y_blob, u_blob, v_blob);
// Exec now
Exec();
}
void Validate() override {
threshold = 1.f;
abs_threshold = 1.f;
// No pixels with deviation of more than 1 color step
ReferencePreprocessLegacyTest::Validate();
// Less than 2% of deviations with 1 color step. 2% is experimental value
// For very precise (acceptable) float calculations - 1.4% deviation with G-API/OpenCV is observed
LayerTestsDefinitions::I420TestUtils::ValidateColors(outputs_legacy[0].data<float>(),
outputs_ov20[0].data<float>(), outputs_legacy[0].get_size(), 0.02);
}
};
TEST_F(ConvertI420WithLegacyTest, convert_i420_full_color_range) {
size_t height = 128;
size_t width = 128;
int b_step = 5;
int b_dim = 255 / b_step + 1;
// Test various possible r/g/b values within dimensions
auto ov20_input_yuv = LayerTestsDefinitions::I420TestUtils::color_test_image(height, width, b_step);
SetupAndExec(height * b_dim, width, ov20_input_yuv);
}
#endif // ENABLE_GAPI_PREPROCESSING

View File

@ -14,8 +14,6 @@ const std::vector<FuncTestUtils::BlobType> setBlobTypes = {
FuncTestUtils::BlobType::Batched,
FuncTestUtils::BlobType::Memory,
FuncTestUtils::BlobType::Remote,
FuncTestUtils::BlobType::I420,
FuncTestUtils::BlobType::NV12
};
INSTANTIATE_TEST_SUITE_P(ie_infer_request, InferRequestSetBlobByType,

View File

@ -53,9 +53,7 @@ protected:
case FuncTestUtils::BlobType::Memory:
return true;
case FuncTestUtils::BlobType::Compound:
case FuncTestUtils::BlobType::I420:
case FuncTestUtils::BlobType::Remote:
case FuncTestUtils::BlobType::NV12:
return false;
case FuncTestUtils::BlobType::Batched: {
auto supported_metrics = ie->GetMetric(target_device, METRIC_KEY(SUPPORTED_METRICS)).as<std::vector<std::string>>();

View File

@ -768,8 +768,6 @@ enum class BlobType {
Batched,
Compound,
Remote,
I420,
NV12,
};
inline std::ostream& operator<<(std::ostream& os, BlobType type) {
@ -782,10 +780,6 @@ inline std::ostream& operator<<(std::ostream& os, BlobType type) {
return os << "Compound";
case BlobType::Remote:
return os << "Remote";
case BlobType::I420:
return os << "I40";
case BlobType::NV12:
return os << "NV12";
default:
IE_THROW() << "Not supported blob type";
}
@ -811,30 +805,6 @@ inline InferenceEngine::Blob::Ptr createBlobByType(const InferenceEngine::Tensor
// TODO: ocl + remote
// case BlobType::Remote:
// return InferenceEngine::as<InferenceEngine::RemoteBlob>(createAndFillBlob(td));
case BlobType::I420: {
InferenceEngine::SizeVector dims = td.getDims();
dims[1] = 1;
InferenceEngine::TensorDesc td1(InferenceEngine::Precision::U8, dims, InferenceEngine::Layout::NHWC);
InferenceEngine::Blob::Ptr y_blob = createAndFillBlob(td1);
dims[2] /= 2;
dims[3] /= 2;
td1 = InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::Layout::NHWC);
InferenceEngine::Blob::Ptr u_blob = createAndFillBlob(td1);
InferenceEngine::Blob::Ptr v_blob = createAndFillBlob(td1);
return InferenceEngine::make_shared_blob<InferenceEngine::I420Blob>(y_blob, u_blob, v_blob);
}
case BlobType::NV12: {
InferenceEngine::SizeVector dims = td.getDims();
dims[1] = 1;
InferenceEngine::TensorDesc td1(InferenceEngine::Precision::U8, dims, InferenceEngine::Layout::NHWC);
InferenceEngine::Blob::Ptr y_blob = createAndFillBlob(td1);
dims[1] = 2;
dims[2] /= 2;
dims[3] /= 2;
td1 = InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::Layout::NHWC);
InferenceEngine::Blob::Ptr uv_blob = createAndFillBlob(td1);
return InferenceEngine::make_shared_blob<InferenceEngine::NV12Blob>(y_blob, uv_blob);
}
default:
IE_THROW() << "Test does not support the blob kind";
}