Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: Onnxruntime型を追加し、そこからdlopen/LoadLibrary*を行う #802

Merged
merged 26 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
501dc4c
change: `Onnxruntime`型を追加し、そこから`dlopen`/`LoadLibrary*`を行う
qryxip Jun 25, 2024
0979c20
KotlinのexampleにFIXMEを追加
qryxip Jun 28, 2024
ba81393
"ONNX Runtimeを表す" → "AIエンジンの"
qryxip Jun 28, 2024
379cc44
ドキュメントとコメントを追加
qryxip Jun 28, 2024
b1dca9c
フィーチャをリネーム
qryxip Jun 29, 2024
f0c720c
fixup! フィーチャをリネーム
qryxip Jun 29, 2024
4af36e0
fixup! フィーチャをリネーム
qryxip Jun 29, 2024
249f8f3
fixup! フィーチャをリネーム
qryxip Jun 29, 2024
7b57268
fixup! フィーチャをリネーム
qryxip Jun 29, 2024
e8dc442
fixup! フィーチャをリネーム
qryxip Jun 29, 2024
9cfc7b1
voicevox-ortを更新
qryxip Jun 29, 2024
c18e335
`sed`のし損ねを修正
qryxip Jun 29, 2024
1492995
ドキュメントやコメントを更新
qryxip Jun 29, 2024
e619d8b
C APIに定数のgetterを追加
qryxip Jun 29, 2024
29eb302
voicevox-ortを更新
qryxip Jun 30, 2024
ae1c71a
"filename"を"ファイル名(モジュール名)もしくはファイルパス"に
qryxip Jun 30, 2024
c79c3f2
C APIのドキュメントに"Availability"のセクションを追加
qryxip Jun 30, 2024
dc587ae
フィーチャに関するドキュメントを更新
qryxip Jul 1, 2024
e99b293
C APIのビルドに関するドキュメントのヘッダファイル周りを更新
qryxip Jul 1, 2024
cc1f6ff
voicevox-ortを更新
qryxip Jul 1, 2024
c301b11
`JavaStr`を`CStr::to_str`しない
qryxip Jul 2, 2024
8a1e2d1
fixup! `JavaStr`を`CStr::to_str`しない
qryxip Jul 2, 2024
07d70e0
不要な依存を削除
qryxip Jul 2, 2024
c545f89
`link-onnxruntime`で`cargo test`が通るようにする
qryxip Jul 2, 2024
f60cd0e
fixup! `link-onnxruntime`で`cargo test`が通るようにする
qryxip Jul 2, 2024
c8c7813
fixup! `link-onnxruntime`で`cargo test`が通るようにする
qryxip Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ defaults:
shell: bash

