Changed sample's format_reader libraries type from dynamic to static (#15756)

This commit is contained in:
Ilya Lavrenov authored and GitHub committed 2023-02-17 09:30:19 +04:00
1 parent f48a67acc9
commit 672522492e
36 files changed
+81 -110

No files matched your search

@@ -6,7 +6,6 @@
#include "cpp_interfaces/interface/ie_iplugin_internal.hpp"
namespace {
@IE_PLUGINS_DECLARATIONS@
struct Value {
@@ -18,9 +17,7 @@ struct Value {
using Key = std::string;
using PluginsStaticRegistry = std::map<Key, Value>;
const std::map<Key, Value> getStaticPluginsRegistry() {
inline const std::map<Key, Value> getStaticPluginsRegistry() {
@IE_PLUGINS_MAP_DEFINITION@
return plugins_hpp;
}
} // namespace
+1 -1
View File
@@ -10,7 +10,7 @@ endif()
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
ie_add_compiler_flags(-Wno-unused-variable)
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
ie_add_compiler_flags(-Wno-unused-variable -Wno-unused-but-set-variable)
endif()
endif()
+1 -1
View File
@@ -8,7 +8,7 @@ add_subdirectory(c)
# used by tests_deprecated
if(TARGET format_reader)
install(TARGETS format_reader
RUNTIME DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL
ARCHIVE DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL
LIBRARY DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL)
endif()
+5
View File
@@ -0,0 +1,5 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
add_subdirectory(opencv_c_wrapper)
@@ -3,13 +3,16 @@
#
project(opencv_c_wrapper)
set(TARGET_NAME opencv_c_wrapper)
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
set(TARGET_NAME ${PROJECT_NAME})
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
# create library
add_library(${TARGET_NAME} SHARED ${HEADERS} ${SOURCES})
add_library(${TARGET_NAME} STATIC ${HEADERS} ${SOURCES})
# Find OpenCV components if exist
find_package(OpenCV QUIET COMPONENTS core imgproc imgcodecs)
@@ -21,16 +24,11 @@ endif()
target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCV_LIBRARIES})
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER c_samples)
if(COMMAND add_clang_format_target AND NOT IE_SAMPLE_EXCLUDE_CLANG_FORMAT)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
endif()
install(
TARGETS ${TARGET_NAME}
RUNTIME DESTINATION samples_bin/ COMPONENT samples_bin EXCLUDE_FROM_ALL
LIBRARY DESTINATION samples_bin/ COMPONENT samples_bin EXCLUDE_FROM_ALL
)
@@ -6,23 +6,7 @@
#include <stdio.h>
#ifdef __cplusplus
# define OPENCV_C_EXTERN extern "C"
#else
# define OPENCV_C_EXTERN
#endif
#if defined(__GNUC__) && (__GNUC__ < 4)
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __VA_ARGS__
#else
# if defined(_WIN32)
# ifdef opencv_c_wrapper_EXPORTS
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __declspec(dllexport) __VA_ARGS__ __cdecl
# else
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __declspec(dllimport) __VA_ARGS__ __cdecl
# endif
# else
# define OPENCV_C_WRAPPER(...) OPENCV_C_EXTERN __attribute__((visibility("default"))) __VA_ARGS__
# endif
extern "C" {
#endif
/**
@@ -65,7 +49,7 @@ typedef struct color {
* @param img A pointer to the newly created c_mat_t.
* @return Status of the operation: 0 for success, -1 for fail.
*/
OPENCV_C_WRAPPER(int) image_read(const char* img_path, c_mat_t* img);
int image_read(const char* img_path, c_mat_t* img);
/**
* @brief Resizes an image.
@@ -75,8 +59,7 @@ OPENCV_C_WRAPPER(int) image_read(const char* img_path, c_mat_t* img);
* @param height The height of dst_img.
* @return Status of the operation: 0 for success, -1 for fail.
*/
OPENCV_C_WRAPPER(int)
image_resize(const c_mat_t* src_img, c_mat_t* dst_img, const int width, const int height);
int image_resize(const c_mat_t* src_img, c_mat_t* dst_img, const int width, const int height);
/**
* @brief Saves an image to a specified file.The image format is chosen based on the filename
@@ -85,14 +68,14 @@ image_resize(const c_mat_t* src_img, c_mat_t* dst_img, const int width, const in
* @param img Image to be saved.
* @return Status of the operation: 0 for success, -1 for fail.
*/
OPENCV_C_WRAPPER(int) image_save(const char* img_path, c_mat_t* img);
int image_save(const char* img_path, c_mat_t* img);
/**
* @brief Releases memory occupied by a c_mat_t instance.
* @param img A pointer to the c_mat_t instance to free memory.
* @return Status of the operation: 0 for success, -1 for fail.
*/
OPENCV_C_WRAPPER(int) image_free(c_mat_t* img);
int image_free(c_mat_t* img);
/**
* @brief Adds colored rectangles to the image
@@ -103,5 +86,8 @@ OPENCV_C_WRAPPER(int) image_free(c_mat_t* img);
* @param thickness - thickness of a line (in pixels) to be used for bounding boxes
* @return Status of the operation: 0 for success, -1 for fail.
*/
OPENCV_C_WRAPPER(int)
image_add_rectangles(c_mat_t* img, rectangle_t rects[], int classes[], int num, int thickness);
int image_add_rectangles(c_mat_t* img, rectangle_t rects[], int classes[], int num, int thickness);
#ifdef __cplusplus
}
#endif
@@ -1,3 +1,7 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "bmp_reader.h"
#include <memory.h>
@@ -1,3 +1,7 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
typedef struct BmpHeaderType {
+8 -19
View File
@@ -69,12 +69,7 @@ if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64.*|aarch64.*|AARCH64.*)")
set(AARCH64 ON)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
set(ARM ON)
endif()
if(ARM AND NOT (CMAKE_CROSSCOMPILING OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"))
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)" AND NOT (CMAKE_CROSSCOMPILING OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"))
add_compile_options(-march=armv7-a+fp)
endif()
@@ -133,19 +128,10 @@ elseif(gflags_required)
endif()
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/utils")
add_subdirectory(common/utils)
endif()
# include common utils
add_subdirectory(common)
# format reader must be added after find_package(OpenVINO) to get
# exactly the same OpenCV_DIR path which was used for the OpenVINO build
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/format_reader")
add_subdirectory(common/format_reader)
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/opencv_c_wrapper")
add_subdirectory(common/opencv_c_wrapper)
endif()
# samples build can be switched off during whole IE build
# samples build can be switched off during whole OpenVINO build
if (DEFINED OpenVINO_SOURCE_DIR AND NOT ENABLE_SAMPLES)
return()
endif()
@@ -247,8 +233,11 @@ endmacro()
# collect all samples subdirectories
file(GLOB samples_dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
# skip building of unnecessary subdirectories
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty")
list(REMOVE_ITEM samples_dirs common thirdparty)
list(REMOVE_ITEM samples_dirs thirdparty)
endif()
list(REMOVE_ITEM samples_dirs common)
add_samples_to_build(${samples_dirs})
@@ -14,7 +14,6 @@
#include <vector>
#include "format_reader_ptr.h"
#include "npy.h"
#include "samples/slog.hpp"
#include "shared_tensor_allocator.hpp"
#include "utils.hpp"
+6
View File
@@ -0,0 +1,6 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
add_subdirectory(utils)
add_subdirectory(format_reader)
@@ -4,16 +4,17 @@
set (TARGET_NAME "format_reader")
file (GLOB MAIN_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file (GLOB LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file (GLOB MAIN_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file (GLOB LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h)
file (GLOB LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
# Create named folders for the sources within the .vcproj
# Empty name lists them directly under the .vcproj
source_group("src" FILES ${LIBRARY_SRC})
source_group("include" FILES ${LIBRARY_HEADERS})
source_group("src" FILES ${LIBRARY_SRC} ${LIBRARY_HEADERS})
source_group("include" FILES ${LIBRARY_PUBLIC_HEADERS})
# Create library file from sources.
add_library(${TARGET_NAME} SHARED ${MAIN_SRC} ${LIBRARY_HEADERS})
add_library(${TARGET_NAME} STATIC ${MAIN_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS})
# Find OpenCV components if exist
find_package(OpenCV QUIET COMPONENTS core imgproc imgcodecs)
@@ -29,20 +30,11 @@ else()
target_compile_definitions(${TARGET_NAME} PRIVATE USE_OPENCV)
endif()
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_FORMAT_READER)
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/..")
set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}
FOLDER cpp_samples)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER cpp_samples)
if(COMMAND add_clang_format_target)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
endif()
install(
TARGETS ${TARGET_NAME}
RUNTIME DESTINATION samples_bin/ COMPONENT samples_bin EXCLUDE_FROM_ALL
LIBRARY DESTINATION samples_bin/ COMPONENT samples_bin EXCLUDE_FROM_ALL
)
@@ -13,22 +13,6 @@
#include <string>
#include <vector>
#if defined(_WIN32)
# ifdef IMPLEMENT_FORMAT_READER
# define FORMAT_READER_API(type) extern "C" __declspec(dllexport) type
# else
# define FORMAT_READER_API(type) extern "C" type
# endif
#elif (__GNUC__ >= 4)
# ifdef IMPLEMENT_FORMAT_READER
# define FORMAT_READER_API(type) extern "C" __attribute__((visibility("default"))) type
# else
# define FORMAT_READER_API(type) extern "C" type
# endif
#else
# define FORMAT_READER_API(TYPE) extern "C" TYPE
#endif
namespace FormatReader {
/**
* \class FormatReader
@@ -85,10 +69,11 @@ public:
*/
virtual size_t size() const = 0;
};
} // namespace FormatReader
/**
* \brief Function for create reader
* @return FormatReader pointer
* @return Reader pointer
*/
FORMAT_READER_API(FormatReader::Reader*) CreateFormatReader(const char* filename);
Reader* CreateFormatReader(const char* filename);
} // namespace FormatReader
@@ -42,6 +42,6 @@ void Registry::RegisterReader(CreatorFunction f) {
_data.push_back(f);
}
FORMAT_READER_API(Reader*) CreateFormatReader(const char* filename) {
Reader* FormatReader::CreateFormatReader(const char* filename) {
return Registry::CreateReader(filename);
}
+1
View File
@@ -1,6 +1,7 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
set(TARGET_NAME "ie_samples_utils")
file(GLOB_RECURSE SOURCES "*.cpp" "*.hpp" "*.h")
@@ -148,7 +148,7 @@ public:
std::cout << std::endl << std::endl;
printHeader();
for (size_t id = image_id * _nTop, cnt = 0; id < (image_id + 1) * _nTop; ++cnt, ++id) {
for (size_t id = image_id * _nTop; id < (image_id + 1) * _nTop; ++id) {
std::cout.precision(7);
// Getting probability for resulting class
const auto index = _results.at(id) + image_id * (_outTensor.get_size() / _batchSize);
@@ -179,7 +179,7 @@ public:
std::cout << std::endl << std::endl;
printHeader();
for (size_t id = image_id * _nTop, cnt = 0; id < (image_id + 1) * _nTop; ++cnt, ++id) {
for (size_t id = image_id * _nTop; id < (image_id + 1) * _nTop; ++id) {
std::cout.precision(7);
// Getting probability for resulting class
const auto result = _outTensor.data<float>();
@@ -21,7 +21,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# 'argument': conversion from 'size_t' to 'int', possible loss of data
ie_add_compiler_flags(/wd4267)
ie_add_compiler_flags(/wd4244)
elseif(CMAKE_COMPILER_IS_GNUCXX)
elseif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
ie_add_compiler_flags(-Wno-unused-but-set-variable)
endif()
@@ -33,7 +33,7 @@ elseif(SELECTIVE_BUILD STREQUAL "ON")
-Wno-unused-variable
-Wno-unused-parameter
-Wno-unused-local-typedefs)
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
target_compile_options(${TARGET_NAME} INTERFACE -Wno-unused-but-set-variable)
endif()
endif()
+5 -5
View File
@@ -1779,17 +1779,17 @@ TEST(constant, lazy_bitwise_identical) {
// Disabled just because of long execution time. Enable for nightly builds in future
TEST(constant, DISABLED_nightly_huge_size_4GB) {
size_t start = 1llu << 32;
size_t s = start + 5;
uint64_t start = 1llu << 32;
uint64_t s = start + 5;
std::vector<uint8_t> data(s);
for (size_t i = start; i < s; i++) {
for (uint64_t i = start; i < s; i++) {
data[i] = static_cast<uint8_t>(i - start + 42);
}
Shape shape{s};
Shape shape{static_cast<Shape::size_type>(s)};
op::Constant c(element::u8, shape, data.data());
auto v = c.get_vector<uint8_t>();
ASSERT_EQ(v.size(), shape_size(shape));
for (size_t i = start; i < s; i++) {
for (uint64_t i = start; i < s; i++) {
EXPECT_EQ(v[i], i - start + 42) << i << " failed";
}
}
+3 -1
View File
@@ -13,9 +13,11 @@ if(ENABLE_FUNCTIONAL_TESTS)
ie_add_compiler_flags(-Wno-unused-local-typedefs)
ie_add_compiler_flags(-Wno-reorder)
ie_add_compiler_flags(-Wno-comment)
ie_add_compiler_flags(-Wno-unused-but-set-variable)
ie_add_compiler_flags(-Wno-unused-local-typedefs)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
ie_add_compiler_flags(-Wno-unused-but-set-variable)
endif()
add_subdirectory(functional)
endfunction()
+1 -1
View File
@@ -124,7 +124,7 @@ std::shared_ptr<ov::ICompiledModel> TemplatePlugin::Plugin::import_model(std::is
ov::Tensor weights;
model.read(reinterpret_cast<char*>(&dataSize), sizeof(dataSize));
if (0 != dataSize) {
weights = ov::Tensor(ov::element::from<char>(), ov::Shape{dataSize});
weights = ov::Tensor(ov::element::from<char>(), ov::Shape{static_cast<ov::Shape::size_type>(dataSize)});
model.read(weights.data<char>(), dataSize);
}
+1 -1
View File
@@ -254,7 +254,7 @@ if(ENABLE_GAPI_PREPROCESSING)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11)
target_compile_options(fluid PRIVATE "-Wno-maybe-uninitialized")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
target_compile_options(fluid PRIVATE "-Wno-unused-but-set-variable")
endif()
+3
View File
@@ -10,6 +10,9 @@ set(BUILD_SHARED_LIBS OFF)
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
ie_add_compiler_flags(-Wno-all)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11 AND CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wno-stringop-overflow)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# protobuf\src\google\protobuf\descriptor.cc(822) : error C4703: potentially uninitialized local pointer variable 'to_use' used
add_definitions("/wd4703")