Support using T-head-Semi/csi-nn2 for RISC-V (#637)
This commit is contained in:
83
.github/workflows/riscv64-linux.yaml
vendored
83
.github/workflows/riscv64-linux.yaml
vendored
@@ -38,7 +38,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
lib_type: [static, shared]
|
lib_type: [shared] #, static]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -55,45 +55,35 @@ jobs:
|
|||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: qemu-install
|
path: qemu-install
|
||||||
key: qemu-riscv-install-20240225
|
key: qemu-riscv-xuantie-install-20240306
|
||||||
|
|
||||||
- name: install-qemu-build-deps
|
|
||||||
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install autoconf automake autotools-dev ninja-build
|
|
||||||
|
|
||||||
- name: checkout-qemu
|
|
||||||
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
repository: qemu/qemu
|
|
||||||
path: qemu
|
|
||||||
|
|
||||||
- name: qemu
|
- name: qemu
|
||||||
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
cd qemu
|
# https://pypi.org/project/xuantie-qemu/#files
|
||||||
./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=riscv64-linux-user --disable-system
|
wget -q https://files.pythonhosted.org/packages/21/f4/733f29c435987e8bb264a6504c7a4ea4c04d0d431b38a818ab63eef082b9/xuantie_qemu-20230825-py3-none-manylinux1_x86_64.whl
|
||||||
make -j2
|
unzip xuantie_qemu-20230825-py3-none-manylinux1_x86_64.whl
|
||||||
make install
|
mkdir -p qemu-install/bin
|
||||||
ls -lh $GITHUB_WORKSPACE/qemu-install
|
|
||||||
ls -lh $GITHUB_WORKSPACE/qemu-install/bin
|
cp -v ./qemu/qemu-riscv64 ./qemu-install/bin
|
||||||
|
|
||||||
- name: cache-toolchain
|
- name: cache-toolchain
|
||||||
id: cache-toolchain
|
id: cache-toolchain
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: toolchain
|
path: toolchain
|
||||||
key: riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly
|
key: Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz
|
||||||
|
|
||||||
- name: Download toolchain
|
- name: Download toolchain
|
||||||
if: steps.cache-toolchain.outputs.cache-hit != 'true'
|
if: steps.cache-toolchain.outputs.cache-hit != 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
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
|
||||||
|
|
||||||
mkdir $GITHUB_WORKSPACE/toolchain
|
mkdir $GITHUB_WORKSPACE/toolchain
|
||||||
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
|
|
||||||
tar xvf ./riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.10.17-nightly.tar.gz --strip-components 1 -C $GITHUB_WORKSPACE/toolchain
|
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
|
||||||
|
ls -lh $GITHUB_WORKSPACE/toolchain/bin
|
||||||
|
|
||||||
- name: Display toolchain info
|
- name: Display toolchain info
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -139,6 +129,7 @@ jobs:
|
|||||||
export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
|
export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
|
||||||
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
|
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
|
||||||
export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
|
export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
|
||||||
|
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib
|
||||||
|
|
||||||
ls -lh ./build-riscv64-linux-gnu/bin
|
ls -lh ./build-riscv64-linux-gnu/bin
|
||||||
|
|
||||||
@@ -154,6 +145,44 @@ jobs:
|
|||||||
qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help
|
qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help
|
||||||
readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts
|
readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts
|
||||||
|
|
||||||
|
- name: Test streaming speech recognition
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
|
||||||
|
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
|
||||||
|
export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
|
||||||
|
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib
|
||||||
|
|
||||||
|
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2
|
||||||
|
tar xvf sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2
|
||||||
|
rm sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2
|
||||||
|
|
||||||
|
qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx \
|
||||||
|
--tokens=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/tokens.txt \
|
||||||
|
--encoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/encoder-epoch-99-avg-1.onnx \
|
||||||
|
--decoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/decoder-epoch-99-avg-1.onnx \
|
||||||
|
--joiner=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/joiner-epoch-99-avg-1.onnx \
|
||||||
|
./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/test_wavs/0.wav
|
||||||
|
|
||||||
|
- name: Test offline tts
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
|
||||||
|
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
|
||||||
|
export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
|
||||||
|
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib
|
||||||
|
|
||||||
|
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-lessac-medium.tar.bz2
|
||||||
|
tar xf vits-piper-en_US-lessac-medium.tar.bz2
|
||||||
|
rm vits-piper-en_US-lessac-medium.tar.bz2
|
||||||
|
|
||||||
|
qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts \
|
||||||
|
--vits-model=./vits-piper-en_US-lessac-medium/en_US-lessac-medium.onnx \
|
||||||
|
--vits-data-dir=./vits-piper-en_US-lessac-medium/espeak-ng-data \
|
||||||
|
--vits-tokens=./vits-piper-en_US-lessac-medium/tokens.txt \
|
||||||
|
--output-filename=./liliana-piper-en_US-lessac-medium.wav \
|
||||||
|
'liliana, the most beautiful and lovely assistant of our team!'
|
||||||
|
|
||||||
- name: Copy files
|
- name: Copy files
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -190,6 +219,12 @@ jobs:
|
|||||||
name: sherpa-onnx-linux-riscv64-shared
|
name: sherpa-onnx-linux-riscv64-shared
|
||||||
path: sherpa-onnx-*linux-riscv64-shared.tar.bz2
|
path: sherpa-onnx-*linux-riscv64-shared.tar.bz2
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
if: matrix.lib_type == 'shared'
|
||||||
|
with:
|
||||||
|
name: wave
|
||||||
|
path: ./*.wav
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
if: matrix.lib_type == 'static'
|
if: matrix.lib_type == 'static'
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
if ! command -v riscv64-unknown-linux-gnu-g++ &> /dev/null; then
|
if ! command -v riscv64-unknown-linux-gnu-g++ &> /dev/null; then
|
||||||
echo "Please install the toolchain first."
|
echo "Please install the toolchain first."
|
||||||
@@ -42,8 +43,8 @@ export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
|
|||||||
export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
|
export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
|
||||||
|
|
||||||
if [[ x"$BUILD_SHARED_LIBS" == x"" ]]; then
|
if [[ x"$BUILD_SHARED_LIBS" == x"" ]]; then
|
||||||
# By default, use static link
|
# By default, use shared libraries
|
||||||
BUILD_SHARED_LIBS=OFF
|
BUILD_SHARED_LIBS=ON
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmake \
|
cmake \
|
||||||
|
|||||||
@@ -14,19 +14,19 @@ if(NOT BUILD_SHARED_LIBS)
|
|||||||
message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
|
message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-1.18.0.zip")
|
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.14.1/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip")
|
||||||
set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-1.18.0.zip")
|
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")
|
||||||
set(onnxruntime_HASH "SHA256=81a11b54d1d71f4b3161b00cba8576a07594abd218aa5c0d82382960ada06092")
|
set(onnxruntime_HASH "SHA256=c2cbc5af081ff82f46640befd85433811486daaf28e702163c6e4e75020fde81")
|
||||||
|
|
||||||
# If you don't have access to the Internet,
|
# If you don't have access to the Internet,
|
||||||
# please download onnxruntime to one of the following locations.
|
# please download onnxruntime to one of the following locations.
|
||||||
# You can add more if you want.
|
# You can add more if you want.
|
||||||
set(possible_file_locations
|
set(possible_file_locations
|
||||||
$ENV{HOME}/Downloads/onnxruntime-linux-riscv64-1.18.0.zip
|
$ENV{HOME}/Downloads/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip
|
||||||
${CMAKE_SOURCE_DIR}/onnxruntime-linux-riscv64-1.18.0.zip
|
${CMAKE_SOURCE_DIR}/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip
|
||||||
${CMAKE_BINARY_DIR}/onnxruntime-linux-riscv64-1.18.0.zip
|
${CMAKE_BINARY_DIR}/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip
|
||||||
/tmp/onnxruntime-linux-riscv64-1.18.0.zip
|
/tmp/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip
|
||||||
/star-fj/fangjun/download/github/onnxruntime-linux-riscv64-1.18.0.zip
|
/star-fj/fangjun/download/github/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(f IN LISTS possible_file_locations)
|
foreach(f IN LISTS possible_file_locations)
|
||||||
@@ -65,7 +65,7 @@ add_library(onnxruntime SHARED IMPORTED)
|
|||||||
|
|
||||||
set_target_properties(onnxruntime PROPERTIES
|
set_target_properties(onnxruntime PROPERTIES
|
||||||
IMPORTED_LOCATION ${location_onnxruntime}
|
IMPORTED_LOCATION ${location_onnxruntime}
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include/onnxruntime"
|
INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include/"
|
||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
|
file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
|
||||||
|
|||||||
Reference in New Issue
Block a user