-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add API to get onnxruntime version. #3810
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // c-api-examples/version-c-api.c | ||
| // | ||
| // Copyright (c) 2026 Xiaomi Corporation | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| #include "sherpa-onnx/c-api/c-api.h" | ||
|
|
||
| int32_t main() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== file context =="
sed -n '1,40p' c-api-examples/version-c-api.c
echo
echo "== all version-c-api files =="
git ls-files | grep -E '(^|/)version-c-api\.c$' || true
echo
echo "== compiler availability and C semantics probe for int32_t main()/int main(void) =="
if command -v gcc >/dev/null 2>&1; then
tmp="$(mktemp --suffix=.c)"
cat > "$tmp" <<'EOF'
`#include` <stdint.h>
`#include` <stdio.h>
int32_t main() {
printf("int32_t main()\n");
return 0;
// unreachable: int32_t has no default argument expressions, so
// unspecified args would not make parameter count 0 for int.
}
EOF
gcc -std=c11 -pedantic -Wall -Wextra -Werror "$tmp" 2>&1 || true
rm -f "$tmp" a.out
fi
if command -v clang >/dev/null 2>&1; then
tmp="$(mktemp --suffix=.c)"
cat > "$tmp" <<'EOF'
`#include` <stdint.h>
`#include` <stdio.h>
int32_t main() {
printf("int32_t main()\n");
return 0;
}
EOF
clang -std=c11 -pedantic -Wall -Wextra "$tmp" 2>&1 || true
rm -f "$tmp" a.out
fi
echo
echo "== search for int32_t main declarations in repo =="
rg -n 'int32_t\s+main\s*\(' -g '*.c' -g '*.h' . || trueRepository: k2-fsa/sherpa-onnx Length of output: 4774 Use a conforming C entry-point signature. A hosted C program’s 🤖 Prompt for AI Agents |
||
| printf("sherpa-onnx version : %s\n", SherpaOnnxGetVersionStr()); | ||
| printf("sherpa-onnx Git SHA1: %s\n", SherpaOnnxGetGitSha1()); | ||
| printf("sherpa-onnx Git date: %s\n", SherpaOnnxGetGitDate()); | ||
| printf("onnxruntime version : %s\n", SherpaOnnxGetOnnxruntimeVersionStr()); | ||
|
|
||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // cxx-api-examples/version-cxx-api.cc | ||
| // | ||
| // Copyright (c) 2026 Xiaomi Corporation | ||
|
|
||
| #include <iostream> | ||
|
|
||
| #include "sherpa-onnx/c-api/cxx-api.h" | ||
|
|
||
| auto main() -> int { | ||
| std::cout << "sherpa-onnx version : " << sherpa_onnx::GetVersionStr() | ||
| << "\n"; | ||
| std::cout << "sherpa-onnx Git SHA1: " << sherpa_onnx::GetGitSha1() << "\n"; | ||
| std::cout << "sherpa-onnx Git date: " << sherpa_onnx::GetGitDate() << "\n"; | ||
| std::cout << "onnxruntime version : " << sherpa_onnx::GetOnnxruntimeVersionStr() | ||
| << "\n"; | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) 2026 Xiaomi Corporation | ||
|
|
||
| import 'package:sherpa_onnx/src/version.dart' as sherpa_onnx; | ||
|
|
||
| void main() { | ||
| print('sherpa-onnx version: ${sherpa_onnx.getVersion()}'); | ||
| print('sherpa-onnx git sha1: ${sherpa_onnx.getGitSha1()}'); | ||
| print('sherpa-onnx git date: ${sherpa_onnx.getGitDate()}'); | ||
| print('onnxruntime version: ${sherpa_onnx.getOnnxruntimeVersion()}'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: version | ||
| description: > | ||
| Print sherpa-onnx version info. | ||
|
|
||
| version: 1.0.0 | ||
|
|
||
| environment: | ||
| sdk: ">=3.0.0 <4.0.0" | ||
|
|
||
| dependencies: | ||
| sherpa_onnx: ^1.13.4 | ||
|
|
||
| dev_dependencies: | ||
| lints: ^3.0.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -ex | ||
|
|
||
| dart pub get | ||
|
|
||
| dart run ./bin/main.dart |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -ex | ||
|
|
||
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Quote path variables before passing them to Unquoted expansions can break when the repository path contains spaces or glob characters. Proposed fix-SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd)
+SHERPA_ONNX_DIR=$(cd "$SCRIPT_DIR/../.." && pwd)
- -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \
- -Fl$SHERPA_ONNX_DIR/build/install/lib \
+ -Fu"$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api" \
+ -Fl"$SHERPA_ONNX_DIR/build/install/lib" \Also applies to: 28-29 🧰 Tools🪛 Shellcheck (0.11.0)[info] 6-6: Double quote to prevent globbing and word splitting. (SC2086) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR" | ||
|
|
||
| if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-onnx-c-api.so && ! -f ../../build/install/lib/sherpa-onnx-c-api.dll ]]; then | ||
| mkdir -p ../../build | ||
| pushd ../../build | ||
| cmake \ | ||
| -DCMAKE_INSTALL_PREFIX=./install \ | ||
| -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| -DBUILD_SHARED_LIBS=ON \ | ||
| -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| .. | ||
|
|
||
| cmake --build . --target install --config Release | ||
| popd | ||
| fi | ||
|
|
||
| fpc \ | ||
| -dSHERPA_ONNX_USE_SHARED_LIBS \ | ||
| -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \ | ||
| -Fl$SHERPA_ONNX_DIR/build/install/lib \ | ||
| ./version.pas | ||
|
|
||
| export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$LD_LIBRARY_PATH | ||
| export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$DYLD_LIBRARY_PATH | ||
|
|
||
| ./version | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // pascal-api-examples/version/version.pas | ||
| // | ||
| // Copyright (c) 2026 Xiaomi Corporation | ||
|
|
||
| program version; | ||
|
|
||
| uses | ||
| sherpa_onnx; | ||
|
|
||
| begin | ||
| WriteLn('sherpa-onnx version : ', SherpaOnnxGetVersionStr()); | ||
| WriteLn('sherpa-onnx Git SHA1: ', SherpaOnnxGetGitSha1()); | ||
| WriteLn('sherpa-onnx Git date: ', SherpaOnnxGetGitDate()); | ||
| WriteLn('onnxruntime version : ', SherpaOnnxGetOnnxruntimeVersionStr()); | ||
| end. |
Uh oh!
There was an error while loading. Please reload this page.