Skip to content

Commit

Permalink
Added suggest-override flag (#6631)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored Jul 16, 2021
1 parent 22fddb4 commit bc36425
Show file tree
Hide file tree
Showing 147 changed files with 406 additions and 548 deletions.
49 changes: 4 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,50 +42,6 @@ endforeach()
# Build
#

function(build_ngraph)
function(ngraph_set option value)
if(NOT DEFINED ${option})
set(${option} ${value} CACHE BOOL "" FORCE)
endif()
endfunction()

if(ENABLE_TESTS AND NOT ANDROID)
ngraph_set(NGRAPH_UNIT_TEST_ENABLE ON)
else()
ngraph_set(NGRAPH_UNIT_TEST_ENABLE OFF)
endif()

if(NOT (ANDROID OR WINDOWS_STORE OR (MSVC AND (ARM OR AARCH64)) ))
ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE ON)
ngraph_set(NGRAPH_PDPD_FRONTEND_ENABLE ON)
else()
ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE OFF)
ngraph_set(NGRAPH_PDPD_FRONTEND_ENABLE OFF)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
ie_add_compiler_flags(-Wno-error=uninitialized -Wno-error=literal-conversion)
elseif(UNIX)
ie_add_compiler_flags(-Wno-error=maybe-uninitialized -Wno-error=return-type)
endif()

# WA for GCC 7.0
if (UNIX)
ie_add_compiler_flags(-Wno-error=return-type -Wno-undef)
elseif(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4308 /wd4146 /wd4703 /wd4244 /wd4819")
endif()

if(ENABLE_LTO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
endif()

ie_cpack_add_component(ngraph REQUIRED)
ie_cpack_add_component(ngraph_dev REQUIRED DEPENDS ngraph)

add_subdirectory(ngraph)
endfunction()

function(openvino_developer_export_targets)
cmake_parse_arguments(EXPORT "" "COMPONENT" "TARGETS" ${ARGN})

Expand Down Expand Up @@ -118,9 +74,12 @@ function(openvino_developer_export_targets)
"A list of OpenVINO exported components" FORCE)
endfunction()

ie_cpack_add_component(ngraph REQUIRED)
ie_cpack_add_component(ngraph_dev REQUIRED DEPENDS ngraph)

add_subdirectory(thirdparty)
add_subdirectory(openvino)
build_ngraph()
add_subdirectory(ngraph)
add_subdirectory(inference-engine)

# for Template plugin
Expand Down
32 changes: 31 additions & 1 deletion cmake/developer_package/compile_flags/os_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

include(ProcessorCount)
include(CheckCXXCompilerFlag)

#
# Disables deprecated warnings generation
Expand Down Expand Up @@ -292,9 +293,14 @@ else()
elseif(UNIX)
ie_add_compiler_flags(-Wuninitialized -Winit-self)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
ie_add_compiler_flags(-Wno-error=switch)
ie_add_compiler_flags(-Wno-error=switch
-Winconsistent-missing-override)
else()
ie_add_compiler_flags(-Wmaybe-uninitialized)
check_cxx_compiler_flag("-Wsuggest-override" SUGGEST_OVERRIDE_SUPPORTED)
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}")
endif()
endif()
endif()

Expand All @@ -316,3 +322,27 @@ else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
endif()
endif()

# Links provided libraries and include their INTERFACE_INCLUDE_DIRECTORIES as SYSTEM
function(link_system_libraries TARGET_NAME)
set(MODE PRIVATE)

