From eabeb6ea5d6bd7484e991d9fa85af465fa53bc6f Mon Sep 17 00:00:00 2001 From: "Carson M." Date: Sun, 22 Oct 2023 12:11:29 -0500 Subject: [PATCH] refactor: split out examples into crates --- .github/workflows/code-quality.yml | 6 +++--- .github/workflows/test.yml | 11 ++--------- Cargo.toml | 19 ++++++++++--------- examples/gpt2/Cargo.toml | 16 ++++++++++++++++ examples/{gpt.rs => gpt2/examples/gpt2.rs} | 0 examples/yolov8/Cargo.toml | 19 +++++++++++++++++++ examples/{ => yolov8/examples}/yolov8.rs | 0 7 files changed, 50 insertions(+), 21 deletions(-) create mode 100644 examples/gpt2/Cargo.toml rename examples/{gpt.rs => gpt2/examples/gpt2.rs} (100%) create mode 100644 examples/yolov8/Cargo.toml rename examples/{ => yolov8/examples}/yolov8.rs (100%) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index ceaab87..5a3e246 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73f2b1e..a7bf109 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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" diff --git a/Cargo.toml b/Cargo.toml index 87f275a..3579e9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/examples/gpt2/Cargo.toml b/examples/gpt2/Cargo.toml new file mode 100644 index 0000000..afcaa31 --- /dev/null +++ b/examples/gpt2/Cargo.toml @@ -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" ] diff --git a/examples/gpt.rs b/examples/gpt2/examples/gpt2.rs similarity index 100% rename from examples/gpt.rs rename to examples/gpt2/examples/gpt2.rs diff --git a/examples/yolov8/Cargo.toml b/examples/yolov8/Cargo.toml new file mode 100644 index 0000000..16f1646 --- /dev/null +++ b/examples/yolov8/Cargo.toml @@ -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" ] diff --git a/examples/yolov8.rs b/examples/yolov8/examples/yolov8.rs similarity index 100% rename from examples/yolov8.rs rename to examples/yolov8/examples/yolov8.rs