Committed by
GitHub
Support windows x86 platform (#86)
* support windows x86 platform * improve cmake * resolve comments --------- Co-authored-by: Jian You (jianyou) <jianyou@cisco.com>
正在显示
3 个修改的文件
包含
34 行增加
和
14 行删除
| @@ -37,9 +37,8 @@ endif() | @@ -37,9 +37,8 @@ endif() | ||
| 37 | set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN}) | 37 | set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN}) |
| 38 | set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN}) | 38 | set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN}) |
| 39 | 39 | ||
| 40 | -if(WIN32 AND BUILD_SHARED_LIBS) | ||
| 41 | - message(STATUS "Set BUILD_SHARED_LIBS to OFF for windows") | ||
| 42 | - set(BUILD_SHARED_LIBS OFF) | 40 | +if(BUILD_SHARED_LIBS AND MSVC) |
| 41 | + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
| 43 | endif() | 42 | endif() |
| 44 | 43 | ||
| 45 | if(NOT CMAKE_BUILD_TYPE) | 44 | if(NOT CMAKE_BUILD_TYPE) |
| @@ -54,15 +54,32 @@ function(download_onnxruntime) | @@ -54,15 +54,32 @@ function(download_onnxruntime) | ||
| 54 | elseif(WIN32) | 54 | elseif(WIN32) |
| 55 | # If you don't have access to the Internet, | 55 | # If you don't have access to the Internet, |
| 56 | # please pre-download onnxruntime | 56 | # please pre-download onnxruntime |
| 57 | - set(possible_file_locations | ||
| 58 | - $ENV{HOME}/Downloads/onnxruntime-win-x64-1.14.0.zip | ||
| 59 | - ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-1.14.0.zip | ||
| 60 | - ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-1.14.0.zip | ||
| 61 | - /tmp/onnxruntime-win-x64-1.14.0.zip | ||
| 62 | - ) | ||
| 63 | - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-win-x64-1.14.0.zip") | ||
| 64 | - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-1.14.0.zip") | ||
| 65 | - set(onnxruntime_HASH "SHA256=300eafef456748cde2743ee08845bd40ff1bab723697ff934eba6d4ce3519620") | 57 | + |
| 58 | + if(CMAKE_VS_PLATFORM_NAME STREQUAL Win32) | ||
| 59 | + # for 32-bit windows | ||
| 60 | + set(possible_file_locations | ||
| 61 | + $ENV{HOME}/Downloads/onnxruntime-win-x86-1.14.0.zip | ||
| 62 | + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-1.14.0.zip | ||
| 63 | + ${PROJECT_BINARY_DIR}/onnxruntime-win-x86-1.14.0.zip | ||
| 64 | + /tmp/onnxruntime-win-x86-1.14.0.zip | ||
| 65 | + ) | ||
| 66 | + | ||
| 67 | + set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-win-x86-1.14.0.zip") | ||
| 68 | + set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x86-1.14.0.zip") | ||
| 69 | + set(onnxruntime_HASH "SHA256=4214b130db602cbf31a6f26f25377ab077af0cf03c4ddd4651283e1fb68f56cf") | ||
| 70 | + else() | ||
| 71 | + # for 64-bit windows | ||
| 72 | + set(possible_file_locations | ||
| 73 | + $ENV{HOME}/Downloads/onnxruntime-win-x64-1.14.0.zip | ||
| 74 | + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-1.14.0.zip | ||
| 75 | + ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-1.14.0.zip | ||
| 76 | + /tmp/onnxruntime-win-x64-1.14.0.zip | ||
| 77 | + ) | ||
| 78 | + | ||
| 79 | + set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-win-x64-1.14.0.zip") | ||
| 80 | + set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-1.14.0.zip") | ||
| 81 | + set(onnxruntime_HASH "SHA256=300eafef456748cde2743ee08845bd40ff1bab723697ff934eba6d4ce3519620") | ||
| 82 | + endif() | ||
| 66 | # After downloading, it contains: | 83 | # After downloading, it contains: |
| 67 | # ./lib/onnxruntime.{dll,lib,pdb} | 84 | # ./lib/onnxruntime.{dll,lib,pdb} |
| 68 | # ./lib/onnxruntime_providers_shared.{dll,lib,pdb} | 85 | # ./lib/onnxruntime_providers_shared.{dll,lib,pdb} |
| @@ -60,9 +60,13 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | @@ -60,9 +60,13 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | ||
| 60 | 60 | ||
| 61 | std::unique_ptr<OnlineTransducerModel> OnlineTransducerModel::Create( | 61 | std::unique_ptr<OnlineTransducerModel> OnlineTransducerModel::Create( |
| 62 | const OnlineTransducerModelConfig &config) { | 62 | const OnlineTransducerModelConfig &config) { |
| 63 | - auto buffer = ReadFile(config.encoder_filename); | 63 | + ModelType model_type = ModelType::kUnkown; |
| 64 | 64 | ||
| 65 | - auto model_type = GetModelType(buffer.data(), buffer.size(), config.debug); | 65 | + { |
| 66 | + auto buffer = ReadFile(config.encoder_filename); | ||
| 67 | + | ||
| 68 | + model_type = GetModelType(buffer.data(), buffer.size(), config.debug); | ||
| 69 | + } | ||
| 66 | 70 | ||
| 67 | switch (model_type) { | 71 | switch (model_type) { |
| 68 | case ModelType::kLstm: | 72 | case ModelType::kLstm: |
-
请 注册 或 登录 后发表评论