foreach(arg IN LISTS ARGN)
if(arg MATCHES "(PRIVATE|PUBLIC|INTERFACE)")
set(MODE ${arg})
else()
if(TARGET "${arg}")
target_include_directories(${TARGET_NAME}
SYSTEM ${MODE}
$<TARGET_PROPERTY:${arg},INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${arg},INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
endif()

target_link_libraries(${TARGET_NAME}
${MODE}
${arg}
)
endif()
endforeach()
endfunction()
4 changes: 2 additions & 2 deletions cmake/developer_package/compile_flags/sanitizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include(CheckCXXCompilerFlag)

if (ENABLE_SANITIZER)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address")
CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=address" SANITIZE_RECOVER_ADDRESS_SUPPORTED)
check_cxx_compiler_flag("-fsanitize-recover=address" SANITIZE_RECOVER_ADDRESS_SUPPORTED)
if (SANITIZE_RECOVER_ADDRESS_SUPPORTED)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address")
endif()
Expand All @@ -18,7 +18,7 @@ if (ENABLE_UB_SANITIZER)
# TODO: Remove -fno-sanitize=null as thirdparty/ocl/clhpp_headers UBSAN compatibility resolved:
# https://github.com/KhronosGroup/OpenCL-CLHPP/issues/17
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=undefined -fno-sanitize=null")
CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=undefined" SANITIZE_RECOVER_UNDEFINED_SUPPORTED)
check_cxx_compiler_flag("-fsanitize-recover=undefined" SANITIZE_RECOVER_UNDEFINED_SUPPORTED)
if (SANITIZE_RECOVER_UNDEFINED_SUPPORTED)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=undefined")
endif()
Expand Down
19 changes: 19 additions & 0 deletions cmake/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,25 @@ ie_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF)

ie_option (ENABLE_CPU_DEBUG_CAPS "enable CPU debug capabilities at runtime" OFF)

if(ANDROID OR WINDOWS_STORE OR (MSVC AND (ARM OR AARCH64)))
set(protoc_available OFF)
else()
set(protoc_available ON)
endif()

ie_dependent_option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" ON "protoc_available" OFF)
ie_dependent_option(NGRAPH_ONNX_EDITOR_ENABLE "Enable ONNX Editor" ON "NGRAPH_ONNX_IMPORT_ENABLE" OFF)
ie_dependent_option(NGRAPH_PDPD_FRONTEND_ENABLE "Enable PaddlePaddle FrontEnd" ON "protoc_available" OFF)
ie_dependent_option(NGRAPH_USE_PROTOBUF_LITE "Compiles and links with protobuf-lite" OFF
"NGRAPH_ONNX_IMPORT_ENABLE OR NGRAPH_PDPD_FRONTEND_ENABLE" OFF)
ie_dependent_option(NGRAPH_UNIT_TEST_ENABLE "Enables ngraph unit tests" ON "ENABLE_TESTS;NOT ANDROID" OFF)
ie_dependent_option(NGRAPH_UNIT_TEST_BACKENDS_ENABLE "Control the building of unit tests using backends" ON
"NGRAPH_UNIT_TEST_ENABLE" OFF)
option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" OFF)

# WA for ngraph python build on Windows debug
list(REMOVE_ITEM IE_OPTIONS NGRAPH_UNIT_TEST_ENABLE NGRAPH_UNIT_TEST_BACKENDS_ENABLE)

#
# Process featues
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set_and_check(IE_MAIN_SOURCE_DIR "@IE_MAIN_SOURCE_DIR@") # HDDL

# Variables to export in plugin's projects

set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH;")
set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH")
list(APPEND ie_options CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER)
file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path)

Expand Down Expand Up @@ -73,6 +73,9 @@ if(NOT MSVC)
ie_add_compiler_flags(-Wno-error=unused-variable)
if(CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wno-error=unused-but-set-variable)
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
endif()
endif()
endif()

Expand Down
16 changes: 8 additions & 8 deletions inference-engine/samples/speech_sample/fileutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ArkFile : public BaseFile {
* @param ptrNumMemoryBytes pointer to specific number of memory bytes
* @return none.
*/
virtual void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes);
void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) override;

/**
* @brief Load Kaldi ARK speech feature vector file
Expand All @@ -43,8 +43,8 @@ class ArkFile : public BaseFile {
* @param ptrNumBytesPerElement pointer to number bytes per element (size of float by default)
* @return none.
*/
virtual void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows,
uint32_t* ptrNumColumns, uint32_t* ptrNumBytesPerElement);
void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows, uint32_t* ptrNumColumns,
uint32_t* ptrNumBytesPerElement) override;

