@ -1,10 +0,0 @@ |
|||||
FetchContent_Declare(boost |
|
||||
URL https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz |
|
||||
URL_HASH SHA256=aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a |
|
||||
) |
|
||||
FetchContent_MakeAvailable(boost) |
|
||||
include_directories(${boost_SOURCE_DIR}) |
|
||||
|
|
||||
if(MSVC) |
|
||||
add_definitions(-DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB) |
|
||||
endif() |
|
@ -1,30 +0,0 @@ |
|||||
if(BPU) |
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") |
|
||||
set(EASY_DNN_URL "https://github.com/xingchensong/toolchain_pkg/releases/download/easy_dnn/easy_dnn.0.4.11.tar.gz") |
|
||||
set(URL_HASH "SHA256=a1a6f77d1baae7181d75ec5d37a2ee529ac4e1c4400babd6ceb1c007392a4904") |
|
||||
else() |
|
||||
message(FATAL_ERROR "Unsupported CMake System Processor '${CMAKE_SYSTEM_PROCESSOR}' (expected 'aarch64')") |
|
||||
endif() |
|
||||
else() |
|
||||
message(FATAL_ERROR "Unsupported CMake System Name '${CMAKE_SYSTEM_NAME}' (expected 'Linux')") |
|
||||
endif() |
|
||||
|
|
||||
FetchContent_Declare(easy_dnn |
|
||||
URL ${EASY_DNN_URL} |
|
||||
URL_HASH ${URL_HASH} |
|
||||
) |
|
||||
FetchContent_MakeAvailable(easy_dnn) |
|
||||
include_directories(${easy_dnn_SOURCE_DIR}/easy_dnn/0.4.11_linux_aarch64-j3_hobot_gcc6.5.0/files/easy_dnn/include) |
|
||||
include_directories(${easy_dnn_SOURCE_DIR}/dnn/1.7.0_linux_aarch64-j3_hobot_gcc6.5.0/files/dnn/include) |
|
||||
include_directories(${easy_dnn_SOURCE_DIR}/hlog/0.4.7_linux_aarch64-j3_hobot_gcc6.5.0/files/hlog/include) |
|
||||
link_directories(${easy_dnn_SOURCE_DIR}/easy_dnn/0.4.11_linux_aarch64-j3_hobot_gcc6.5.0/files/easy_dnn/lib) |
|
||||
link_directories(${easy_dnn_SOURCE_DIR}/dnn/1.7.0_linux_aarch64-j3_hobot_gcc6.5.0/files/dnn/lib) |
|
||||
link_directories(${easy_dnn_SOURCE_DIR}/hlog/0.4.7_linux_aarch64-j3_hobot_gcc6.5.0/files/hlog/lib) |
|
||||
|
|
||||
add_definitions(-DUSE_BPU) |
|
||||
# NOTE(xcsong): Reasons for adding flag `-fuse-ld=gold`: |
|
||||
# https://stackoverflow.com/questions/59915966/unknown-gcc-linker-error-but-builds-sucessfully/59916438#59916438 |
|
||||
# https://github.com/tensorflow/tensorflow/issues/47849 |
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") |
|
||||
endif() |
|
@ -1,8 +0,0 @@ |
|||||
FetchContent_Declare(googletest |
|
||||
URL https://github.com/google/googletest/archive/release-1.11.0.zip |
|
||||
URL_HASH SHA256=353571c2440176ded91c2de6d6cd88ddd41401d14692ec1f99e35d013feda55a |
|
||||
) |
|
||||
if(MSVC) |
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "Always use msvcrt.dll" FORCE) |
|
||||
endif() |
|
||||
FetchContent_MakeAvailable(googletest) |
|
@ -1,40 +0,0 @@ |
|||||
add_definitions(-DUSE_TORCH) |
|
||||
add_definitions(-DUSE_IPEX) |
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
|
||||
message(FATAL_ERROR "Intel Extension For PyTorch supports only Linux for now") |
|
||||
endif() |
|
||||
|
|
||||
if(CXX11_ABI) |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip") |
|
||||
set(URL_HASH "SHA256=137a842d1cf1e9196b419390133a1623ef92f8f84dc7a072f95ada684f394afd") |
|
||||
else() |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.0.1%2Bcpu.zip") |
|
||||
set(URL_HASH "SHA256=90d50350fd24ce5cf9dfbf47888d0cfd9f943eb677f481b86fe1b8e90f7fda5d") |
|
||||
endif() |
|
||||
FetchContent_Declare(libtorch |
|
||||
URL ${LIBTORCH_URL} |
|
||||
URL_HASH ${URL_HASH} |
|
||||
) |
|
||||
FetchContent_MakeAvailable(libtorch) |
|
||||
find_package(Torch REQUIRED PATHS ${libtorch_SOURCE_DIR} NO_DEFAULT_PATH) |
|
||||
|
|
||||
if(CXX11_ABI) |
|
||||
set(LIBIPEX_URL "https://intel-optimized-pytorch.s3.cn-north-1.amazonaws.com.cn/libipex/cpu/libintel-ext-pt-cxx11-abi-2.0.100%2Bcpu.run") |
|
||||
set(URL_HASH "SHA256=f172d9ebc2ca0c39cc93bb395721194f79767e1bc3f82b13e1edc07d1530a600") |
|
||||
set(LIBIPEX_SCRIPT_NAME "libintel-ext-pt-cxx11-abi-2.0.100%2Bcpu.run") |
|
||||
else() |
|
||||
set(LIBIPEX_URL "https://intel-optimized-pytorch.s3.cn-north-1.amazonaws.com.cn/libipex/cpu/libintel-ext-pt-2.0.100%2Bcpu.run") |
|
||||
set(URL_HASH "SHA256=8392f965dd9b8f6c0712acbb805c7e560e4965a0ade279b47a5f5a8363888268") |
|
||||
set(LIBIPEX_SCRIPT_NAME "libintel-ext-pt-2.0.100%2Bcpu.run") |
|
||||
endif() |
|
||||
FetchContent_Declare(intel_ext_pt |
|
||||
URL ${LIBIPEX_URL} |
|
||||
URL_HASH ${URL_HASH} |
|
||||
DOWNLOAD_DIR ${FETCHCONTENT_BASE_DIR} |
|
||||
DOWNLOAD_NO_EXTRACT TRUE |
|
||||
PATCH_COMMAND bash ${FETCHCONTENT_BASE_DIR}/${LIBIPEX_SCRIPT_NAME} install ${libtorch_SOURCE_DIR} |
|
||||
) |
|
||||
FetchContent_MakeAvailable(intel_ext_pt) |
|
||||
find_package(IPEX REQUIRED PATHS ${libtorch_SOURCE_DIR} NO_DEFAULT_PATH) |
|
||||
|
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -DC10_USE_GLOG") |
|
@ -1,80 +0,0 @@ |
|||||
if(TORCH) |
|
||||
set(TORCH_VERSION "2.1.0") |
|
||||
add_definitions(-DUSE_TORCH) |
|
||||
if(NOT ANDROID) |
|
||||
if(GPU) |
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
|
||||
message(FATAL_ERROR "GPU is supported only Linux, you can use CPU version") |
|
||||
else() |
|
||||
add_definitions(-DUSE_GPU) |
|
||||
endif() |
|
||||
endif() |
|
||||
|
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Release") |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-${TORCH_VERSION}%2Bcpu.zip") |
|
||||
set(URL_HASH "SHA256=77815aa799f15e91b6fbb0216ac78cc0479adb5cd0ca662072241484cf23f667") |
|
||||
else() |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-debug-${TORCH_VERSION}%2Bcpu.zip") |
|
||||
set(URL_HASH "SHA256=5f887c02d9abf805c8b53fef89bf5a4dab9dd78771754344e73c98d9c484aa9d") |
|
||||
endif() |
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
|
||||
if(CXX11_ABI) |
|
||||
if(NOT GPU) |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-${TORCH_VERSION}%2Bcpu.zip") |
|
||||
set(URL_HASH "SHA256=04f699d5181048b0062ef52de1df44b46859b8fbeeee12abdbcb9aac63e2a14b") |
|
||||
else() |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-${TORCH_VERSION}%2Bcu118.zip") |
|
||||
set(URL_HASH "SHA256=7796249faa9828a53b72d3f616fc97a1d9e87e6a35ac72b392ca1ddc7b125188") |
|
||||
endif() |
|
||||
else() |
|
||||
if(NOT GPU) |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-${TORCH_VERSION}%2Bcpu.zip") |
|
||||
set(URL_HASH "SHA256=0e86d364d05b83c6c66c3bb32e7eee932847843e4085487eefd9b3bbde4e2c58") |
|
||||
else() |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cu118/libtorch-shared-with-deps-${TORCH_VERSION}%2Bcu118.zip") |
|
||||
set(URL_HASH "SHA256=f70cfae25b02ff419e1d51ad137a746941773d2c4b0155a44b4b6b50702d661a") |
|
||||
endif() |
|
||||
endif() |
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") |
|
||||
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-macos-${TORCH_VERSION}.zip") |
|
||||
set(URL_HASH "SHA256=ce744d2d27a96df8f34d4227e8b1179dad5a76612dc7230b61db65affce6e7bd") |
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "iOS") |
|
||||
add_definitions(-DIOS) |
|
||||
else() |
|
||||
message(FATAL_ERROR "Unsupported System '${CMAKE_SYSTEM_NAME}' (expected 'Windows', 'Linux', 'Darwin' or 'iOS')") |
|
||||
endif() |
|
||||
|
|
||||
# iOS use LibTorch from pod install |
|
||||
if(NOT IOS) |
|
||||
FetchContent_Declare(libtorch |
|
||||
URL ${LIBTORCH_URL} |
|
||||
URL_HASH ${URL_HASH} |
|
||||
) |
|
||||
FetchContent_MakeAvailable(libtorch) |
|
||||
find_package(Torch REQUIRED PATHS ${libtorch_SOURCE_DIR} NO_DEFAULT_PATH) |
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -DC10_USE_GLOG") |
|
||||
endif() |
|
||||
|
|
||||
if(MSVC) |
|
||||
file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll") |
|
||||
file(COPY ${TORCH_DLLS} DESTINATION ${CMAKE_BINARY_DIR}) |
|
||||
endif() |
|
||||
else() |
|
||||
# Change version in runtime/android/app/build.gradle. |
|
||||
file(GLOB PYTORCH_INCLUDE_DIRS "${build_DIR}/pytorch_android*.aar/headers") |
|
||||
file(GLOB PYTORCH_LINK_DIRS "${build_DIR}/pytorch_android*.aar/jni/${ANDROID_ABI}") |
|
||||
find_library(PYTORCH_LIBRARY pytorch_jni |
|
||||
PATHS ${PYTORCH_LINK_DIRS} |
|
||||
NO_CMAKE_FIND_ROOT_PATH |
|
||||
) |
|
||||
find_library(FBJNI_LIBRARY fbjni |
|
||||
PATHS ${PYTORCH_LINK_DIRS} |
|
||||
NO_CMAKE_FIND_ROOT_PATH |
|
||||
) |
|
||||
include_directories( |
|
||||
${PYTORCH_INCLUDE_DIRS} |
|
||||
${PYTORCH_INCLUDE_DIRS}/torch/csrc/api/include |
|
||||
) |
|
||||
endif() |
|
||||
endif() |
|
@ -1,47 +0,0 @@ |
|||||
if(NOT ANDROID) |
|
||||
include(gflags) |
|
||||
# We can't build glog with gflags, unless gflags is pre-installed. |
|
||||
# If build glog with pre-installed gflags, there will be conflict. |
|
||||
set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE) |
|
||||
include(glog) |
|
||||
|
|
||||
if(NOT GRAPH_TOOLS) |
|
||||
set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE) |
|
||||
set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE) |
|
||||
endif() |
|
||||
set(HAVE_COMPACT OFF CACHE BOOL "Build compact" FORCE) |
|
||||
set(HAVE_CONST OFF CACHE BOOL "Build const" FORCE) |
|
||||
set(HAVE_GRM OFF CACHE BOOL "Build grm" FORCE) |
|
||||
set(HAVE_FAR OFF CACHE BOOL "Build far" FORCE) |
|
||||
set(HAVE_PDT OFF CACHE BOOL "Build pdt" FORCE) |
|
||||
set(HAVE_MPDT OFF CACHE BOOL "Build mpdt" FORCE) |
|
||||
set(HAVE_LINEAR OFF CACHE BOOL "Build linear" FORCE) |
|
||||
set(HAVE_LOOKAHEAD OFF CACHE BOOL "Build lookahead" FORCE) |
|
||||
set(HAVE_NGRAM OFF CACHE BOOL "Build ngram" FORCE) |
|
||||
set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE) |
|
||||
|
|
||||
if(MSVC) |
|
||||
add_compile_options(/W0 /wd4244 /wd4267) |
|
||||
endif() |
|
||||
|
|
||||
# "OpenFST port for Windows" builds openfst with cmake for multiple platforms. |
|
||||
# Openfst is compiled with glog/gflags to avoid log and flag conflicts with log and flags in wenet/libtorch. |
|
||||
# To build openfst with gflags and glog, we comment out some vars of {flags, log}.h and flags.cc. |
|
||||
set(openfst_SOURCE_DIR ${fc_base}/openfst-src CACHE PATH "OpenFST source directory") |
|
||||
FetchContent_Declare(openfst |
|
||||
URL https://github.com/kkm000/openfst/archive/refs/tags/win/1.7.2.1.tar.gz |
|
||||
URL_HASH SHA256=e04e1dabcecf3a687ace699ccb43a8a27da385777a56e69da6e103344cc66bca |
|
||||
#URL https://github.com/kkm000/openfst/archive/refs/tags/win/1.6.5.1.tar.gz |
|
||||
#URL_HASH SHA256=02c49b559c3976a536876063369efc0e41ab374be1035918036474343877046e |
|
||||
PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${openfst_SOURCE_DIR} |
|
||||
) |
|
||||
FetchContent_MakeAvailable(openfst) |
|
||||
add_dependencies(fst gflags glog) |
|
||||
target_link_libraries(fst PUBLIC gflags_nothreads_static glog) |
|
||||
include_directories(${openfst_SOURCE_DIR}/src/include) |
|
||||
else() |
|
||||
set(openfst_BINARY_DIR ${build_DIR}/wenet-openfst-android-1.0.2.aar/jni) |
|
||||
include_directories(${openfst_BINARY_DIR}/include) |
|
||||
link_directories(${openfst_BINARY_DIR}/${ANDROID_ABI}) |
|
||||
link_libraries(log gflags_nothreads glog fst) |
|
||||
endif() |
|
@ -1,5 +0,0 @@ |
|||||
FetchContent_Declare(pybind11 |
|
||||
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.9.2.zip |
|
||||
URL_HASH SHA256=d1646e6f70d8a3acb2ddd85ce1ed543b5dd579c68b8fb8e9638282af20edead8 |
|
||||
) |
|
||||
FetchContent_MakeAvailable(pybind11) |
|
@ -1,37 +0,0 @@ |
|||||
if(NOT WIN32) |
|
||||
string(ASCII 27 Esc) |
|
||||
set(ColourReset "${Esc}[m") |
|
||||
set(ColourBold "${Esc}[1m") |
|
||||
set(Red "${Esc}[31m") |
|
||||
set(Green "${Esc}[32m") |
|
||||
set(Yellow "${Esc}[33m") |
|
||||
set(Blue "${Esc}[34m") |
|
||||
set(Magenta "${Esc}[35m") |
|
||||
set(Cyan "${Esc}[36m") |
|
||||
set(White "${Esc}[37m") |
|
||||
set(BoldRed "${Esc}[1;31m") |
|
||||
set(BoldGreen "${Esc}[1;32m") |
|
||||
set(BoldYellow "${Esc}[1;33m") |
|
||||
set(BoldBlue "${Esc}[1;34m") |
|
||||
set(BoldMagenta "${Esc}[1;35m") |
|
||||
set(BoldCyan "${Esc}[1;36m") |
|
||||
set(BoldWhite "${Esc}[1;37m") |
|
||||
endif() |
|
||||
|
|
||||
if(XPU) |
|
||||
set(RUNTIME_KUNLUN_PATH ${CMAKE_CURRENT_SOURCE_DIR}) |
|
||||
message(STATUS "RUNTIME_KUNLUN_PATH is ${RUNTIME_KUNLUN_PATH} .\n") |
|
||||
set(KUNLUN_XPU_PATH ${RUNTIME_KUNLUN_PATH}/xpu) |
|
||||
if(NOT DEFINED ENV{XPU_API_PATH}) |
|
||||
message(FATAL_ERROR "${BoldRed}NO ENV{XPU_API_PATH} in your env. Please set XPU_API_PATH.${ColourReset}\n") |
|
||||
else() |
|
||||
set(XPU_API_PATH $ENV{XPU_API_PATH}) |
|
||||
message("set XPU_API_PATH from env_var. Val is $ENV{XPU_API_PATH}.") |
|
||||
endif() |
|
||||
|
|
||||
include_directories(${RUNTIME_KUNLUN_PATH} ${KUNLUN_XPU_PATH}/ |
|
||||
${XPU_API_PATH}/output/include ${XPU_API_PATH}/../runtime/include) |
|
||||
link_directories(${XPU_API_PATH}/output/so/ ${XPU_API_PATH}/../runtime/output/so/) |
|
||||
|
|
||||
add_definitions(-DUSE_XPU) |
|
||||
endif() |
|