Skip to content

Commit d4a548e

Browse files
committed
archive
1 parent 7d0c80b commit d4a548e

24 files changed

+110
-45
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# They are copied to python folder during the build to allow skipping wheel installation
2-
src/python/openvino_genai/*generate_pipeline_lib*
2+
src/python/openvino_genai/*genai*
33
src/python/openvino_genai/py_generate_pipeline*
44

55
# build/artifact dirs

CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,14 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithD
1010
project(openvino_genai)
1111

1212
add_subdirectory(./thirdparty/openvino_tokenizers/ "${CMAKE_CURRENT_BINARY_DIR}/openvino_tokenizers/")
13+
set(openvino_genai_VERSION 2024.1.0.0)
1314
add_subdirectory(src)
1415
add_subdirectory(text_generation/causal_lm/cpp)
16+
17+
install(DIRECTORY text_generation/causal_lm/cpp/ DESTINATION samples/cpp/causal_lm COMPONENT cpp_samples_genai)
18+
19+
install(FILES LICENSE third-party-programs.txt DESTINATION licenses_genai COMPONENT licensing_genai) # TODO: how to merge with OPenvino
20+
21+
set(CPACK_PACKAGE_VERSION ${openvino_genai_VERSION})
22+
set(CPACK_GENERATOR "ZIP")
23+
include(CPack)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies = [
2222
[tool.scikit-build]
2323
cmake.source-dir = "./"
2424
cmake.build-type = "Release"
25-
cmake.targets = ["py_generate_pipeline", "generate_pipeline_lib"]
25+
cmake.targets = ["py_generate_pipeline", "genai"]
2626
install.components = ["genai", "genai_python"]
2727
sdist.cmake = true
2828
wheel.packages = ["src/python/openvino_genai"]

src/cpp/CMakeLists.txt

+51-8
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,68 @@ ov_genai_build_jinja2cpp()
4444

4545
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
4646

47-
set(TARGET_NAME generate_pipeline_lib)
47+
set(TARGET_NAME genai)
4848
add_library(${TARGET_NAME} SHARED ${SOURCE_FILES})
4949

5050
target_include_directories(${TARGET_NAME}
5151
# TODO: remove it, because beam_search algo should not be exposed to end users
52-
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../text_generation/causal_lm/cpp/
53-
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
52+
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../text_generation/causal_lm/cpp/>"
53+
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
5454

5555
target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime PRIVATE nlohmann_json::nlohmann_json jinja2cpp)
5656

5757
target_compile_definitions(${TARGET_NAME} PRIVATE OPENVINO_TOKENIZERS_PATH=\"$<TARGET_FILE:openvino_tokenizers>\")
5858

5959
target_compile_features(${TARGET_NAME} PUBLIC cxx_std_17)
6060

61-
install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION . COMPONENT genai RUNTIME DESTINATION . COMPONENT genai)
61+
install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION . COMPONENT core_genai RUNTIME DESTINATION . COMPONENT core_genai)
6262

6363
# Populate python with the libraries to allow skipping wheel installation
64-
add_custom_command(TARGET generate_pipeline_lib POST_BUILD
64+
add_custom_command(TARGET genai POST_BUILD
6565
COMMAND "${CMAKE_COMMAND}" -E copy
66-
"$<TARGET_FILE:generate_pipeline_lib>"
67-
"${CMAKE_CURRENT_SOURCE_DIR}/../python/openvino_genai/$<TARGET_FILE_NAME:generate_pipeline_lib>"
68-
COMMENT "Copy generate_pipeline_lib to src/python/openvino_genai")
66+
"$<TARGET_FILE:genai>"
67+
"${CMAKE_CURRENT_SOURCE_DIR}/../python/openvino_genai/$<TARGET_FILE_NAME:genai>"
68+
COMMENT "Copy genai to src/python/openvino_genai")
69+
70+
export(TARGETS genai NAMESPACE openvino:: FILE "${CMAKE_BINARY_DIR}/openvino_genaiConfig.cmake") # TODO: try to merge
71+
install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION . COMPONENT core_genai RUNTIME DESTINATION . COMPONENT core_genai)
72+
73+
include(GenerateExportHeader)
74+
75+
generate_export_header(genai)
76+
set_property(TARGET genai PROPERTY VERSION ${openvino_genai_VERSION})
77+
set_property(TARGET genai PROPERTY SOVERSION 3)
78+
set_property(TARGET genai PROPERTY INTERFACE_genai_MAJOR_VERSION 3)
79+
set_property(TARGET genai APPEND PROPERTY COMPATIBLE_INTERFACE_STRING genai_MAJOR_VERSION)
80+
81+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCH_FOLDER)
82+
if(X86_64)
83+
set(ARCH_FOLDER intel64)
84+
elseif(X86)
85+
set(ARCH_FOLDER ia32)
86+
elseif(MSVC AND ARM)
87+
set(ARCH_FOLDER arm)
88+
elseif((MSVC OR APPLE) AND AARCH64)
89+
set(ARCH_FOLDER arm64)
90+
elseif(UNIVERSAL2)
91+
set(ARCH_FOLDER universal2)
92+
elseif(ARCH_FOLDER STREQUAL "x86_64" OR ARCH_FOLDER STREQUAL "amd64" # Windows detects Intel's 64-bit CPU as AMD64
93+
OR CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
94+
set(ARCH_FOLDER intel64)
95+
endif()
96+
install(TARGETS genai EXPORT openvino_genaiTargets
97+
LIBRARY DESTINATION runtime/lib/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} COMPONENT core_genai_dev
98+
ARCHIVE DESTINATION runtime/lib/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} COMPONENT core_genai_dev
99+
RUNTIME DESTINATION runtime/bin/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} COMPONENT core_genai_dev
100+
INCLUDES DESTINATION runtime/include)
101+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION runtime/include COMPONENT core_genai_dev)
102+
103+
include(CMakePackageConfigHelpers)
104+
write_basic_package_version_file("${CMAKE_BINARY_DIR}/openvino_genaiConfigVersion.cmake" VERSION ${openvino_genai_VERSION} COMPATIBILITY AnyNewerVersion)
105+
106+
export(EXPORT openvino_genaiTargets FILE "${CMAKE_BINARY_DIR}/openvino_genaiTargets.cmake" NAMESPACE openvino::)
107+
configure_file(cmake/openvino_genaiConfig.cmake "${CMAKE_BINARY_DIR}/openvino_genaiConfig.cmake" COPYONLY)
108+
109+
install(EXPORT openvino_genaiTargets FILE openvino_genaiTargets.cmake NAMESPACE openvino:: DESTINATION runtime/cmake)
110+
install(FILES cmake/openvino_genaiConfig.cmake "${CMAKE_BINARY_DIR}/openvino_genaiConfigVersion.cmake"
111+
DESTINATION runtime/cmake COMPONENT core_genai_dev)
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include(CMakeFindDependencyMacro)
2+
find_dependency(OpenVINO COMPONENTS Runtime)
3+
4+
include("${CMAKE_CURRENT_LIST_DIR}/openvino_genaiTargets.cmake")

src/cpp/include/openvino/genai/generation_config.hpp src/cpp/include/openvino_genai/generation_config.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "openvino/runtime/compiled_model.hpp"
1111
#include "openvino/runtime/infer_request.hpp"
12-
#include "openvino/genai/tokenizer.hpp"
12+
#include "openvino_genai/tokenizer.hpp"
1313

1414
namespace ov {
1515

src/cpp/include/openvino/genai/llm_pipeline.hpp src/cpp/include/openvino_genai/llm_pipeline.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include <variant>
88

99
#include <openvino/core/any.hpp>
10-
#include "openvino/genai/generation_config.hpp"
11-
#include "openvino/genai/tokenizer.hpp"
12-
#include "openvino/genai/streamer_base.hpp"
10+
#include "openvino_genai/generation_config.hpp"
11+
#include "openvino_genai/tokenizer.hpp"
12+
#include "openvino_genai/streamer_base.hpp"
1313

1414
namespace ov {
1515

src/cpp/include/openvino/genai/streamer_base.hpp src/cpp/include/openvino_genai/streamer_base.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#pragma once
55

6-
#include "openvino/genai/tokenizer.hpp"
6+
#include "openvino_genai/tokenizer.hpp"
77

88
namespace ov {
99

src/cpp/include/openvino/genai/tokenizer.hpp src/cpp/include/openvino_genai/tokenizer.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
#include <vector>
88
#include <initializer_list>
99
#include <openvino/runtime/tensor.hpp>
10-
#include "openvino/genai/visibility.hpp"
10+
#include "openvino_genai/visibility.hpp"
1111

1212
namespace ov {
1313

1414
/**
1515
* @brief class is used to encode prompts and decode resulting tokens
1616
*/
17-
class OPENVINO_GENAI_EXPORTS Tokenizer {
17+
class openvino_genai_EXPORTS Tokenizer {
1818
public:
1919
/**
2020
* @brief ov::Tokenizer constructor.

src/cpp/src/generation_config.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <nlohmann/json.hpp>
88
#include <openvino/runtime/core.hpp>
99

10-
#include "openvino/genai/generation_config.hpp"
10+
#include "openvino_genai/generation_config.hpp"
1111

1212
#include "generation_config_helper.hpp"
1313

src/cpp/src/generation_config_helper.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#pragma once
55

6-
#include "openvino/genai/generation_config.hpp"
6+
#include "openvino_genai/generation_config.hpp"
77

88
namespace ov {
99

src/cpp/src/greedy_decoding.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#include "generation_config_helper.hpp"
5-
#include "openvino/genai/llm_pipeline.hpp"
5+
#include "openvino_genai/llm_pipeline.hpp"
66
#include "utils.hpp"
77

88
namespace ov {

src/cpp/src/group_beam_searcher.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#pragma once
55

66
#include <openvino/runtime/tensor.hpp>
7-
#include "openvino/genai/generation_config.hpp"
8-
#include "openvino/genai/llm_pipeline.hpp"
7+
#include "openvino_genai/generation_config.hpp"
8+
#include "openvino_genai/llm_pipeline.hpp"
99

1010
namespace ov {
1111
EncodedResults beam_search(ov::InferRequest& lm, ov::Tensor prompts, ov::Tensor attentin_mask, GenerationConfig sampling_params);

src/cpp/src/llm_pipeline.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <jinja2cpp/template_env.h>
1111

1212
#include <openvino/openvino.hpp>
13-
#include "openvino/genai/generation_config.hpp"
14-
#include "openvino/genai/llm_pipeline.hpp"
13+
#include "openvino_genai/generation_config.hpp"
14+
#include "openvino_genai/llm_pipeline.hpp"
1515
#include "utils.hpp"
1616
#include "generation_config_helper.hpp"
1717
#include "group_beam_searcher.hpp"

src/cpp/src/text_callback_streamer.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33
#pragma once
44

5-
#include "openvino/genai/streamer_base.hpp"
6-
#include "openvino/genai/tokenizer.hpp"
5+
#include "openvino_genai/streamer_base.hpp"
6+
#include "openvino_genai/tokenizer.hpp"
77

88
namespace ov {
99

src/cpp/src/tokenizer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#include <openvino/openvino.hpp>
5-
#include "openvino/genai/tokenizer.hpp"
5+
#include "openvino_genai/tokenizer.hpp"
66
#include "utils.hpp"
77

88
namespace {

src/python/CMakeLists.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ if(NOT pybind11_POPULATED)
1616
endif()
1717

1818
pybind11_add_module(py_generate_pipeline py_generate_pipeline.cpp)
19-
target_link_libraries(py_generate_pipeline PRIVATE generate_pipeline_lib)
19+
target_link_libraries(py_generate_pipeline PRIVATE openvino_genai)
2020

21-
install(TARGETS py_generate_pipeline LIBRARY DESTINATION . COMPONENT genai_python)
21+
# find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
22+
install(TARGETS py_generate_pipeline LIBRARY DESTINATION . COMPONENT pygenai_${Python_VERSION_MAJOR}_${Python_VERSION_MINOR})
2223

2324
# setting RPATH / LC_RPATH depending on platform
2425
if(LINUX)
25-
# to find libgenerate_pipeline_lib.so in the same folder
26+
# to find libgenai.so in the same folder
2627
set(rpaths "$ORIGIN")
2728
elseif(APPLE)
28-
# to find libgenerate_pipeline_lib.dylib in the same folder
29+
# to find libgenai.dylib in the same folder
2930
set(rpaths "@loader_path")
3031
if(DEFINED SKBUILD)
3132
# in case we build pip package, we need to refer to libopenvino.dylib from 'openvino' package

src/python/py_generate_pipeline.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <pybind11/pybind11.h>
55
#include <pybind11/stl.h>
66
#include <pybind11/functional.h>
7-
#include "openvino/genai/llm_pipeline.hpp"
7+
#include "openvino_genai/llm_pipeline.hpp"
88

99
namespace py = pybind11;
1010
using namespace ov;

text_generation/causal_lm/cpp/CMakeLists.txt

+17-9
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@
44
cmake_minimum_required(VERSION 3.15)
55
project(causal_lm)
66

7-
if(NOT TARGET openvino_tokenizers)
8-
add_subdirectory(../../../thirdparty/openvino_tokenizers/ "${CMAKE_CURRENT_BINARY_DIR}/openvino_tokenizers/")
7+
if(TARGET openvino_tokenizers)
8+
set(OPENVINO_TOKENIZERS_PATH $<TARGET_FILE:openvino_tokenizers>)
9+
else()
10+
set(OPENVINO_TOKENIZERS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../bin/openvino_tokenizers.dll) # TODO: I'll go away after the generate() gets a way to find openvino_tokenizers
911
endif()
1012

13+
if(openvino_genai_SOURCE_DIR)
14+
set(openvino_genai_DIR "${CMAKE_BINARY_DIR}")
15+
endif()
16+
17+
find_package(openvino_genai REQUIRED)
18+
1119
add_executable(greedy_causal_lm greedy_causal_lm.cpp)
12-
target_compile_definitions(greedy_causal_lm PRIVATE OPENVINO_TOKENIZERS_PATH=\"$<TARGET_FILE:openvino_tokenizers>\")
13-
target_link_libraries(greedy_causal_lm PRIVATE generate_pipeline_lib)
20+
target_compile_definitions(greedy_causal_lm PRIVATE OPENVINO_TOKENIZERS_PATH="${OPENVINO_TOKENIZERS_PATH}")
21+
target_link_libraries(greedy_causal_lm PRIVATE openvino::genai)
1422
set_target_properties(greedy_causal_lm PROPERTIES CXX_STANDARD 17)
1523
set_target_properties(greedy_causal_lm PROPERTIES CXX_STANDARD_REQUIRED ON)
1624

1725
add_executable(beam_search_causal_lm beam_search_causal_lm.cpp)
18-
target_link_libraries(beam_search_causal_lm PRIVATE generate_pipeline_lib)
26+
target_link_libraries(beam_search_causal_lm PRIVATE openvino::genai)
1927
set_target_properties(beam_search_causal_lm PROPERTIES CXX_STANDARD 17)
2028
set_target_properties(beam_search_causal_lm PROPERTIES CXX_STANDARD_REQUIRED ON)
2129

2230
add_executable(speculative_decoding_lm speculative_decoding_lm.cpp)
23-
target_compile_definitions(speculative_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH=\"$<TARGET_FILE:openvino_tokenizers>\")
31+
target_compile_definitions(speculative_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH="${OPENVINO_TOKENIZERS_PATH}")
2432
target_include_directories(speculative_decoding_lm PRIVATE ./)
2533
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
2634
target_link_libraries(speculative_decoding_lm PRIVATE openvino::runtime)
@@ -30,7 +38,7 @@ find_package(TBB REQUIRED COMPONENTS tbb)
3038
target_link_libraries(speculative_decoding_lm PRIVATE TBB::tbb)
3139

3240
add_executable(prompt_lookup_decoding_lm prompt_lookup_decoding_lm.cpp)
33-
target_compile_definitions(prompt_lookup_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH=\"$<TARGET_FILE:openvino_tokenizers>\")
41+
target_compile_definitions(prompt_lookup_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH="${OPENVINO_TOKENIZERS_PATH}")
3442
target_include_directories(prompt_lookup_decoding_lm PRIVATE ./)
3543
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
3644
target_link_libraries(prompt_lookup_decoding_lm PRIVATE openvino::runtime)
@@ -40,13 +48,13 @@ find_package(TBB REQUIRED COMPONENTS tbb)
4048
target_link_libraries(prompt_lookup_decoding_lm PRIVATE TBB::tbb)
4149

4250
add_executable(generate_sample generate_pipeline/generate_sample.cpp)
43-
target_link_libraries(generate_sample PRIVATE generate_pipeline_lib)
51+
target_link_libraries(generate_sample PRIVATE openvino::genai)
4452
target_include_directories(generate_sample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
4553
set_target_properties(generate_sample PROPERTIES CXX_STANDARD 17)
4654
set_target_properties(generate_sample PROPERTIES CXX_STANDARD_REQUIRED ON)
4755

4856
add_executable(chat_sample generate_pipeline/chat_sample.cpp)
49-
target_link_libraries(chat_sample PRIVATE generate_pipeline_lib)
57+
target_link_libraries(chat_sample PRIVATE openvino::genai)
5058
target_include_directories(chat_sample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
5159
set_target_properties(chat_sample PROPERTIES CXX_STANDARD 17)
5260
set_target_properties(chat_sample PROPERTIES CXX_STANDARD_REQUIRED ON)

text_generation/causal_lm/cpp/beam_search_causal_lm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2023-2024 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#include <openvino/genai/llm_pipeline.hpp>
4+
#include <openvino_genai/llm_pipeline.hpp>
55

66
int main(int argc, char* argv[]) try {
77
if (argc < 3) {

text_generation/causal_lm/cpp/generate_pipeline/chat_sample.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#include <openvino/openvino.hpp>
5-
#include "openvino/genai/llm_pipeline.hpp"
5+
#include "openvino_genai/llm_pipeline.hpp"
66

77
using namespace std;
88

text_generation/causal_lm/cpp/generate_pipeline/generate_sample.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2023-2024 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#include "openvino/genai/llm_pipeline.hpp"
4+
#include "openvino_genai/llm_pipeline.hpp"
55

66
using std::cout;
77
using std::endl;

text_generation/causal_lm/cpp/greedy_causal_lm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2023-2024 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#include "openvino/genai/llm_pipeline.hpp"
4+
#include "openvino_genai/llm_pipeline.hpp"
55

66
int main(int argc, char* argv[]) try {
77
if (3 > argc || argc > 4)

0 commit comments

Comments
 (0)