From 25826bfe7dfd9c0f565596e53e206708c9fb9776 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Mon, 17 Apr 2023 18:13:43 +0400 Subject: [PATCH] Added deprecation of nv12 legacy API (#16982) * Added deprecation of nv12 legacy API * Added new files * Change macros * Suppress warnings for preprocessing * Suppress warnings in tests * Suppress warnings for Windows --- src/bindings/c/docs/api_overview.md | 3 - src/bindings/c/include/c_api/ie_c_api.h | 16 +++- .../c/include/openvino/c/deprecated.h | 91 +++++++++++++++++++ .../openvino/inference_engine/constants.pyx | 12 ++- .../preprocessing/src/ie_preprocess_gapi.cpp | 2 + .../include/ie/gpu/gpu_context_api_dx.hpp | 1 + .../include/ie/gpu/gpu_context_api_ocl.hpp | 1 + .../include/ie/gpu/gpu_context_api_va.hpp | 1 + src/inference/include/ie/ie_compound_blob.h | 8 +- src/inference/src/ie_compound_blob.cpp | 1 + .../tests/unit/ie_compound_blob_test.cpp | 1 + 11 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 src/bindings/c/include/openvino/c/deprecated.h diff --git a/src/bindings/c/docs/api_overview.md b/src/bindings/c/docs/api_overview.md index 073e6bf1dcc..a1e0b45e7a4 100644 --- a/src/bindings/c/docs/api_overview.md +++ b/src/bindings/c/docs/api_overview.md @@ -212,9 +212,6 @@ enum colorformat_e { ​ RGBX, ///< RGBX color format with X ignored during inference ​ BGRX, ///< BGRX color format with X ignored during inference - -​ NV12, ///< NV12 color format represented as compound Y+UV blob - }; ``` diff --git a/src/bindings/c/include/c_api/ie_c_api.h b/src/bindings/c/include/c_api/ie_c_api.h index 1ee41692d05..7f81a2ded42 100644 --- a/src/bindings/c/include/c_api/ie_c_api.h +++ b/src/bindings/c/include/c_api/ie_c_api.h @@ -25,6 +25,8 @@ #include #include +#include "openvino/c/deprecated.h" + #ifdef __cplusplus # define INFERENCE_ENGINE_C_API_EXTERN extern "C" #else @@ -216,8 +218,12 @@ typedef enum { 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, //!< NV12 color format represented as compound Y+UV blob - I420, //!< I420 color format represented as compound Y+U+V blob + NV12 OPENVINO_ENUM_DEPRECATED( + "This type is deprecated and will be removed in 2023.1 release"), //!< NV12 color format represented as + //!< compound Y+UV blob + I420 OPENVINO_ENUM_DEPRECATED( + "This type is deprecated and will be removed in 2023.1 release"), //!< I420 color format represented as + //!< compound Y+U+V blob } colorformat_e; /** @@ -1071,7 +1077,8 @@ ie_blob_make_memory_with_roi(const ie_blob_t* inputBlob, const roi_t* roi, ie_bl * @param nv12Blob A pointer to the newly created blob. * @return Status code of the operation: OK(0) for success. */ -INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) +INFERENCE_ENGINE_C_API(OPENVINO_DEPRECATED("This function is deprecated and will be removed in 2023.1 release") + IE_NODISCARD IEStatusCode) ie_blob_make_memory_nv12(const ie_blob_t* y, const ie_blob_t* uv, ie_blob_t** nv12Blob); /** @@ -1083,7 +1090,8 @@ ie_blob_make_memory_nv12(const ie_blob_t* y, const ie_blob_t* uv, ie_blob_t** nv * @param i420Blob A pointer to the newly created blob. * @return Status code of the operation: OK(0) for success. */ -INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) +INFERENCE_ENGINE_C_API(OPENVINO_DEPRECATED("This function is deprecated and will be removed in 2023.1 release") + IE_NODISCARD IEStatusCode) ie_blob_make_memory_i420(const ie_blob_t* y, const ie_blob_t* u, const ie_blob_t* v, ie_blob_t** i420Blob); /** diff --git a/src/bindings/c/include/openvino/c/deprecated.h b/src/bindings/c/include/openvino/c/deprecated.h new file mode 100644 index 00000000000..0ca04b53d15 --- /dev/null +++ b/src/bindings/c/include/openvino/c/deprecated.h @@ -0,0 +1,91 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @file openvino/c/deprecated.h + * Defines macros for API deprecation + **/ +#pragma once + +#ifdef OPENVINO_DEPRECATED +# undef OPENVINO_DEPRECATED +#endif + +#ifdef OPENVINO_ENUM_DEPRECATED +# undef OPENVINO_ENUM_DEPRECATED +#endif + +#ifdef OPENVINO_DO_PRAGMA +# undef OPENVINO_DO_PRAGMA +#endif + +#ifdef OPENVINO_SUPPRESS_DEPRECATED_START +# undef OPENVINO_SUPPRESS_DEPRECATED_START +#endif + +#ifdef OPENVINO_SUPPRESS_DEPRECATED_END +# undef OPENVINO_SUPPRESS_DEPRECATED_END +#endif + +// +// The OPENVINO_DEPRECATED macro can be used to deprecate a function declaration. For example: +// +// OPENVINO_DEPRECATED("replace with groxify"); +// void frobnicate() +// +// The macro will expand to a deprecation attribute supported by the compiler, +// so any use of `frobnicate` will produce a compiler warning. +// + +#if defined(_WIN32) +# define OPENVINO_DEPRECATED(msg) __declspec(deprecated(msg)) +# if __cplusplus >= 201402L +# define OPENVINO_ENUM_DEPRECATED(msg) [[deprecated(msg)]] +# else +# define OPENVINO_ENUM_DEPRECATED(msg) +# endif +#elif defined(__INTEL_COMPILER) +# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) +# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) +#elif defined(__GNUC__) +# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) +# if __GNUC__ < 6 && !defined(__clang__) +# define OPENVINO_ENUM_DEPRECATED(msg) +# else +# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) +# endif +#else +# define OPENVINO_DEPRECATED(msg) +# define OPENVINO_ENUM_DEPRECATED(msg) +#endif + +// Suppress warning "-Wdeprecated-declarations" / C4996 +#if defined(_MSC_VER) +# define OPENVINO_DO_PRAGMA(x) __pragma(x) +#elif defined(__GNUC__) +# define OPENVINO_DO_PRAGMA(x) _Pragma(# x) +#else +# define OPENVINO_DO_PRAGMA(x) +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(warning(push)) \ + OPENVINO_DO_PRAGMA(warning(disable : 4996)) +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) +#elif defined(__INTEL_COMPILER) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(warning(push)) \ + OPENVINO_DO_PRAGMA(warning(disable : 1478)) +OPENVINO_DO_PRAGMA(warning(disable : 1786)) +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) +#elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(GCC diagnostic push) \ + OPENVINO_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(GCC diagnostic pop) +#else +# define OPENVINO_SUPPRESS_DEPRECATED_START +# define OPENVINO_SUPPRESS_DEPRECATED_END +#endif diff --git a/src/bindings/python/src/compatibility/openvino/inference_engine/constants.pyx b/src/bindings/python/src/compatibility/openvino/inference_engine/constants.pyx index e193b0a76a6..d92660f0d17 100644 --- a/src/bindings/python/src/compatibility/openvino/inference_engine/constants.pyx +++ b/src/bindings/python/src/compatibility/openvino/inference_engine/constants.pyx @@ -66,13 +66,21 @@ class ResizeAlgorithm(Enum): class ColorFormat(Enum): + @classmethod + def _missing_(cls, value: object): + """Add deprecation warningt to Field2""" + if str(value) == "NV12": + print("Field name `NV12` for `ColorFormat` enum is deprecated and will be removed in 2023.1 release.") + return 5 + if str(value) == "I420": + print("Field name `I420` for `ColorFormat` enum is deprecated and will be removed in 2023.1 release.") + return 6 + return value RAW = 0 RGB = 1 BGR = 2 RGBX = 3 BGRX = 4 - NV12 = 5 - I420 = 6 cpdef enum StatusCode: diff --git a/src/common/preprocessing/src/ie_preprocess_gapi.cpp b/src/common/preprocessing/src/ie_preprocess_gapi.cpp index 636987da55d..95c7c4a3b52 100644 --- a/src/common/preprocessing/src/ie_preprocess_gapi.cpp +++ b/src/common/preprocessing/src/ie_preprocess_gapi.cpp @@ -28,6 +28,8 @@ #include // GFluidOutputRois +IE_SUPPRESS_DEPRECATED_START + namespace InferenceEngine { namespace { int get_cv_depth(const TensorDesc &ie_desc); diff --git a/src/inference/include/ie/gpu/gpu_context_api_dx.hpp b/src/inference/include/ie/gpu/gpu_context_api_dx.hpp index cb173bbf293..6992e5b24cb 100644 --- a/src/inference/include/ie/gpu/gpu_context_api_dx.hpp +++ b/src/inference/include/ie/gpu/gpu_context_api_dx.hpp @@ -129,6 +129,7 @@ public: * @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, diff --git a/src/inference/include/ie/gpu/gpu_context_api_ocl.hpp b/src/inference/include/ie/gpu/gpu_context_api_ocl.hpp index e644cb662d6..76b0c789481 100644 --- a/src/inference/include/ie/gpu/gpu_context_api_ocl.hpp +++ b/src/inference/include/ie/gpu/gpu_context_api_ocl.hpp @@ -230,6 +230,7 @@ public: * @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) { diff --git a/src/inference/include/ie/gpu/gpu_context_api_va.hpp b/src/inference/include/ie/gpu/gpu_context_api_va.hpp index dc19334b0fa..8c67588e977 100644 --- a/src/inference/include/ie/gpu/gpu_context_api_va.hpp +++ b/src/inference/include/ie/gpu/gpu_context_api_va.hpp @@ -100,6 +100,7 @@ public: * @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, diff --git a/src/inference/include/ie/ie_compound_blob.h b/src/inference/include/ie/ie_compound_blob.h index e76a6fa5fa1..74a216bfb1a 100644 --- a/src/inference/include/ie/ie_compound_blob.h +++ b/src/inference/include/ie/ie_compound_blob.h @@ -118,7 +118,9 @@ protected: /** * @brief Represents a blob that contains two planes (Y and UV) in NV12 color format */ -class INFERENCE_ENGINE_API_CLASS(NV12Blob) : public CompoundBlob { +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 @@ -176,7 +178,9 @@ public: /** * @brief Represents a blob that contains three planes (Y,U and V) in I420 color format */ -class INFERENCE_ENGINE_API_CLASS(I420Blob) : public CompoundBlob { +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 diff --git a/src/inference/src/ie_compound_blob.cpp b/src/inference/src/ie_compound_blob.cpp index 1ab5572685b..cb10f5d451a 100644 --- a/src/inference/src/ie_compound_blob.cpp +++ b/src/inference/src/ie_compound_blob.cpp @@ -14,6 +14,7 @@ #include #include +IE_SUPPRESS_DEPRECATED_START namespace InferenceEngine { namespace { diff --git a/src/inference/tests/unit/ie_compound_blob_test.cpp b/src/inference/tests/unit/ie_compound_blob_test.cpp index a14bdafcfca..17a4c91af52 100644 --- a/src/inference/tests/unit/ie_compound_blob_test.cpp +++ b/src/inference/tests/unit/ie_compound_blob_test.cpp @@ -245,6 +245,7 @@ TEST_F(CompoundBlobTests, compoundBlobHoldsValidDataWhenUnderlyingBlobIsDestroye EXPECT_EQ(stored_value, mb0->rmap().as()[0]); } +IE_SUPPRESS_DEPRECATED_START TEST_F(NV12BlobTests, cannotCreateNV12BlobFromNullptrBlobs) { Blob::Ptr valid = make_shared_blob(TensorDesc(Precision::U8, {1, 1, 4, 4}, NHWC)); EXPECT_THROW(make_shared_blob(valid, nullptr), InferenceEngine::Exception);