Skip to content

Commit 19926e2

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 76aff84 + 1620a1e commit 19926e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+323
-2889
lines changed

Diff for: cmake/OpenCVDetectInferenceEngine.cmake

+1-107
Original file line numberDiff line numberDiff line change
@@ -29,84 +29,10 @@ endif()
2929

3030
# ======================
3131

32-
macro(ocv_ie_find_extra_libraries find_prefix find_suffix)
33-
file(GLOB libraries "${INF_ENGINE_LIB_DIRS}/${find_prefix}inference_engine*${find_suffix}")
34-
foreach(full_path IN LISTS libraries)
35-
get_filename_component(library "${full_path}" NAME_WE)
36-
string(REPLACE "${find_prefix}" "" library "${library}")
37-
if(library STREQUAL "inference_engine" OR library STREQUAL "inference_engined")
38-
# skip
39-
else()
40-
add_library(${library} UNKNOWN IMPORTED)
41-
set_target_properties(${library} PROPERTIES
42-
IMPORTED_LOCATION "${full_path}")
43-
list(APPEND custom_libraries ${library})
44-
endif()
45-
endforeach()
46-
endmacro()
47-
48-
function(add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg)
49-
if(NOT _inc OR NOT (_lib OR _lib_rel OR _lib_dbg))
50-
return()
51-
endif()
52-
if(NOT _lib)
53-
if(_lib_rel)
54-
set(_lib "${_lib_rel}")
55-
else()
56-
set(_lib "${_lib_dbg}")
57-
endif()
58-
endif()
59-
add_library(inference_engine UNKNOWN IMPORTED)
60-
set_target_properties(inference_engine PROPERTIES
61-
IMPORTED_LOCATION "${_lib}"
62-
IMPORTED_IMPLIB_RELEASE "${_lib_rel}"
63-
IMPORTED_IMPLIB_DEBUG "${_lib_dbg}"
64-
INTERFACE_INCLUDE_DIRECTORIES "${_inc}"
65-
)
66-
67-
set(custom_libraries "")
68-
set(__prefixes "${CMAKE_FIND_LIBRARY_PREFIXES}")
69-
if(NOT __prefixes)
70-
set(__prefixes "_empty_")
71-
endif()
72-
foreach(find_prefix ${__prefixes})
73-
if(find_prefix STREQUAL "_empty_") # foreach doesn't iterate over empty elements
74-
set(find_prefix "")
75-
endif()
76-
if(NOT DEFINED INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES) # allow custom override
77-
set(INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
78-
if(APPLE)
79-
ocv_list_filterout(INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES "^.so$") # skip plugins (can't be linked)
80-
endif()
81-
endif()
82-
foreach(find_suffix ${INFERENCE_ENGINE_FIND_LIBRARY_SUFFIXES})
83-
ocv_ie_find_extra_libraries("${find_prefix}" "${find_suffix}")
84-
endforeach()
85-
if(NOT CMAKE_FIND_LIBRARY_SUFFIXES)
86-
ocv_ie_find_extra_libraries("${find_prefix}" "")
87-
endif()
88-
endforeach()
89-
90-
if(NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000")
91-
find_library(INF_ENGINE_OMP_LIBRARY iomp5 PATHS "${INF_ENGINE_OMP_DIR}" NO_DEFAULT_PATH)
92-
if(NOT INF_ENGINE_OMP_LIBRARY)
93-
message(WARNING "OpenMP for IE have not been found. Set INF_ENGINE_OMP_DIR variable if you experience build errors.")
94-
endif()
95-
endif()
96-
if(EXISTS "${INF_ENGINE_OMP_LIBRARY}")
97-
set_target_properties(inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${INF_ENGINE_OMP_LIBRARY}")
98-
endif()
99-
set(INF_ENGINE_VERSION "Unknown" CACHE STRING "")
100-
set(INF_ENGINE_TARGET "inference_engine;${custom_libraries}" PARENT_SCOPE)
101-
message(STATUS "Detected InferenceEngine: ${_msg}")
102-
endfunction()
103-
104-
# ======================
105-
10632
find_package(InferenceEngine QUIET)
10733
if(InferenceEngine_FOUND)
10834
set(INF_ENGINE_TARGET ${InferenceEngine_LIBRARIES})
109-
set(INF_ENGINE_VERSION "${InferenceEngine_VERSION}" CACHE STRING "")
35+
set(INF_ENGINE_VERSION "${InferenceEngine_VERSION}")
11036
message(STATUS "Detected InferenceEngine: cmake package (${InferenceEngine_VERSION})")
11137
endif()
11238

@@ -124,38 +50,6 @@ elseif(DEFINED INF_ENGINE_RELEASE)
12450
endif()
12551
set(INF_ENGINE_RELEASE "${INF_ENGINE_RELEASE_INIT}" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
12652

127-
if(NOT INF_ENGINE_TARGET AND INF_ENGINE_LIB_DIRS AND INF_ENGINE_INCLUDE_DIRS)
128-
find_path(ie_custom_inc "inference_engine.hpp" PATHS "${INF_ENGINE_INCLUDE_DIRS}" NO_DEFAULT_PATH)
129-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
130-
find_library(ie_custom_lib_dbg "inference_engined" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH) # Win32 and MacOSX
131-
endif()
132-
find_library(ie_custom_lib "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH)
133-
find_library(ie_custom_lib_rel "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Release" NO_DEFAULT_PATH)
134-
find_library(ie_custom_lib_dbg "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Debug" NO_DEFAULT_PATH)
135-
add_custom_ie_build("${ie_custom_inc}" "${ie_custom_lib}" "${ie_custom_lib_rel}" "${ie_custom_lib_dbg}" "INF_ENGINE_{INCLUDE,LIB}_DIRS")
136-
endif()
137-
138-
set(_loc "$ENV{INTEL_OPENVINO_DIR}")
139-
if(NOT _loc AND DEFINED ENV{INTEL_CVSDK_DIR})
140-
set(_loc "$ENV{INTEL_CVSDK_DIR}") # OpenVINO 2018.x
141-
endif()
142-
if(NOT INF_ENGINE_TARGET AND _loc)
143-
if(NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000")
144-
set(INF_ENGINE_PLATFORM_DEFAULT "ubuntu_16.04")
145-
else()
146-
set(INF_ENGINE_PLATFORM_DEFAULT "")
147-
endif()
148-
set(INF_ENGINE_PLATFORM "${INF_ENGINE_PLATFORM_DEFAULT}" CACHE STRING "InferenceEngine platform (library dir)")
149-
find_path(ie_custom_env_inc "inference_engine.hpp" PATHS "${_loc}/deployment_tools/inference_engine/include" NO_DEFAULT_PATH)
150-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
151-
find_library(ie_custom_env_lib_dbg "inference_engined" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
152-
endif()
153-
find_library(ie_custom_env_lib "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
154-
find_library(ie_custom_env_lib_rel "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Release" NO_DEFAULT_PATH)
155-
find_library(ie_custom_env_lib_dbg "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Debug" NO_DEFAULT_PATH)
156-
add_custom_ie_build("${ie_custom_env_inc}" "${ie_custom_env_lib}" "${ie_custom_env_lib_rel}" "${ie_custom_env_lib_dbg}" "OpenVINO (${_loc})")
157-
endif()
158-
15953
set(tgts)
16054
set(defs)
16155

Diff for: modules/core/include/opencv2/core/persistence.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ class CV_EXPORTS_W FileStorage
309309
READ = 0, //!< value, open the file for reading
310310
WRITE = 1, //!< value, open the file for writing
311311
APPEND = 2, //!< value, open the file for appending
312-
MEMORY = 4, //!< flag, read data from source or write data to the internal buffer (which is
313-
//!< returned by FileStorage::release)
312+
MEMORY = 4, /**< flag, read data from source or write data to the internal buffer (which is
313+
returned by FileStorage::release) */
314314
FORMAT_MASK = (7<<3), //!< mask for format flags
315315
FORMAT_AUTO = 0, //!< flag, auto format
316316
FORMAT_XML = (1<<3), //!< flag, XML format

Diff for: modules/core/src/hal_internal.cpp

+16-9
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@
6464
#define HAL_LU_SMALL_MATRIX_THRESH 100
6565
#define HAL_CHOLESKY_SMALL_MATRIX_THRESH 100
6666

67+
#if defined(__clang__) && defined(__has_feature)
68+
#if __has_feature(memory_sanitizer)
69+
#define CV_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \
70+
__msan_unpoison(adresse, size)
71+
#endif
72+
#endif
73+
#ifndef CV_ANNOTATE_MEMORY_IS_INITIALIZED
74+
#define CV_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) do { } while(0)
75+
#endif
76+
6777
//lapack stores matrices in column-major order so transposing is needed everywhere
6878
template <typename fptype> static inline void
6979
transpose_square_inplace(fptype *src, size_t src_ld, size_t m)
@@ -239,20 +249,16 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype
239249
else if(typeid(fptype) == typeid(double))
240250
OCV_LAPACK_FUNC(dgesdd)(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)buffer, &lwork, iworkBuf, info);
241251

242-
#if defined(__clang__) && defined(__has_feature)
243-
#if __has_feature(memory_sanitizer)
244252
// Make sure MSAN sees the memory as having been written.
245253
// MSAN does not think it has been written because a different language was called.
246-
__msan_unpoison(a, a_step * n);
247-
__msan_unpoison(buffer, sizeof(fptype) * (lwork + 1));
254+
CV_ANNOTATE_MEMORY_IS_INITIALIZED(a, a_step * n);
255+
CV_ANNOTATE_MEMORY_IS_INITIALIZED(buffer, sizeof(fptype) * (lwork + 1));
248256
if (u)
249-
__msan_unpoison(u, u_step * m);
257+
CV_ANNOTATE_MEMORY_IS_INITIALIZED(u, u_step * m);
250258
if (vt)
251-
__msan_unpoison(vt, v_step * n);
259+
CV_ANNOTATE_MEMORY_IS_INITIALIZED(vt, v_step * n);
252260
if (w)
253-
__msan_unpoison(w, sizeof(fptype) * std::min(m, n));
254-
#endif // __has_feature(memory_sanitizer)
255-
#endif // defined(__clang__) && defined(__has_feature)
261+
CV_ANNOTATE_MEMORY_IS_INITIALIZED(w, sizeof(fptype) * std::min(m, n));
256262

257263
if(!(flags & CV_HAL_SVD_NO_UV))
258264
transpose_square_inplace(vt, ldv, n);
@@ -357,6 +363,7 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
357363
dgeqrf_(&m, &n, (double*)tmpA, &ldtmpA, (double*)dst, (double*)buffer, &lwork, info);
358364
}
359365

366+
CV_ANNOTATE_MEMORY_IS_INITIALIZED(info, sizeof(int));
360367
if (m == n)
361368
transpose_square_inplace(a, lda, m);
362369
else

Diff for: modules/dnn/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
165165
endif()
166166

167167
set(dnn_runtime_libs "")
168-
if(TARGET ocv.3rdparty.openvino)
168+
169+
ocv_option(OPENCV_DNN_OPENVINO "Build with OpenVINO support (2021.4+)" (TARGET ocv.3rdparty.openvino))
170+
if(TARGET ocv.3rdparty.openvino AND OPENCV_DNN_OPENVINO)
171+
if(NOT HAVE_OPENVINO AND NOT HAVE_NGRAPH)
172+
message(FATAL_ERROR "DNN: Inference Engine is not supported without enabled 'nGraph'. Check build configuration.")
173+
endif()
169174
list(APPEND dnn_runtime_libs ocv.3rdparty.openvino)
170175
endif()
171176

Diff for: modules/dnn/include/opencv2/dnn/dnn.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,6 @@ CV__DNN_INLINE_NS_BEGIN
302302
*/
303303
virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs);
304304

305-
virtual Ptr<BackendNode> initInfEngine(const std::vector<Ptr<BackendWrapper> > &inputs);
306-
307305
virtual Ptr<BackendNode> initNgraph(const std::vector<Ptr<BackendWrapper> > &inputs, const std::vector<Ptr<BackendNode> >& nodes);
308306

309307
virtual Ptr<BackendNode> initVkCom(const std::vector<Ptr<BackendWrapper> > &inputs);

Diff for: modules/dnn/include/opencv2/dnn/utils/inference_engine.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ CV__DNN_INLINE_NS_BEGIN
1515

1616

1717
/* Values for 'OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE' parameter */
18+
/// @deprecated
1819
#define CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API "NN_BUILDER"
20+
/// @deprecated
1921
#define CV_DNN_BACKEND_INFERENCE_ENGINE_NGRAPH "NGRAPH"
2022

2123
/** @brief Returns Inference Engine internal backend API.
2224
*
2325
* See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros.
2426
*
25-
* Default value is controlled through `OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE` runtime parameter (environment variable).
27+
* `OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE` runtime parameter (environment variable) is ignored since 4.6.0.
28+
*
29+
* @deprecated
2630
*/
2731
CV_EXPORTS_W cv::String getInferenceEngineBackendType();
2832

@@ -31,6 +35,8 @@ CV_EXPORTS_W cv::String getInferenceEngineBackendType();
3135
* See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros.
3236
*
3337
* @returns previous value of internal backend API
38+
*
39+
* @deprecated
3440
*/
3541
CV_EXPORTS_W cv::String setInferenceEngineBackendType(const cv::String& newBackendType);
3642

0 commit comments

Comments
 (0)