refactor: split out examples into crates

This commit is contained in:
Carson M.
2023-10-22 12:11:29 -05:00
parent b849ae2f0f
commit eabeb6ea5d
7 changed files with 50 additions and 21 deletions

View File

@@ -47,7 +47,7 @@ jobs:
- name: Check fmt
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --workspace --features fetch-models
run: cargo clippy -p ort --all-targets --workspace --features fetch-models
coverage:
name: Code coverage
runs-on: ubuntu-latest
@@ -71,8 +71,8 @@ jobs:
run: cargo install cargo-tarpaulin
- name: Generate code coverage
run: |
cargo tarpaulin --features fetch-models --verbose --timeout 120 --out xml
cargo tarpaulin -p ort --features fetch-models --verbose --timeout 120 --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
fail_ci_if_error: false

View File

@@ -37,7 +37,7 @@ jobs:
- name: Run tests
# do not run doctests until rust-lang/cargo#10469 is merged
run: |
cargo test --verbose --lib --features fetch-models
cargo test -p ort --verbose --lib --features fetch-models
cross-compile:
name: Cross-platform compile
runs-on: ${{ matrix.platform.os }}
@@ -68,16 +68,9 @@ jobs:
$VCINSTALLDIR = Join-Path $VSINSTALLDIR "VC"
$LLVM_ROOT = Join-Path $VCINSTALLDIR "Tools\Llvm\x64"
echo "PATH=$Env:PATH;${LLVM_ROOT}\bin" >> $Env:GITHUB_ENV
- name: Install native dependencies for Linux
if: matrix.platform.os == 'ubuntu-latest'
shell: bash
run: |
sudo apt-get install pkg-config libfreetype6-dev libexpat1-dev libxcb-composite0-dev libssl-dev libx11-dev libfontconfig1-dev
- name: Build/test
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "--features fetch-models"
env:
LC_ALL: C
args: "-p ort --features fetch-models"

View File

@@ -1,5 +1,14 @@
[workspace]
members = ['ort-sys']
members = [
'ort-sys',
'examples/gpt2',
'examples/yolov8'
]
default-members = [
'.',
'examples/gpt2',
'examples/yolov8'
]
[package]
name = "ort"
@@ -27,10 +36,6 @@ codegen-units = 1
[package.metadata.docs.rs]
features = [ "half", "fetch-models", "copy-dylibs" ]
[[example]]
name = "gpt"
required-features = ["fetch-models"]
[features]
default = [ "half", "download-binaries", "copy-dylibs" ]
@@ -87,9 +92,5 @@ widestring = { version = "1.0", optional = true }
anyhow = "1.0"
ureq = "2.1"
image = "0.24"
show-image = { version = "0.13", features = [ "image", "raqote" ] }
raqote = { version = "0.8", default-features = false }
test-log = { version = "0.2", default-features = false, features = [ "trace" ] }
tracing-subscriber = { version = "0.3", default-features = false, features = [ "env-filter", "fmt" ] }
tokenizers = { version = ">=0.13.4", default-features = false, features = [ "onig" ] }
rand = "0.8"

16
examples/gpt2/Cargo.toml Normal file
View File

@@ -0,0 +1,16 @@
[package]
publish = false
name = "gpt2"
version = "0.0.0"
edition = "2021"
[dependencies]
ort = { path = "../../", features = [ "fetch-models" ] }
ndarray = "0.15"
tokenizers = { version = ">=0.13.4", default-features = false, features = [ "onig" ] }
rand = "0.8"
tracing-subscriber = { version = "0.3", default-features = false, features = [ "env-filter", "fmt" ] }
[features]
load-dynamic = [ "ort/load-dynamic" ]
cuda = [ "ort/cuda" ]

View File

@@ -0,0 +1,19 @@
[package]
publish = false
name = "yolov8"
version = "0.0.0"
edition = "2021"
[dependencies]
ort = { path = "../../" }
ndarray = "0.15"
tracing-subscriber = { version = "0.3", default-features = false, features = [ "env-filter", "fmt" ] }
image = "0.24"
show-image = { version = "0.13", features = [ "image", "raqote" ] }
raqote = { version = "0.8", default-features = false }
ureq = "2.1"
tracing = "0.1"
[features]
load-dynamic = [ "ort/load-dynamic" ]
cuda = [ "ort/cuda" ]