Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ft tokenizer url #151

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions csrc/fastdeploy/function/reduce.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ void ArgMinMax(const FDTensor& x, FDTensor* out, int64_t axis,
} else {
all_element_num = x_dims[axis];
}
FDASSERT(all_element_num <= std::numeric_limits<int>::max(),
FDASSERT(all_element_num <= (std::numeric_limits<int>::max)(),
"The element num of the argmin/argmax input at axis is "
"%lld, is larger than int32 maximum value:%d, you must "
"set the dtype of argmin/argmax to 'int64'.",
all_element_num, std::numeric_limits<int>::max());
all_element_num, (std::numeric_limits<int>::max)());
}
std::vector<int64_t> vec;
if (flatten) {
Expand Down
29 changes: 26 additions & 3 deletions external/faster_tokenizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,40 @@ set(FASTERTOKENIZER_INC_DIR
set(FASTERTOKENIZER_LIB_DIR
"${FASTERTOKENIZER_INSTALL_DIR}/lib/"
CACHE PATH "faster_tokenizer lib directory." FORCE)
set(FASTERTOKENIZER_THIRD_LIB_DIR
"${FASTERTOKENIZER_INSTALL_DIR}/third_party/lib/"
CACHE PATH "faster_tokenizer lib directory." FORCE)
set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}"
"${FASTERTOKENIZER_LIB_DIR}")

include_directories(${FASTERTOKENIZER_INC_DIR})

# Set lib path
if(WIN32)
set(FASTERTOKENIZER_COMPILE_LIB "${FASTERTOKENIZER_LIB_DIR}/core_tokenizers.lib"
CACHE FILEPATH "faster_tokenizer compile library." FORCE)
message("FASTERTOKENIZER_COMPILE_LIB = ${FASTERTOKENIZER_COMPILE_LIB}")
set(ICUDT_LIB "${FASTERTOKENIZER_THIRD_LIB_DIR}/icudt.lib")
set(ICUUC_LIB "${FASTERTOKENIZER_THIRD_LIB_DIR}/icuuc.lib")

elseif(APPLE)
# Not support apple so far.
else()

set(FASTERTOKENIZER_COMPILE_LIB "${FASTERTOKENIZER_LIB_DIR}/libcore_tokenizers.so"
CACHE FILEPATH "faster_tokenizer compile library." FORCE)
message("FASTERTOKENIZER_COMPILE_LIB = ${FASTERTOKENIZER_COMPILE_LIB}")
set(ICUDT_LIB "")
set(ICUUC_LIB "")
endif(WIN32)

set(FASTERTOKENIZER_URL_BASE "https://bj.bcebos.com/paddlenlp/faster_tokenizer/")
set(FASTERTOKENIZER_VERSION "dev")

# Set download url
if(WIN32)
set(FASTERTOKENIZER_FILE "faster_tokenizer-win-x64-${FASTERTOKENIZER_VERSION}.zip")
if(NOT CMAKE_CL_64)
set(FASTERTOKENIZER_FILE "faster_tokenizer-win-x86-${FASTERTOKENIZER_VERSION}.zip")
endif()
elseif(APPLE)
else()
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
Expand All @@ -76,4 +87,16 @@ ExternalProject_Add(
add_library(faster_tokenizer STATIC IMPORTED GLOBAL)
set_property(TARGET faster_tokenizer PROPERTY IMPORTED_LOCATION ${FASTERTOKENIZER_COMPILE_LIB})
add_dependencies(faster_tokenizer ${FASTERTOKENIZER_PROJECT})
list(APPEND DEPEND_LIBS faster_tokenizer)
list(APPEND DEPEND_LIBS faster_tokenizer)

if (WIN32)
add_library(icudt STATIC IMPORTED GLOBAL)
set_property(TARGET icudt PROPERTY IMPORTED_LOCATION ${ICUDT_LIB})
add_dependencies(icudt ${FASTERTOKENIZER_PROJECT})
list(APPEND DEPEND_LIBS icudt)

add_library(icuuc STATIC IMPORTED GLOBAL)
set_property(TARGET icuuc PROPERTY IMPORTED_LOCATION ${ICUUC_LIB})
add_dependencies(icuuc ${FASTERTOKENIZER_PROJECT})
list(APPEND DEPEND_LIBS icuuc)
endif()