-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(candle,tract): standalone builds
Allows the candle/tract backends to be compiled as a standalone dylib/staticlib so they can be directly swapped into any application in place of `onnxruntime.dll` or `libonnxruntime.a` (if anybody could figure out how to make Rust static libs work outside of Rust)
- Loading branch information
1 parent
0539cd5
commit 62d40b3
Showing
10 changed files
with
126 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "ort-candle-standalone" | ||
publish = false | ||
version = "1.20.0" | ||
edition = "2021" | ||
|
||
[package.metadata.winresource] | ||
ProductName = "ONNX Runtime (candle)" | ||
FileDescription = "API-compatible ONNX Runtime implementation using candle" | ||
LegalCopyright = "Copyright ©️ 2025 pyke.io" | ||
OriginalFilename = "onnxruntime+candle.dll" | ||
|
||
[lib] | ||
name = "onnxruntime" | ||
crate-type = [ "staticlib", "cdylib" ] | ||
path = "lib.rs" | ||
|
||
[dependencies] | ||
ort-candle = { path = "../" } | ||
ort-sys = { workspace = true, features = [ "disable-linking" ] } | ||
|
||
[build-dependencies] | ||
winresource = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main() { | ||
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" { | ||
let res = winresource::WindowsResource::new(); | ||
res.compile().unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
static API_BASE: ort_sys::OrtApiBase = ort_sys::OrtApiBase { | ||
GetVersionString: get_version_string, | ||
GetApi: get_api | ||
}; | ||
static API: ort_sys::OrtApi = ort_candle::api(); | ||
|
||
unsafe extern "system" fn get_version_string() -> *const ort_sys::c_char { | ||
c"1.20.0+candle@0.8-wrapper@0.1.0".as_ptr() | ||
} | ||
|
||
unsafe extern "system" fn get_api(version: u32) -> *const ort_sys::OrtApi { | ||
if version <= 20 { &API as *const _ } else { core::ptr::null() } | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn OrtGetApiBase() -> *const ort_sys::OrtApiBase { | ||
&API_BASE as *const _ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "ort-tract-standalone" | ||
publish = false | ||
version = "1.20.0" | ||
edition = "2021" | ||
|
||
[package.metadata.winresource] | ||
ProductName = "ONNX Runtime (tract)" | ||
FileDescription = "API-compatible ONNX Runtime implementation using tract" | ||
LegalCopyright = "Copyright ©️ 2025 pyke.io" | ||
OriginalFilename = "onnxruntime+tract.dll" | ||
|
||
[lib] | ||
name = "onnxruntime" | ||
crate-type = [ "staticlib", "cdylib" ] | ||
path = "lib.rs" | ||
|
||
[dependencies] | ||
ort-tract = { path = "../" } | ||
ort-sys = { workspace = true, features = [ "disable-linking" ] } | ||
|
||
[build-dependencies] | ||
winresource = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main() { | ||
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" { | ||
let res = winresource::WindowsResource::new(); | ||
res.compile().unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
static API_BASE: ort_sys::OrtApiBase = ort_sys::OrtApiBase { | ||
GetVersionString: get_version_string, | ||
GetApi: get_api | ||
}; | ||
static API: ort_sys::OrtApi = ort_tract::api(); | ||
|
||
unsafe extern "system" fn get_version_string() -> *const ort_sys::c_char { | ||
c"1.20.0+tract@0.21-wrapper@0.1.0".as_ptr() | ||
} | ||
|
||
unsafe extern "system" fn get_api(version: u32) -> *const ort_sys::OrtApi { | ||
if version <= 20 { &API as *const _ } else { core::ptr::null() } | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn OrtGetApiBase() -> *const ort_sys::OrtApiBase { | ||
&API_BASE as *const _ | ||
} |