Skip to content

Commit

Permalink
refactor: make Environment and ExecutionProvider send & sync
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Oct 3, 2024
1 parent 2e1f014 commit 542f210
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct Environment {
pub(crate) has_global_threadpool: bool
}

unsafe impl Send for Environment {}
unsafe impl Sync for Environment {}

impl Environment {
/// Returns the underlying [`ort_sys::OrtEnv`] pointer.
pub fn ptr(&self) -> *mut ort_sys::OrtEnv {
Expand Down
4 changes: 2 additions & 2 deletions src/execution_providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub use self::rknpu::RKNPUExecutionProvider;
/// optimize the execution by taking advantage of the compute capabilities of the platform.
///
/// ![](https://www.onnxruntime.ai/images/ONNX_Runtime_EP1.png)
pub trait ExecutionProvider {
pub trait ExecutionProvider: Send + Sync {
/// Returns the identifier of this execution provider used internally by ONNX Runtime.
///
/// This is the same as what's used in ONNX Runtime's Python API to register this execution provider, i.e.
Expand Down Expand Up @@ -144,7 +144,7 @@ pub struct ExecutionProviderDispatch {
impl ExecutionProviderDispatch {
pub(crate) fn new<E: ExecutionProvider + 'static>(ep: E) -> Self {
ExecutionProviderDispatch {
inner: Arc::new(ep) as Arc<dyn ExecutionProvider>,
inner: Arc::new(ep) as _,
error_on_failure: false
}
}
Expand Down

0 comments on commit 542f210

Please sign in to comment.