Skip to content

Commit 3a773e6

Browse files
committed
fix link error.
Signed-off-by: xipingya <xiping.yan@intel.com>
1 parent 23d8aa0 commit 3a773e6

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

src/cpp/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ endif()
8888
# yaml-cpp dependency (use centralized cmake module)
8989
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/yaml-cpp.cmake)
9090

91-
find_package(TBB REQUIRED)
92-
9391
if(NOT TARGET minja)
9492
FetchContent_Declare(
9593
minja
@@ -225,7 +223,7 @@ endif()
225223

226224
target_include_directories(${TARGET_NAME_OBJ} SYSTEM PRIVATE "${safetensors.h_SOURCE_DIR}")
227225

228-
target_link_libraries(${TARGET_NAME_OBJ} PRIVATE openvino::runtime openvino::threading nlohmann_json::nlohmann_json minja ${YAML_CPP_TARGET} PRIVATE TBB::tbb)
226+
target_link_libraries(${TARGET_NAME_OBJ} PRIVATE openvino::runtime openvino::threading nlohmann_json::nlohmann_json minja ${YAML_CPP_TARGET})
229227

230228
# modeling/ sources use internal OpenVINO dev-api headers (e.g. openvino/op/linear_attn.hpp)
231229
# openvino::core::dev exposes src/core/dev_api which contains these headers.

src/python/py_utils.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -455,23 +455,13 @@ ov::genai::StreamerVariant pystreamer_to_streamer(const PyBindStreamerVariant& p
455455
[](std::function<std::optional<uint16_t>(py::str)>* f) {
456456
if (Py_IsInitialized()) {
457457
py::gil_scoped_acquire acquire;
458+
delete f;
459+
} else {
460+
delete f;
461+
}
458462
}
459463
);
460464

461-
py::gil_scoped_acquire acquire;
462-
PyObject* py_str = PyUnicode_DecodeUTF8(subword.data(), subword.length(), "replace");
463-
if (!py_str) {
464-
PyErr_Clear();
465-
return StreamingStatus::RUNNING;
466-
}
467-
std::optional<uint16_t> callback_output = (*shared_callback)(py::reinterpret_steal<py::str>(py_str));
468-
if (callback_output.has_value()) {
469-
if (*callback_output == (uint16_t)StreamingStatus::RUNNING)
470-
return StreamingStatus::RUNNING;
471-
else if (*callback_output == (uint16_t)StreamingStatus::CANCEL)
472-
return StreamingStatus::CANCEL;
473-
return StreamingStatus::STOP;
474-
} else {
475465
auto callback_wrapped = [shared_callback = std::move(shared_callback)](std::string subword) -> ov::genai::StreamingStatus {
476466
py::gil_scoped_acquire acquire;
477467
PyObject* py_str = PyUnicode_DecodeUTF8(subword.data(), subword.length(), "replace");

src/python/py_vlm_pipeline.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,26 @@ void init_vlm_pipeline(py::module_& m) {
284284
py::arg("streamer") = std::monostate(), "streamer",
285285
(vlm_generate_prompt_docstring + std::string(" \n ")).c_str()
286286
)
287+
.def(
288+
"generate",
289+
[](ov::genai::VLMPipeline& pipe,
290+
const std::string& prompt,
291+
const ov::Tensor& image,
292+
const ov::genai::GenerationConfig& generation_config,
293+
const pyutils::PyBindStreamerVariant& streamer,
294+
const py::kwargs& kwargs
295+
) -> py::typing::Union<ov::genai::VLMDecodedResults> {
296+
return call_vlm_generate(pipe, prompt, {image}, {}, generation_config, streamer, kwargs);
297+
},
298+
py::arg("prompt"), "Input string",
299+
py::arg("image"), "Input image",
300+
py::arg("generation_config"), "generation_config",
301+
py::arg("streamer") = std::monostate(), "streamer",
302+
(vlm_generate_prompt_docstring + std::string(" \n ")).c_str()
303+
)
304+
.def(
305+
"generate",
306+
[](ov::genai::VLMPipeline& pipe,
287307
const std::string& prompt,
288308
const py::kwargs& kwargs
289309
) -> py::typing::Union<ov::genai::VLMDecodedResults> {

tests/module_genai/cpp/CMakeLists.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ set(TEST_TARGET_NAME "genai_modules_test")
3939
add_executable(${TEST_TARGET_NAME} ${src_modules} ${src_pipelines} ${src_utils} $<TARGET_OBJECTS:openvino_genai_obj>)
4040

4141
get_target_property(genai_link_libraries openvino::genai LINK_LIBRARIES)
42-
if(genai_link_libraries)
43-
set(filtered_genai_link_libraries ${genai_link_libraries})
44-
if(NOT TARGET OpenCL::OpenCL)
45-
list(REMOVE_ITEM filtered_genai_link_libraries OpenCL::OpenCL)
46-
endif()
47-
endif()
42+
set(filtered_genai_link_libraries ${genai_link_libraries})
43+
list(REMOVE_ITEM filtered_genai_link_libraries OpenCL::OpenCL)
4844

4945
target_link_libraries(${TEST_TARGET_NAME} PRIVATE ${filtered_genai_link_libraries} gtest_main gmock_main ${OpenCV_LIBS})
46+
47+
if(ENABLE_SYSTEM_OPENCL)
48+
find_library(SYSTEM_OPENCL_LIBRARY NAMES OpenCL)
49+
if(SYSTEM_OPENCL_LIBRARY)
50+
target_link_libraries(${TEST_TARGET_NAME} PRIVATE ${SYSTEM_OPENCL_LIBRARY})
51+
else()
52+
message(WARNING "OpenCL library was not found; module tests that require OpenCL may fail to link")
53+
endif()
54+
endif()
5055
target_include_directories(${TEST_TARGET_NAME} PRIVATE "${OpenVINOGenAI_SOURCE_DIR}/src/cpp/src"
5156
"${CMAKE_CURRENT_SOURCE_DIR}"
5257
$<TARGET_PROPERTY:openvino::genai,INTERFACE_INCLUDE_DIRECTORIES>

0 commit comments

Comments
 (0)