jobs:
config: # 全 jobs で利用する定数の定義。実行対象の条件をフィルタリングする。
# 全 jobs で利用する定数の定義。実行対象の条件をフィルタリングする。
#
# c_release_format = plain-cdylib | ios-xcframework
#
# `plain-cdylib`の場合、動的ライブラリとその付属物をZIPに固めたものをC APIとしてリリースする。
# `ios-xcframework`の場合はiOS用のXCFrameworkをC APIとしてリリースする。また、ONNX Runtimeの
# リンク方法に関わるCargoフィーチャも`c_release_format`によって選択される。
config:
runs-on: ubuntu-latest
outputs:
includes: ${{ steps.strategy_matrix.outputs.includes }}
Expand All @@ -57,6 +64,7 @@ jobs:
"features": "",
"target": "x86_64-pc-windows-msvc",
"artifact_name": "windows-x64-cpu",
"c_release_format": "plain-cdylib",
"whl_local_version": "cpu",
"can_skip_in_simple_test": true
},
Expand All @@ -65,6 +73,7 @@ jobs:
"features": "directml",
"target": "x86_64-pc-windows-msvc",
"artifact_name": "windows-x64-directml",
"c_release_format": "plain-cdylib",
"whl_local_version": "directml",
"can_skip_in_simple_test": false
},
Expand All @@ -73,6 +82,7 @@ jobs:
"features": "cuda",
"target": "x86_64-pc-windows-msvc",
"artifact_name": "windows-x64-cuda",
"c_release_format": "plain-cdylib",
"whl_local_version": "cuda",
"can_skip_in_simple_test": true
},
Expand All @@ -81,6 +91,7 @@ jobs:
"features": "",
"target": "i686-pc-windows-msvc",
"artifact_name": "windows-x86-cpu",
"c_release_format": "plain-cdylib",
"whl_local_version": "cpu",
"can_skip_in_simple_test": true
},
Expand All @@ -89,6 +100,7 @@ jobs:
"features": "",
"target": "x86_64-unknown-linux-gnu",
"artifact_name": "linux-x64-cpu",
"c_release_format": "plain-cdylib",
"whl_local_version": "cpu",
"can_skip_in_simple_test": true
},
Expand All @@ -97,6 +109,7 @@ jobs:
"features": "cuda",
"target": "x86_64-unknown-linux-gnu",
"artifact_name": "linux-x64-gpu",
"c_release_format": "plain-cdylib",
"whl_local_version": "cuda",
"can_skip_in_simple_test": false
},
Expand All @@ -105,6 +118,7 @@ jobs:
"features": "",
"target": "aarch64-unknown-linux-gnu",
"artifact_name": "linux-arm64-cpu",
"c_release_format": "plain-cdylib",
"whl_local_version": "cpu",
"can_skip_in_simple_test": true
},
Expand All @@ -113,20 +127,23 @@ jobs:
"features": "",
"target": "aarch64-linux-android",
"artifact_name": "android-arm64-cpu",
"c_release_format": "plain-cdylib",
"can_skip_in_simple_test": true
},
{
"os": "ubuntu-20.04",
"features": "",
"target": "x86_64-linux-android",
"artifact_name": "android-x86_64-cpu",
"c_release_format": "plain-cdylib",
"can_skip_in_simple_test": true
},
{
"os": "macos-12",
"features": "",
"target": "aarch64-apple-darwin",
"artifact_name": "osx-arm64-cpu",
"c_release_format": "plain-cdylib",
"whl_local_version": "cpu",
"can_skip_in_simple_test": false
},
Expand All @@ -135,6 +152,7 @@ jobs:
"features": "",
"target": "x86_64-apple-darwin",
"artifact_name": "osx-x64-cpu",
"c_release_format": "plain-cdylib",
"whl_local_version": "cpu",
"can_skip_in_simple_test": true
},
Expand All @@ -143,20 +161,23 @@ jobs:
"features": "",
"target": "aarch64-apple-ios",
"artifact_name": "ios-arm64-cpu",
"c_release_format": "ios-xcframework",
"can_skip_in_simple_test": true
},
{
"os": "macos-12",
"features": "",
"target": "aarch64-apple-ios-sim",
"artifact_name": "ios-arm64-cpu-sim",
"c_release_format": "ios-xcframework",
"can_skip_in_simple_test": true
},
{
"os": "macos-12",
"features": "",
"target": "x86_64-apple-ios",
"artifact_name": "ios-x64-cpu",
"c_release_format": "ios-xcframework",
"can_skip_in_simple_test": true
}
]'
Expand Down Expand Up @@ -244,8 +265,12 @@ jobs:
- name: build voicevox_core_c_api
shell: bash
run: |
case ${{ matrix.c_release_format }} in
plain-cdylib) linking=load-onnxruntime ;;
ios-xcframework) linking=link-onnxruntime ;;
esac
function build() {
cargo build -p voicevox_core_c_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
cargo build -p voicevox_core_c_api -vv --features "$linking",${{ matrix.features }} --target ${{ matrix.target }} --release
}
if ${{ !inputs.is_production }}; then
build
Expand Down Expand Up @@ -285,7 +310,12 @@ jobs:
- name: Organize artifact
run: |
mkdir -p "artifact/${{ env.ASSET_NAME }}"
cp -v crates/voicevox_core_c_api/include/voicevox_core.h "artifact/${{ env.ASSET_NAME }}"
case ${{ matrix.c_release_format }} in
plain-cdylib) feature=VOICEVOX_LOAD_ONNXRUNTIME ;;
ios-xcframework) feature=VOICEVOX_LINK_ONNXRUNTIME ;;
esac
sed 's:^//\(#define '"$feature"'\)$:\1:' crates/voicevox_core_c_api/include/voicevox_core.h \
> "artifact/${{ env.ASSET_NAME }}/voicevox_core.h"
cp -v target/${{ matrix.target }}/release/*voicevox_core.{dll,so,dylib} "artifact/${{ env.ASSET_NAME }}" || true
cp -v target/${{ matrix.target }}/release/voicevox_core.dll.lib "artifact/${{ env.ASSET_NAME }}/voicevox_core.lib" || true
cp -v -n target/${{ matrix.target }}/release/{,lib}onnxruntime*.{dll,so.*,so,dylib} "artifact/${{ env.ASSET_NAME }}" || true
Expand All @@ -305,7 +335,7 @@ jobs:
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
- name: Upload artifact to build XCFramework
if: contains(matrix.target, 'ios')
if: matrix.c_release_format == 'ios-xcframework'
uses: actions/upload-artifact@v4
with:
name: voicevox_core-${{ matrix.target }}
Expand All @@ -315,7 +345,7 @@ jobs:
cd artifact
7z a "../${{ env.ASSET_NAME }}.zip" "${{ env.ASSET_NAME }}"
- name: Upload to Release
if: fromJson(needs.config.outputs.deploy) && !contains(matrix.target, 'ios')
if: fromJson(needs.config.outputs.deploy) && matrix.c_release_format == 'plain-cdylib'
uses: softprops/action-gh-release@v2
with:
prerelease: true
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/generate_document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ jobs:
with:
working-directory: "docs/apis/c_api/doxygen"
- name: Build voicevox_core_python_api
run: |
cargo build -p voicevox_core_c_api -vv
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
maturin develop --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --locked
run: maturin develop --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --locked
# https://github.com/readthedocs/sphinx-autoapi/issues/405
- name: Workaround to make Sphinx recognize `_rust` as a module
run: touch ./crates/voicevox_core_python_api/python/voicevox_core/_rust/__init__.py
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ jobs:
with:
python-version: "3.8"
- uses: Swatinem/rust-cache@v2
- run: cargo clippy -vv --all-features --tests -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -vv --all-features -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -vv --features directml,cuda --tests -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -vv --features directml,cuda -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -vv -p voicevox_core -p voicevox_core_c_api --features link-onnxruntime,directml,cuda --tests -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -vv -p voicevox_core -p voicevox_core_c_api --features link-onnxruntime,directml,cuda -- -D clippy::all -D warnings --no-deps
- run: cargo fmt -- --check

rust-unit-test:
Expand Down Expand Up @@ -134,7 +136,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
key: "cargo-integration-test-cache-${{ matrix.features }}-${{ matrix.os }}"
- name: Run cargo integration test
- name: Run cargo integration test (load-onnxruntime)
run: RUST_BACKTRACE=full cargo test --test "*" -vv --features ,${{ matrix.features }} -- --include-ignored

c-header:
Expand Down Expand Up @@ -193,11 +195,13 @@ jobs:
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv
run: cargo build -p voicevox_core_c_api --features load-onnxruntime -vv
- name: 必要なfileをunix用exampleのディレクトリに移動させる
run: |
mkdir -p example/cpp/unix/voicevox_core/
cp -v crates/voicevox_core_c_api/include/voicevox_core.h example/cpp/unix/voicevox_core/
sed 's:^//\(#define VOICEVOX_LOAD_ONNXRUNTIME\)$:\1:' \
crates/voicevox_core_c_api/include/voicevox_core.h \
> example/cpp/unix/voicevox_core/voicevox_core.h
cp -v target/debug/libvoicevox_core.{so,dylib} example/cpp/unix/voicevox_core/ || true
cp -v target/debug/libonnxruntime.so.* example/cpp/unix/voicevox_core/ || true
cp -v target/debug/libonnxruntime.*.dylib example/cpp/unix/voicevox_core/ || true
Expand Down Expand Up @@ -235,11 +239,14 @@ jobs:
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv
run: cargo build -p voicevox_core_c_api --features load-onnxruntime -vv
- name: 必要なfileをexampleのディレクトリに移動させる
shell: bash
run: |
mkdir -p example/cpp/windows/simple_tts/lib/x64
cp -v crates/voicevox_core_c_api/include/voicevox_core.h example/cpp/windows/simple_tts/
sed 's:^//\(#define VOICEVOX_LOAD_ONNXRUNTIME\)$:\1:' \
crates/voicevox_core_c_api/include/voicevox_core.h \
> example/cpp/windows/simple_tts/voicevox_core.h
cp target/debug/voicevox_core.dll.lib example/cpp/windows/simple_tts/lib/x64/voicevox_core.lib

- name: Add MSBuild to PATH
Expand Down
Loading
Loading