Skip to content

Commit

Permalink
[NPU] Separate the compiler headers from the runtime headers (#27125)
Browse files Browse the repository at this point in the history
### Details:
 - *Separate  the compiler headers from the runtime headers*
 - *Create separate options for each target*
 - *BUILD_COMPILER_FOR_DRIVER option is removed from OV*

### Tickets:
- *CVS-153081*
  • Loading branch information
pereanub authored Oct 23, 2024
1 parent c375336 commit 5676ff8
Show file tree
Hide file tree
Showing 132 changed files with 2,433 additions and 817 deletions.
16 changes: 13 additions & 3 deletions src/plugins/intel_npu/cmake/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

ov_option(ENABLE_MLIR_COMPILER "Enable compilation of npu_mlir_compiler libraries" ON)

ov_option(BUILD_COMPILER_FOR_DRIVER "Enable build of npu_driver_compiler" OFF)
ov_option(ENABLE_NPU_RUNTIME_COMMON "Enable compilation of npu runtime common libraries" ON)

# if ENABLE_ZEROAPI_BACKEND=ON, it adds the ze_loader dependency for driver compiler
ov_dependent_option(ENABLE_ZEROAPI_BACKEND "Enable zero-api as a plugin backend" ON "NOT BUILD_COMPILER_FOR_DRIVER" OFF)
ov_dependent_option(ENABLE_NPU_PLUGIN_ENGINE "Enable compilation of NPU plugin engine" ON "ENABLE_NPU_RUNTIME_COMMON" OFF)

ov_dependent_option(ENABLE_DRIVER_COMPILER_ADAPTER "Enable NPU Compiler inside driver" ON "NOT BUILD_COMPILER_FOR_DRIVER;ENABLE_ZEROAPI_BACKEND" OFF)
ov_dependent_option(ENABLE_ZEROAPI_BACKEND "Enable zero-api as a plugin backend" ON "ENABLE_NPU_RUNTIME_COMMON;ENABLE_NPU_PLUGIN_ENGINE" OFF)

ov_dependent_option(ENABLE_DRIVER_COMPILER_ADAPTER "Enable NPU Compiler inside driver" ON "ENABLE_ZEROAPI_BACKEND" OFF)

if((NOT ENABLE_NPU_PLUGIN_ENGINE OR NOT ENABLE_NPU_RUNTIME_COMMON) AND ENABLE_TESTS)
message(FATAL_ERROR "Tests depends on npu plugin engine and npu runtime common libraries!")
endif()

if((NOT ENABLE_NPU_PLUGIN_ENGINE OR NOT ENABLE_NPU_RUNTIME_COMMON) AND ENABLE_ZEROAPI_BACKEND)
message(FATAL_ERROR "Zero backend depends on npu plugin engine and npu common libraries!")
endif()

if(NOT ENABLE_ZEROAPI_BACKEND AND ENABLE_DRIVER_COMPILER_ADAPTER)
message(FATAL_ERROR "Compiler adapter depends on zero backend to use same context!")
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/intel_npu/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ add_subdirectory(utils)

add_subdirectory(al)

if (ENABLE_NPU_RUNTIME_COMMON)
add_subdirectory(common)
endif()

if(ENABLE_DRIVER_COMPILER_ADAPTER AND ENABLE_ZEROAPI_BACKEND)
add_subdirectory(compiler)
endif()
Expand All @@ -17,6 +21,6 @@ if(ENABLE_ZEROAPI_BACKEND)
add_subdirectory(backend)
endif()

if (NOT BUILD_COMPILER_FOR_DRIVER)
if (ENABLE_NPU_PLUGIN_ENGINE)
add_subdirectory(plugin)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "intel_npu/al/config/config.hpp"
#include "npu_private_properties.hpp"
#include "intel_npu/config/config.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "openvino/runtime/internal_properties.hpp"
#include "openvino/runtime/properties.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <thread>

#include "common.hpp"
#include "intel_npu/al/config/config.hpp"
#include "npu_private_properties.hpp"
#include "intel_npu/config/config.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"

namespace ov {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <thread>

#include "common.hpp"
#include "npu_private_properties.hpp"
#include "npuw_private_properties.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "intel_npu/npuw_private_properties.hpp"

namespace intel_npu {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "intel_npu/al/config/config.hpp"
#include "npu_private_properties.hpp"
#include "intel_npu/config/config.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
#include "openvino/runtime/internal_properties.hpp"
#include "openvino/runtime/properties.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <unordered_map>
#include <unordered_set>

#include "intel_npu/al/config/config.hpp"
#include "intel_npu/config/config.hpp"
#include "openvino/core/partial_shape.hpp"
#include "openvino/core/type/element_type.hpp"
#include "openvino/runtime/common.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/al/src/config/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "intel_npu/al/config/common.hpp"
#include "intel_npu/config/common.hpp"

using namespace intel_npu;
using namespace ov::intel_npu;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/al/src/config/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "intel_npu/al/config/compiler.hpp"
#include "intel_npu/config/compiler.hpp"

using namespace intel_npu;
using namespace ov::intel_npu;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/al/src/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "intel_npu/al/config/config.hpp"
#include "intel_npu/config/config.hpp"

namespace intel_npu {

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/al/src/config/npuw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "intel_npu/al/config/npuw.hpp"
#include "intel_npu/config/npuw.hpp"

using namespace intel_npu;
using namespace ov::intel_npu;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_npu/src/al/src/config/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "intel_npu/al/config/runtime.hpp"
#include "intel_npu/config/runtime.hpp"

#include <sstream>

#include "intel_npu/al/config/common.hpp"
#include "intel_npu/config/common.hpp"
#include "openvino/runtime/properties.hpp"

using namespace intel_npu;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/al/src/icompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "intel_npu/al/icompiler.hpp"
#include "intel_npu/icompiler.hpp"

namespace intel_npu {

Expand Down
1 change: 1 addition & 0 deletions src/plugins/intel_npu/src/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_include_directories(${TARGET_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
openvino::npu_al
openvino::npu_common
openvino_npu_zero_result_parser
ze_loader
)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/backend/include/zero_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <map>
#include <memory>

#include "intel_npu/common/npu.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "npu.hpp"
#include "zero_init.hpp"

namespace intel_npu {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_npu/src/backend/include/zero_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <ze_api.h>
#include <ze_graph_ext.h>

#include "intel_npu/al/icompiled_model.hpp"
#include "intel_npu/common/icompiled_model.hpp"
#include "intel_npu/common/npu.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "npu.hpp"
#include "openvino/runtime/intel_npu/remote_properties.hpp"
#include "zero_init.hpp"
#include "zero_types.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include <mutex>

#include "intel_npu/common/npu.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "npu.hpp"
#include "openvino/runtime/properties.hpp"
#include "zero_init.hpp"
#include "zero_wrappers.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "intel_npu/al/config/config.hpp"
#include "intel_npu/config/config.hpp"
#include "openvino/runtime/itensor.hpp"
#include "zero_init.hpp"
#include "zero_remote_tensor.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#include <ze_api.h>
#include <ze_graph_ext.h>

#include "intel_npu/common/npu.hpp"
#include "intel_npu/common/sync_infer_request.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "npu.hpp"
#include "zero_executor.hpp"
#include "zero_pipeline.hpp"
#include "zero_profiling.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <climits>
#include <map>

#include "intel_npu/al/config/compiler.hpp"
#include "intel_npu/config/compiler.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "openvino/runtime/profiling_info.hpp"
#include "zero_types.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <memory>
#include <string>

#include "intel_npu/common/remote_tensor.hpp"
#include "openvino/runtime/intel_npu/remote_properties.hpp"
#include "remote_tensor.hpp"
#include "zero_init.hpp"

namespace intel_npu {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/backend/include/zero_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <string_view>

#include "intel_npu/al/config/runtime.hpp"
#include "intel_npu/config/runtime.hpp"

/**
* @brief Last version of Table of Graph Extension functions used within plugin
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/backend/include/zero_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <ze_api.h>
#include <ze_graph_ext.h>

#include "intel_npu/al/config/runtime.hpp"
#include "intel_npu/config/runtime.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "intel_npu/utils/zero/zero_result.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/backend/src/zero_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <vector>

#include "intel_npu/al/config/common.hpp"
#include "intel_npu/config/common.hpp"
#include "zero_device.hpp"

namespace intel_npu {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/backend/src/zero_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "zero_device.hpp"

#include "intel_npu/al/itt.hpp"
#include "intel_npu/common/itt.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "zero_executor.hpp"
#include "zero_host_tensor.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/intel_npu/src/backend/src/zero_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <sstream>
#include <string>

#include "intel_npu/al/config/common.hpp"
#include "intel_npu/al/itt.hpp"
#include "intel_npu/al/prefix.hpp"
#include "intel_npu/common/itt.hpp"
#include "intel_npu/config/common.hpp"
#include "intel_npu/prefix.hpp"
#include "openvino/runtime/properties.hpp"
#include "ze_command_queue_npu_ext.h"
#include "zero_device.hpp"
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include "zero_infer_request.hpp"

#include "intel_npu/al/config/common.hpp"
#include "intel_npu/al/config/compiler.hpp"
#include "intel_npu/al/config/runtime.hpp"
#include "intel_npu/al/itt.hpp"
#include "intel_npu/al/prefix.hpp"
#include "intel_npu/common/itt.hpp"
#include "intel_npu/config/common.hpp"
#include "intel_npu/config/compiler.hpp"
#include "intel_npu/config/runtime.hpp"
#include "intel_npu/prefix.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "openvino/op/util/op_types.hpp"
#include "openvino/runtime/intel_npu/remote_properties.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/backend/src/zero_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "zero_init.hpp"

#include "intel_npu/al/itt.hpp"
#include "intel_npu/common/itt.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "ze_api.h"
#include "ze_command_queue_npu_ext.h"
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <ze_api.h>
#include <ze_graph_ext.h>

#include "intel_npu/al/itt.hpp"
#include "intel_npu/al/prefix.hpp"
#include "intel_npu/common/itt.hpp"
#include "intel_npu/prefix.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "zero_types.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_npu/src/backend/src/zero_profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <ze_graph_profiling_ext.h>

#include "intel_npu/al/config/compiler.hpp"
#include "intel_npu/al/profiling.hpp"
#include "intel_npu/config/compiler.hpp"
#include "intel_npu/profiling.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "zero_profiling.hpp"
#include "zero_utils.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <ze_api.h>

#include "intel_npu/al/config/common.hpp"
#include "intel_npu/config/common.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "openvino/core/type/element_iterator.hpp"
#include "zero_utils.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "zero_wrappers.hpp"

#include "intel_npu/al/config/common.hpp"
#include "intel_npu/config/common.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "zero_types.hpp"

Expand Down
36 changes: 36 additions & 0 deletions src/plugins/intel_npu/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

set(TARGET_NAME openvino_npu_common)

file(GLOB_RECURSE SOURCES *.cpp *.hpp *.h)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})

add_library(${TARGET_NAME} STATIC ${SOURCES})
add_library(openvino::npu_common ALIAS ${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME npu_common)

target_include_directories(${TARGET_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

target_link_libraries(${TARGET_NAME}
PUBLIC
openvino::npu_al
openvino::npu_logger_utils
openvino::runtime::dev
)

set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})

#
# targets install
#
ov_install_static_lib(${TARGET_NAME} ${NPU_PLUGIN_COMPONENT})

ov_developer_package_export_targets(TARGET openvino::npu_common
INSTALL_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/include)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <cstdint>
#include <map>

#include "npu_private_properties.hpp"
#include "intel_npu/npu_private_properties.hpp"

namespace utils {
bool isNPUDevice(const uint32_t deviceId);
Expand Down
Loading

0 comments on commit 5676ff8

Please sign in to comment.