diff --git a/src/execution_providers/mod.rs b/src/execution_providers/mod.rs index 0b6d6c6..85b4c9a 100644 --- a/src/execution_providers/mod.rs +++ b/src/execution_providers/mod.rs @@ -274,7 +274,7 @@ macro_rules! get_ep_register { pub(crate) use get_ep_register; pub(crate) fn apply_execution_providers(session_builder: &mut SessionBuilder, eps: &[ExecutionProviderDispatch], source: &'static str) -> Result<()> { - fn register_inner(session_builder: &mut SessionBuilder, ep: &ExecutionProviderDispatch, source: &'static str) -> Result { + fn register_inner(session_builder: &mut SessionBuilder, ep: &ExecutionProviderDispatch, #[allow(unused)] source: &'static str) -> Result { if let Err(e) = ep.inner.register(session_builder) { if ep.error_on_failure { return Err(e); diff --git a/src/session/builder/impl_options.rs b/src/session/builder/impl_options.rs index 6289854..00d7c18 100644 --- a/src/session/builder/impl_options.rs +++ b/src/session/builder/impl_options.rs @@ -1,11 +1,7 @@ -use alloc::{borrow::Cow, rc::Rc, sync::Arc}; -use core::{ - any::Any, - ffi::{c_char, c_void}, - ptr -}; +use alloc::{rc::Rc, sync::Arc}; +use core::{any::Any, ffi::c_void, ptr}; #[cfg(feature = "std")] -use std::path::Path; +use std::{borrow::Cow, path::Path}; use super::SessionBuilder; #[cfg(feature = "std")] @@ -175,7 +171,7 @@ impl SessionBuilder { pub fn with_external_initializer_file_in_memory(mut self, file_name: impl AsRef, buffer: Cow<'static, [u8]>) -> Result { let file_name = path_to_os_char(file_name); let sizes = [buffer.len()]; - ortsys![unsafe AddExternalInitializersFromMemory(self.ptr_mut(), &file_name.as_ptr(), &buffer.as_ptr().cast::().cast_mut(), sizes.as_ptr(), 1)?]; + ortsys![unsafe AddExternalInitializersFromMemory(self.ptr_mut(), &file_name.as_ptr(), &buffer.as_ptr().cast::().cast_mut(), sizes.as_ptr(), 1)?]; self.external_initializer_buffers.push(buffer); Ok(self) } diff --git a/src/session/input.rs b/src/session/input.rs index 87cffac..0ff723e 100644 --- a/src/session/input.rs +++ b/src/session/input.rs @@ -1,7 +1,7 @@ -use alloc::{borrow::Cow, sync::Arc, vec::Vec}; +use alloc::{borrow::Cow, vec::Vec}; use core::ops::Deref; -use crate::value::{DynValueTypeMarker, Value, ValueInner, ValueRef, ValueRefMut, ValueTypeMarker}; +use crate::value::{DynValueTypeMarker, Value, ValueRef, ValueRefMut, ValueTypeMarker}; pub enum SessionInputValue<'v> { ViewMut(ValueRefMut<'v, DynValueTypeMarker>), @@ -9,16 +9,6 @@ pub enum SessionInputValue<'v> { Owned(Value) } -impl SessionInputValue<'_> { - pub(crate) fn inner(&self) -> &Arc { - match self { - Self::ViewMut(v) => v.inner(), - Self::View(v) => v.inner(), - Self::Owned(v) => v.inner() - } - } -} - impl Deref for SessionInputValue<'_> { type Target = Value; diff --git a/src/session/mod.rs b/src/session/mod.rs index 9092e2c..6af203e 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -10,7 +10,7 @@ //! # } //! ``` -use alloc::{boxed::Box, ffi::CString, format, string::String, sync::Arc, vec::Vec}; +use alloc::{boxed::Box, format, string::String, sync::Arc, vec::Vec}; use core::{ any::Any, ffi::{CStr, c_char}, @@ -20,6 +20,8 @@ use core::{ ptr::{self, NonNull}, slice }; +#[cfg(feature = "std")] +use std::ffi::CString; use smallvec::SmallVec; @@ -434,7 +436,11 @@ impl Session { let mut input_ort_values = SmallVec::with_capacity(input_values.len()); for input in input_values { input_ort_values.push(input.ptr()); - input_inner_holders.push(Arc::clone(input.inner())); + input_inner_holders.push(Arc::clone(match input { + SessionInputValue::ViewMut(v) => &(**v).inner, + SessionInputValue::View(v) => &(**v).inner, + SessionInputValue::Owned(v) => &v.inner + })); } let (output_names, mut output_tensors) = run_options.outputs.resolve_outputs(&self.outputs); diff --git a/src/value/mod.rs b/src/value/mod.rs index c8a111d..6ed9de6 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -96,10 +96,6 @@ impl<'v, Type: ValueTypeMarker + ?Sized> ValueRef<'v, Type> { } } - pub(crate) fn inner(&self) -> &Arc { - &self.inner.inner - } - /// Attempts to downcast a temporary dynamic value (like [`DynValue`] or [`DynTensor`]) to a more strongly typed /// variant, like [`TensorRef`]. #[inline] @@ -153,10 +149,6 @@ impl<'v, Type: ValueTypeMarker + ?Sized> ValueRefMut<'v, Type> { } } - pub(crate) fn inner(&self) -> &Arc { - &self.inner.inner - } - /// Attempts to downcast a temporary mutable dynamic value (like [`DynValue`] or [`DynTensor`]) to a more /// strongly typed variant, like [`TensorRefMut`]. #[inline] @@ -312,10 +304,6 @@ unsafe impl Send for Value {} unsafe impl Sync for Value {} impl Value { - pub(crate) fn inner(&self) -> &Arc { - &self.inner - } - /// Returns the data type of this [`Value`]. pub fn dtype(&self) -> &ValueType { &self.inner.dtype