Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Anders Xiao
2025-03-30 12:07:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-03-30 12:07:19 +0800
Commit
ce196fceae5a6c0dcc0bcf1d73c110b6d7aae6e1
ce196fce
1 parent
3420c898
fix dml with preinstall ort (#2066)
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
94 行增加
和
71 行删除
CMakeLists.txt
cmake/onnxruntime-win-x64-directml.cmake
cmake/onnxruntime.cmake
sherpa-onnx/csrc/CMakeLists.txt
CMakeLists.txt
查看文件 @
ce196fc
...
...
@@ -37,6 +37,8 @@ option(SHERPA_ONNX_ENABLE_C_API "Whether to build C API" ON)
option
(
SHERPA_ONNX_ENABLE_WEBSOCKET
"Whether to build webscoket server/client"
ON
)
option
(
SHERPA_ONNX_ENABLE_GPU
"Enable ONNX Runtime GPU support"
OFF
)
option
(
SHERPA_ONNX_ENABLE_DIRECTML
"Enable ONNX Runtime DirectML support"
OFF
)
option
(
SHERPA_ONNX_LINK_D3D
"Whether static ONNX runtime lib with DML"
OFF
)
option
(
SHERPA_ONNX_ENABLE_WASM
"Whether to enable WASM"
OFF
)
option
(
SHERPA_ONNX_ENABLE_WASM_SPEAKER_DIARIZATION
"Whether to enable WASM for speaker diarization"
OFF
)
option
(
SHERPA_ONNX_ENABLE_WASM_TTS
"Whether to enable WASM for TTS"
OFF
)
...
...
@@ -165,6 +167,7 @@ message(STATUS "SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE ${SHERPA_
message
(
STATUS
"SHERPA_ONNX_ENABLE_SANITIZER:
${
SHERPA_ONNX_ENABLE_SANITIZER
}
"
)
message
(
STATUS
"SHERPA_ONNX_BUILD_C_API_EXAMPLES:
${
SHERPA_ONNX_BUILD_C_API_EXAMPLES
}
"
)
message
(
STATUS
"SHERPA_ONNX_ENABLE_RKNN:
${
SHERPA_ONNX_ENABLE_RKNN
}
"
)
message
(
STATUS
"SHERPA_ONNX_LINK_D3D:
${
SHERPA_ONNX_LINK_D3D
}
"
)
if
(
BUILD_SHARED_LIBS OR SHERPA_ONNX_ENABLE_JNI
)
set
(
CMAKE_CXX_VISIBILITY_PRESET hidden
)
...
...
@@ -311,6 +314,7 @@ if(WIN32)
add_definitions
(
-DNOMINMAX
)
# Otherwise, std::max() and std::min() won't work
endif
()
if
(
WIN32 AND MSVC
)
# disable various warnings for MSVC
# 4244: 'return': conversion from 'unsigned __int64' to 'int', possible loss of data
...
...
cmake/onnxruntime-win-x64-directml.cmake
查看文件 @
ce196fc
...
...
@@ -19,81 +19,87 @@ if(NOT SHERPA_ONNX_ENABLE_DIRECTML)
message
(
FATAL_ERROR
"This file is for DirectML. Given SHERPA_ONNX_ENABLE_DIRECTML:
${
SHERPA_ONNX_ENABLE_DIRECTML
}
"
)
endif
()
set
(
onnxruntime_URL
"https://globalcdn.nuget.org/packages/microsoft.ml.onnxruntime.directml.1.14.1.nupkg"
)
set
(
onnxruntime_URL2
"https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/microsoft.ml.onnxruntime.directml.1.14.1.nupkg"
)
set
(
onnxruntime_HASH
"SHA256=c8ae7623385b19cd5de968d0df5383e13b97d1b3a6771c9177eac15b56013a5a"
)
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set
(
possible_file_locations
$ENV{HOME}/Downloads/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
${
PROJECT_SOURCE_DIR
}
/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
${
PROJECT_BINARY_DIR
}
/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
/tmp/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
)
foreach
(
f IN LISTS possible_file_locations
)
if
(
EXISTS
${
f
}
)
set
(
onnxruntime_URL
"
${
f
}
"
)
file
(
TO_CMAKE_PATH
"
${
onnxruntime_URL
}
"
onnxruntime_URL
)
message
(
STATUS
"Found local downloaded onnxruntime:
${
onnxruntime_URL
}
"
)
set
(
onnxruntime_URL2
)
break
()
endif
()
endforeach
()
FetchContent_Declare
(
onnxruntime
URL
${
onnxruntime_URL
}
${
onnxruntime_URL2
}
URL_HASH
${
onnxruntime_HASH
}
)
FetchContent_GetProperties
(
onnxruntime
)
if
(
NOT onnxruntime_POPULATED
)
message
(
STATUS
"Downloading onnxruntime from
${
onnxruntime_URL
}
"
)
FetchContent_Populate
(
onnxruntime
)
endif
()
message
(
STATUS
"onnxruntime is downloaded to
${
onnxruntime_SOURCE_DIR
}
"
)
find_library
(
location_onnxruntime onnxruntime
PATHS
"
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native"
NO_CMAKE_SYSTEM_PATH
)
message
(
STATUS
"location_onnxruntime:
${
location_onnxruntime
}
"
)
add_library
(
onnxruntime SHARED IMPORTED
)
set_target_properties
(
onnxruntime PROPERTIES
IMPORTED_LOCATION
${
location_onnxruntime
}
INTERFACE_INCLUDE_DIRECTORIES
"
${
onnxruntime_SOURCE_DIR
}
/build/native/include"
)
set_property
(
TARGET onnxruntime
PROPERTY
IMPORTED_IMPLIB
"
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native/onnxruntime.lib"
)
file
(
COPY
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native/onnxruntime.dll
DESTINATION
${
CMAKE_BINARY_DIR
}
/bin/
${
CMAKE_BUILD_TYPE
}
)
file
(
GLOB onnxruntime_lib_files
"
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native/onnxruntime.*"
)
if
(
location_onnxruntime_header_dir AND location_onnxruntime_lib
)
message
(
"Use preinstall onnxruntime with directml:
${
location_onnxruntime_lib
}
"
)
else
()
message
(
STATUS
"onnxruntime lib files:
${
onnxruntime_lib_files
}
"
)
set
(
onnxruntime_URL
"https://globalcdn.nuget.org/packages/microsoft.ml.onnxruntime.directml.1.14.1.nupkg"
)
set
(
onnxruntime_URL2
"https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/microsoft.ml.onnxruntime.directml.1.14.1.nupkg"
)
set
(
onnxruntime_HASH
"SHA256=c8ae7623385b19cd5de968d0df5383e13b97d1b3a6771c9177eac15b56013a5a"
)
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set
(
possible_file_locations
$ENV{HOME}/Downloads/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
${
PROJECT_SOURCE_DIR
}
/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
${
PROJECT_BINARY_DIR
}
/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
/tmp/microsoft.ml.onnxruntime.directml.1.14.1.nupkg
)
foreach
(
f IN LISTS possible_file_locations
)
if
(
EXISTS
${
f
}
)
set
(
onnxruntime_URL
"
${
f
}
"
)
file
(
TO_CMAKE_PATH
"
${
onnxruntime_URL
}
"
onnxruntime_URL
)
message
(
STATUS
"Found local downloaded onnxruntime:
${
onnxruntime_URL
}
"
)
set
(
onnxruntime_URL2
)
break
()
endif
()
endforeach
()
FetchContent_Declare
(
onnxruntime
URL
${
onnxruntime_URL
}
${
onnxruntime_URL2
}
URL_HASH
${
onnxruntime_HASH
}
)
FetchContent_GetProperties
(
onnxruntime
)
if
(
NOT onnxruntime_POPULATED
)
message
(
STATUS
"Downloading onnxruntime from
${
onnxruntime_URL
}
"
)
FetchContent_Populate
(
onnxruntime
)
endif
()
message
(
STATUS
"onnxruntime is downloaded to
${
onnxruntime_SOURCE_DIR
}
"
)
find_library
(
location_onnxruntime onnxruntime
PATHS
"
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native"
NO_CMAKE_SYSTEM_PATH
)
message
(
STATUS
"location_onnxruntime:
${
location_onnxruntime
}
"
)
add_library
(
onnxruntime SHARED IMPORTED
)
set_target_properties
(
onnxruntime PROPERTIES
IMPORTED_LOCATION
${
location_onnxruntime
}
INTERFACE_INCLUDE_DIRECTORIES
"
${
onnxruntime_SOURCE_DIR
}
/build/native/include"
)
set_property
(
TARGET onnxruntime
PROPERTY
IMPORTED_IMPLIB
"
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native/onnxruntime.lib"
)
file
(
COPY
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native/onnxruntime.dll
DESTINATION
${
CMAKE_BINARY_DIR
}
/bin/
${
CMAKE_BUILD_TYPE
}
)
file
(
GLOB onnxruntime_lib_files
"
${
onnxruntime_SOURCE_DIR
}
/runtimes/win-x64/native/onnxruntime.*"
)
message
(
STATUS
"onnxruntime lib files:
${
onnxruntime_lib_files
}
"
)
if
(
SHERPA_ONNX_ENABLE_PYTHON
)
install
(
FILES
${
onnxruntime_lib_files
}
DESTINATION ..
)
else
()
install
(
FILES
${
onnxruntime_lib_files
}
DESTINATION lib
)
endif
()
install
(
FILES
${
onnxruntime_lib_files
}
DESTINATION bin
)
if
(
SHERPA_ONNX_ENABLE_PYTHON
)
install
(
FILES
${
onnxruntime_lib_files
}
DESTINATION ..
)
else
()
install
(
FILES
${
onnxruntime_lib_files
}
DESTINATION lib
)
endif
()
install
(
FILES
${
onnxruntime_lib_files
}
DESTINATION bin
)
# Setup DirectML
set
(
directml_URL
"https://www.nuget.org/api/v2/package/Microsoft.AI.DirectML/1.15.0"
)
...
...
cmake/onnxruntime.cmake
查看文件 @
ce196fc
...
...
@@ -154,6 +154,9 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE)
set
(
location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.dylib
)
elseif
(
WIN32
)
set
(
location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.lib
)
if
(
SHERPA_ONNX_ENABLE_DIRECTML
)
include
(
onnxruntime-win-x64-directml
)
endif
()
else
()
set
(
location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.so
)
endif
()
...
...
sherpa-onnx/csrc/CMakeLists.txt
查看文件 @
ce196fc
...
...
@@ -216,6 +216,16 @@ endif()
# Always static build
add_library
(
sherpa-onnx-core STATIC
${
sources
}
)
if
(
WIN32 AND SHERPA_ONNX_LINK_D3D
)
target_link_libraries
(
sherpa-onnx-core dxguid.lib d3d12.lib dxgi.lib dxcore.lib
)
endif
()
if
(
TARGET directml
)
target_link_libraries
(
sherpa-onnx-core directml
)
endif
()
set_target_properties
(
sherpa-onnx-core
PROPERTIES
...
...
请
注册
或
登录
后发表评论