/**
* @brief Save Kaldi ARK speech feature vector file
Expand All @@ -56,7 +56,7 @@ class ArkFile : public BaseFile {
* @param numColumns number of columns
* @return none.
*/
virtual void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns);
void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) override;
};

/// @brief Responsible to work with .npz files
Expand All @@ -70,7 +70,7 @@ class NumpyFile : public BaseFile {
* @param ptrNumMemoryBytes pointer to specific number of memory bytes
* @return none.
*/
virtual void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes);
void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) override;

/**
* @brief Load Numpy* uncompressed NPZ speech feature vector file
Expand All @@ -83,8 +83,8 @@ class NumpyFile : public BaseFile {
* @param ptrNumBytesPerElement pointer to number bytes per element (size of float by default)
* @return none.
*/
virtual void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows,
uint32_t* ptrNumColumns, uint32_t* ptrNumBytesPerElement);
void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows, uint32_t* ptrNumColumns,
uint32_t* ptrNumBytesPerElement) override;

/**
* @brief Save Numpy* uncompressed NPZ speech feature vector file
Expand All @@ -96,5 +96,5 @@ class NumpyFile : public BaseFile {
* @param numColumns number of columns
* @return none.
*/
virtual void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns);
void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) override;
};
13 changes: 8 additions & 5 deletions inference-engine/src/mkldnn_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ target_link_libraries(${TARGET_NAME} PRIVATE mkldnn
inference_engine_lp_transformations)

target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
$<TARGET_PROPERTY:mkldnn,INCLUDE_DIRECTORIES>)
${CMAKE_CURRENT_SOURCE_DIR})

target_include_directories(${TARGET_NAME} SYSTEM PRIVATE
$<TARGET_PROPERTY:mkldnn,INCLUDE_DIRECTORIES>)

# Cross compiled function
# TODO: The same for proposal, proposalONNX, topk
Expand All @@ -64,15 +66,16 @@ ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME})
# add test object library

add_library(${TARGET_NAME}_obj OBJECT ${SOURCES} ${HEADERS})
target_link_libraries(${TARGET_NAME}_obj PUBLIC mkldnn)
link_system_libraries(${TARGET_NAME}_obj PUBLIC mkldnn)

target_include_directories(${TARGET_NAME}_obj PRIVATE $<TARGET_PROPERTY:inference_engine_preproc_s,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:inference_engine_transformations,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:openvino::itt,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:inference_engine_lp_transformations,INTERFACE_INCLUDE_DIRECTORIES>
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
$<TARGET_PROPERTY:openvino::conditional_compilation,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:mkldnn,INCLUDE_DIRECTORIES>)
$<TARGET_PROPERTY:openvino::conditional_compilation,INTERFACE_INCLUDE_DIRECTORIES>)

target_include_directories(${TARGET_NAME}_obj SYSTEM PUBLIC $<TARGET_PROPERTY:mkldnn,INCLUDE_DIRECTORIES>)

set_ie_threading_interface_for(${TARGET_NAME}_obj)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ constexpr size_t channelsPos = 1lu;

