Skip to content

Commit

Permalink
win build
Browse files Browse the repository at this point in the history
  • Loading branch information
mryzhov committed Nov 22, 2023
1 parent 22613d6 commit a040b03
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

setup(
packages=["ov_tokenizer"],
package_dir={"": "src/tokenizer/python"},
cmake_install_dir="src/tokenizer/python/ov_tokenizer/libs",
package_dir={"": "user_ie_extensions/src/tokenizer/python"},
cmake_install_dir="user_ie_extensions/src/tokenizer/python/ov_tokenizer/libs",
cmake_args=['-DCUSTOM_OPERATIONS:STRING=tokenizer',
'-DBUILD_FAST_TOKENIZERS=OFF']
)
Expand Down
5 changes: 4 additions & 1 deletion modules/custom_operations/user_ie_extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ set(OP_REQ_TBB "complex_mul" "fft")
set(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)

#
# Select specific operations
#
Expand Down Expand Up @@ -101,7 +105,6 @@ endif()
# Left sentence_piece for backward compatibility
if("tokenizer" IN_LIST CUSTOM_OPERATIONS)
add_subdirectory(${SOURCES}/tokenizer)
install(FILES ${FAST_TOKENIZER_LIBS} DESTINATION .)
endif()

target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ endif()

option(BUILD_FAST_TOKENIZERS OFF)

# to build only sentencepiece-static target
# set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# PROPERTY EXCLUDE_FROM_ALL ON)

#
# Compile flags
#
Expand Down Expand Up @@ -116,7 +112,8 @@ else()
if(WIN32 AND X86_64)
# we use re2 library in regex_normalization operation, so have to add to this list
# because prebuilt fast_tokenizers package does not provide this library
list(APPEND FAST_TOKENIZER_LIBS re2)
# list(APPEND FAST_TOKENIZER_LIBS re2)
set (RE2_LIBS re2)
endif()
endif()

Expand All @@ -138,15 +135,21 @@ target_include_directories(${TARGET_NAME} PRIVATE
set_property(DIRECTORY ${sentencepiece_SOURCE_DIR}
PROPERTY EXCLUDE_FROM_ALL ON)

set_property(DIRECTORY ${re2_SOURCE_DIR}
PROPERTY EXCLUDE_FROM_ALL ON)

if(CMAKE_CL_64)
target_compile_definitions(sentencepiece-static PRIVATE _CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS)
endif()

target_link_libraries(${TARGET_NAME} PRIVATE ${FAST_TOKENIZER_LIBS} sentencepiece-static)
target_link_libraries(${TARGET_NAME} PRIVATE ${FAST_TOKENIZER_LIBS} ${RE2_LIBS} sentencepiece-static)

# string_view is used from cxx17
string(REPLACE " " ";" cxx_flags "${cxx_flags}")
set_target_properties(${TARGET_NAME} PROPERTIES CXX_STANDARD 17
COMPILE_OPTIONS "${cxx_flags}")

install(FILES ${FAST_TOKENIZER_LIBS} DESTINATION .)
file(GLOB DEPS_LIBS ${fast_tokenizer_SOURCE_DIR}/lib/*.dll ${fast_tokenizer_SOURCE_DIR}/third_party/lib/*.dll)
file(COPY ${DEPS_LIBS} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})

install(FILES ${DEPS_LIBS} DESTINATION .)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
_ext_path = os.path.join(_ext_libs_path, "libuser_ov_extensions.so")

if sys.platform == "win32":
_ext_path = os.path.join(_ext_libs_path, "libuser_ov_extensions.dll")
_ext_libs_path = os.path.join(_ext_libs_path, "bin")
_ext_path = os.path.join(_ext_libs_path, "user_ov_extensions.dll")
if os.path.isdir(_ext_libs_path):
# On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.
os.add_dll_directory(os.path.abspath(_ext_path))
Expand Down

0 comments on commit a040b03

Please sign in to comment.