Committed by
GitHub
Support using T-head-Semi/csi-nn2 for RISC-V (#637)
正在显示
3 个修改的文件
包含
71 行增加
和
35 行删除
| @@ -38,7 +38,7 @@ jobs: | @@ -38,7 +38,7 @@ jobs: | ||
| 38 | fail-fast: false | 38 | fail-fast: false |
| 39 | matrix: | 39 | matrix: |
| 40 | os: [ubuntu-latest] | 40 | os: [ubuntu-latest] |
| 41 | - lib_type: [static, shared] | 41 | + lib_type: [shared] #, static] |
| 42 | 42 | ||
| 43 | steps: | 43 | steps: |
| 44 | - uses: actions/checkout@v4 | 44 | - uses: actions/checkout@v4 |
| @@ -55,45 +55,35 @@ jobs: | @@ -55,45 +55,35 @@ jobs: | ||
| 55 | uses: actions/cache@v4 | 55 | uses: actions/cache@v4 |
| 56 | with: | 56 | with: |
| 57 | path: qemu-install | 57 | path: qemu-install |
| 58 | - key: qemu-riscv-install-20240225 | ||
| 59 | - | ||
| 60 | - - name: install-qemu-build-deps | ||
| 61 | - if: steps.cache-qemu.outputs.cache-hit != 'true' | ||
| 62 | - run: | | ||
| 63 | - sudo apt-get update | ||
| 64 | - sudo apt-get install autoconf automake autotools-dev ninja-build | ||
| 65 | - | ||
| 66 | - - name: checkout-qemu | ||
| 67 | - if: steps.cache-qemu.outputs.cache-hit != 'true' | ||
| 68 | - uses: actions/checkout@v3 | ||
| 69 | - with: | ||
| 70 | - repository: qemu/qemu | ||
| 71 | - path: qemu | 58 | + key: qemu-riscv-xuantie-install-20240306 |
| 72 | 59 | ||
| 73 | - name: qemu | 60 | - name: qemu |
| 74 | if: steps.cache-qemu.outputs.cache-hit != 'true' | 61 | if: steps.cache-qemu.outputs.cache-hit != 'true' |
| 75 | run: | | 62 | run: | |
| 76 | - cd qemu | ||
| 77 | - ./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=riscv64-linux-user --disable-system | ||
| 78 | - make -j2 | ||
| 79 | - make install | ||
| 80 | - ls -lh $GITHUB_WORKSPACE/qemu-install | ||
| 81 | - ls -lh $GITHUB_WORKSPACE/qemu-install/bin | 63 | + # https://pypi.org/project/xuantie-qemu/#files |
| 64 | + wget -q https://files.pythonhosted.org/packages/21/f4/733f29c435987e8bb264a6504c7a4ea4c04d0d431b38a818ab63eef082b9/xuantie_qemu-20230825-py3-none-manylinux1_x86_64.whl | ||
| 65 | + unzip xuantie_qemu-20230825-py3-none-manylinux1_x86_64.whl | ||
| 66 | + mkdir -p qemu-install/bin | ||
| 67 | + | ||
| 68 | + cp -v ./qemu/qemu-riscv64 ./qemu-install/bin | ||
| 82 | 69 | ||
| 83 | - name: cache-toolchain | 70 | - name: cache-toolchain |
| 84 | id: cache-toolchain | 71 | id: cache-toolchain |
| 85 | uses: actions/cache@v4 | 72 | uses: actions/cache@v4 |
| 86 | with: | 73 | with: |
| 87 | path: toolchain | 74 | path: toolchain |
| 88 | - key: riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly | 75 | + key: Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz |
| 89 | 76 | ||
| 90 | - name: Download toolchain | 77 | - name: Download toolchain |
| 91 | if: steps.cache-toolchain.outputs.cache-hit != 'true' | 78 | if: steps.cache-toolchain.outputs.cache-hit != 'true' |
| 92 | shell: bash | 79 | shell: bash |
| 93 | run: | | 80 | run: | |
| 81 | + wget -q https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz | ||
| 82 | + | ||
| 94 | mkdir $GITHUB_WORKSPACE/toolchain | 83 | mkdir $GITHUB_WORKSPACE/toolchain |
| 95 | - wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2023.10.17/riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly.tar.gz | ||
| 96 | - tar xvf ./riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly.tar.gz --strip-components 1 -C $GITHUB_WORKSPACE/toolchain | 84 | + |
| 85 | + tar xvf ./Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz --strip-components 1 -C $GITHUB_WORKSPACE/toolchain | ||
| 86 | + ls -lh $GITHUB_WORKSPACE/toolchain/bin | ||
| 97 | 87 | ||
| 98 | - name: Display toolchain info | 88 | - name: Display toolchain info |
| 99 | shell: bash | 89 | shell: bash |
| @@ -139,6 +129,7 @@ jobs: | @@ -139,6 +129,7 @@ jobs: | ||
| 139 | export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH | 129 | export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH |
| 140 | export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH | 130 | export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH |
| 141 | export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot | 131 | export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot |
| 132 | + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib | ||
| 142 | 133 | ||
| 143 | ls -lh ./build-riscv64-linux-gnu/bin | 134 | ls -lh ./build-riscv64-linux-gnu/bin |
| 144 | 135 | ||
| @@ -154,6 +145,44 @@ jobs: | @@ -154,6 +145,44 @@ jobs: | ||
| 154 | qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help | 145 | qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help |
| 155 | readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts | 146 | readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts |
| 156 | 147 | ||
| 148 | + - name: Test streaming speech recognition | ||
| 149 | + shell: bash | ||
| 150 | + run: | | ||
| 151 | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH | ||
| 152 | + export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH | ||
| 153 | + export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot | ||
| 154 | + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib | ||
| 155 | + | ||
| 156 | + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2 | ||
| 157 | + tar xvf sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2 | ||
| 158 | + rm sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2 | ||
| 159 | + | ||
| 160 | + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx \ | ||
| 161 | + --tokens=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/tokens.txt \ | ||
| 162 | + --encoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/encoder-epoch-99-avg-1.onnx \ | ||
| 163 | + --decoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/decoder-epoch-99-avg-1.onnx \ | ||
| 164 | + --joiner=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/joiner-epoch-99-avg-1.onnx \ | ||
| 165 | + ./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/test_wavs/0.wav | ||
| 166 | + | ||
| 167 | + - name: Test offline tts | ||
| 168 | + shell: bash | ||
| 169 | + run: | | ||
| 170 | + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH | ||
| 171 | + export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH | ||
| 172 | + export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot | ||
| 173 | + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib | ||
| 174 | + | ||
| 175 | + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-lessac-medium.tar.bz2 | ||
| 176 | + tar xf vits-piper-en_US-lessac-medium.tar.bz2 | ||
| 177 | + rm vits-piper-en_US-lessac-medium.tar.bz2 | ||
| 178 | + | ||
| 179 | + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts \ | ||
| 180 | + --vits-model=./vits-piper-en_US-lessac-medium/en_US-lessac-medium.onnx \ | ||
| 181 | + --vits-data-dir=./vits-piper-en_US-lessac-medium/espeak-ng-data \ | ||
| 182 | + --vits-tokens=./vits-piper-en_US-lessac-medium/tokens.txt \ | ||
| 183 | + --output-filename=./liliana-piper-en_US-lessac-medium.wav \ | ||
| 184 | + 'liliana, the most beautiful and lovely assistant of our team!' | ||
| 185 | + | ||
| 157 | - name: Copy files | 186 | - name: Copy files |
| 158 | shell: bash | 187 | shell: bash |
| 159 | run: | | 188 | run: | |
| @@ -191,6 +220,12 @@ jobs: | @@ -191,6 +220,12 @@ jobs: | ||
| 191 | path: sherpa-onnx-*linux-riscv64-shared.tar.bz2 | 220 | path: sherpa-onnx-*linux-riscv64-shared.tar.bz2 |
| 192 | 221 | ||
| 193 | - uses: actions/upload-artifact@v4 | 222 | - uses: actions/upload-artifact@v4 |
| 223 | + if: matrix.lib_type == 'shared' | ||
| 224 | + with: | ||
| 225 | + name: wave | ||
| 226 | + path: ./*.wav | ||
| 227 | + | ||
| 228 | + - uses: actions/upload-artifact@v4 | ||
| 194 | if: matrix.lib_type == 'static' | 229 | if: matrix.lib_type == 'static' |
| 195 | with: | 230 | with: |
| 196 | name: sherpa-onnx-linux-riscv64-static | 231 | name: sherpa-onnx-linux-riscv64-static |
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | +set -ex | ||
| 2 | 3 | ||
| 3 | if ! command -v riscv64-unknown-linux-gnu-g++ &> /dev/null; then | 4 | if ! command -v riscv64-unknown-linux-gnu-g++ &> /dev/null; then |
| 4 | echo "Please install the toolchain first." | 5 | echo "Please install the toolchain first." |
| @@ -42,8 +43,8 @@ export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH | @@ -42,8 +43,8 @@ export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH | ||
| 42 | export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs | 43 | export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs |
| 43 | 44 | ||
| 44 | if [[ x"$BUILD_SHARED_LIBS" == x"" ]]; then | 45 | if [[ x"$BUILD_SHARED_LIBS" == x"" ]]; then |
| 45 | - # By default, use static link | ||
| 46 | - BUILD_SHARED_LIBS=OFF | 46 | + # By default, use shared libraries |
| 47 | + BUILD_SHARED_LIBS=ON | ||
| 47 | fi | 48 | fi |
| 48 | 49 | ||
| 49 | cmake \ | 50 | cmake \ |
| @@ -14,19 +14,19 @@ if(NOT BUILD_SHARED_LIBS) | @@ -14,19 +14,19 @@ if(NOT BUILD_SHARED_LIBS) | ||
| 14 | message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | 14 | message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") |
| 15 | endif() | 15 | endif() |
| 16 | 16 | ||
| 17 | -set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-1.18.0.zip") | ||
| 18 | -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-1.18.0.zip") | ||
| 19 | -set(onnxruntime_HASH "SHA256=81a11b54d1d71f4b3161b00cba8576a07594abd218aa5c0d82382960ada06092") | 17 | +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.14.1/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip") |
| 18 | +set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.14.1/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip") | ||
| 19 | +set(onnxruntime_HASH "SHA256=c2cbc5af081ff82f46640befd85433811486daaf28e702163c6e4e75020fde81") | ||
| 20 | 20 | ||
| 21 | # If you don't have access to the Internet, | 21 | # If you don't have access to the Internet, |
| 22 | # please download onnxruntime to one of the following locations. | 22 | # please download onnxruntime to one of the following locations. |
| 23 | # You can add more if you want. | 23 | # You can add more if you want. |
| 24 | set(possible_file_locations | 24 | set(possible_file_locations |
| 25 | - $ENV{HOME}/Downloads/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 26 | - ${CMAKE_SOURCE_DIR}/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 27 | - ${CMAKE_BINARY_DIR}/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 28 | - /tmp/onnxruntime-linux-riscv64-1.18.0.zip | ||
| 29 | - /star-fj/fangjun/download/github/onnxruntime-linux-riscv64-1.18.0.zip | 25 | + $ENV{HOME}/Downloads/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip |
| 26 | + ${CMAKE_SOURCE_DIR}/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip | ||
| 27 | + ${CMAKE_BINARY_DIR}/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip | ||
| 28 | + /tmp/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip | ||
| 29 | + /star-fj/fangjun/download/github/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip | ||
| 30 | ) | 30 | ) |
| 31 | 31 | ||
| 32 | foreach(f IN LISTS possible_file_locations) | 32 | foreach(f IN LISTS possible_file_locations) |
| @@ -65,7 +65,7 @@ add_library(onnxruntime SHARED IMPORTED) | @@ -65,7 +65,7 @@ add_library(onnxruntime SHARED IMPORTED) | ||
| 65 | 65 | ||
| 66 | set_target_properties(onnxruntime PROPERTIES | 66 | set_target_properties(onnxruntime PROPERTIES |
| 67 | IMPORTED_LOCATION ${location_onnxruntime} | 67 | IMPORTED_LOCATION ${location_onnxruntime} |
| 68 | - INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include/onnxruntime" | 68 | + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include/" |
| 69 | ) | 69 | ) |
| 70 | 70 | ||
| 71 | file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*") | 71 | file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*") |
-
请 注册 或 登录 后发表评论