class PlainFormatCreator : public TensorDescCreator {
public:
virtual InferenceEngine::TensorDesc createDesc(const InferenceEngine::Precision& precision, const InferenceEngine::SizeVector& srcDims) const {
InferenceEngine::TensorDesc createDesc(const InferenceEngine::Precision& precision, const InferenceEngine::SizeVector& srcDims) const override {
SizeVector order(srcDims.size());
std::iota(order.begin(), order.end(), 0);
return TensorDesc(precision, srcDims, {srcDims, order});
}
virtual size_t getMinimalRank() const { return 0lu; }
size_t getMinimalRank() const override { return 0lu; }
};

class PerChannelCreator : public TensorDescCreator {
public:
virtual InferenceEngine::TensorDesc createDesc(const InferenceEngine::Precision &precision, const InferenceEngine::SizeVector &srcDims) const {
InferenceEngine::TensorDesc createDesc(const InferenceEngine::Precision &precision, const InferenceEngine::SizeVector &srcDims) const override {
SizeVector order(srcDims.size());
std::iota(order.begin(), order.end(), 0);
SizeVector blkDims = srcDims;
Expand All @@ -39,13 +39,13 @@ class PerChannelCreator : public TensorDescCreator {

return TensorDesc(precision, srcDims, {blkDims, order});
}
virtual size_t getMinimalRank() const { return 3lu; }
size_t getMinimalRank() const override { return 3lu; }
};

class ChannelBlockedCreator : public TensorDescCreator {
public:
ChannelBlockedCreator(size_t blockSize) : _blockSize(blockSize) {}
virtual InferenceEngine::TensorDesc createDesc(const InferenceEngine::Precision& precision, const InferenceEngine::SizeVector& srcDims) const {
InferenceEngine::TensorDesc createDesc(const InferenceEngine::Precision& precision, const InferenceEngine::SizeVector& srcDims) const override {
if (srcDims.size() < 2) {
IE_THROW() << "Can't create blocked tensor descriptor!";
}
Expand All @@ -60,7 +60,7 @@ class ChannelBlockedCreator : public TensorDescCreator {

return TensorDesc(precision, srcDims, {blkDims, order});
}
virtual size_t getMinimalRank() const { return 3lu; }
size_t getMinimalRank() const override { return 3lu; }

private:
size_t _blockSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ struct jit_has_subnormals_base::reg<cpu_isa_t::sse41> {

template<cpu_isa_t isa>
struct jit_has_subnormals : public jit_has_subnormals_base {
void generate() final {
void generate() override final { // NOLINT
size_t const vlen = reg<isa>::length;
const int sh_bits = std::ilogb(vlen);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ file(GLOB_RECURSE legacy_tests
set_source_files_properties(${legacy_tests} PROPERTIES INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:inference_engine_legacy,INTERFACE_INCLUDE_DIRECTORIES>)

if(SUGGEST_OVERRIDE_SUPPORTED)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/caching_test.cpp
PROPERTIES COMPILE_OPTIONS -Wno-suggest-override)
endif()

include(CMakeParseArguments)

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ using namespace InferenceEngine;

class NGraphReaderTests : public CommonTestUtils::TestsCommon {
protected:
void TearDown() override {}
void SetUp() override {}

void compareIRs(const std::string& modelV10, const std::string& oldModel, size_t weightsSize = 0, const std::function<void(Blob::Ptr&)>& fillBlob = {}) {
Core ie;
Blob::Ptr weights;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ class PreallocatorTests: public ::testing::Test {
protected:
std::vector<float> mybuf;

virtual void TearDown() {
}

virtual void SetUp() {
void SetUp() override {
mybuf.resize(10);
allocator = details::make_pre_allocator(&*mybuf.begin(), mybuf.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FakeQuantizeDecompositionTest : public CommonTestUtils::TestsCommon, publi
}

protected:
void SetUp() {
void SetUp() override {
FakeQuantizeDecompositionBasicParams basic_params;
std::pair<float, float> input_ranges_values;
bool should_be_decompos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

set(TARGET_NAME subgraphsDumperTests)

list(APPEND DEPENDENCIES
unitTestUtils
ngraph
)

addIeTargetTest(
NAME ${TARGET_NAME}
ROOT ${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -18,7 +13,7 @@ addIeTargetTest(
$<TARGET_PROPERTY:inference_engine,INTERFACE_INCLUDE_DIRECTORIES>
LINK_LIBRARIES
PRIVATE
unitTestUtils
funcTestUtils
ngraph
pugixml::static
ADD_CPPLINT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using ngraph::element::Type_t;

class ConvolutionMatcherTest : public ::testing::Test {
protected:
void SetUp() {
void SetUp() override {
matcher = SubgraphsDumper::ConvolutionsMatcher();
op_info = LayerTestsUtils::OPInfo();
}
Expand Down
Loading

0 comments on commit bc36425

Please sign in to comment.