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

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

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})

View File

@@ -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"

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)

View File

@@ -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
)

View File

@@ -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

View File

@@ -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);
}

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")

View File

@@ -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>();