mirror of
https://github.com/pykeio/ort
synced 2026-04-25 16:34:55 +02:00
fix!: windows compilation
This commit is contained in:
@@ -28,6 +28,8 @@ default = [ "half", "fetch-models", "copy-dylibs" ]
|
||||
# used to prevent issues with docs.rs
|
||||
disable-build-script = []
|
||||
|
||||
profiling = [ "widestring" ]
|
||||
|
||||
fetch-models = [ "ureq" ]
|
||||
generate-bindings = [ "bindgen" ]
|
||||
copy-dylibs = []
|
||||
@@ -76,6 +78,7 @@ libc = "0.2"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = [ "std", "libloaderapi" ] }
|
||||
widestring = { version = "1.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
ureq = "2.1"
|
||||
|
||||
@@ -99,9 +99,13 @@ pub enum OrtError {
|
||||
/// Path with invalid UTF-8
|
||||
path: PathBuf
|
||||
},
|
||||
/// Attempt to build a Rust `CString` from a null pointer
|
||||
/// Attempt to build a Rust `CString` when the original string contains a null character.
|
||||
#[error("Failed to build CString when original contains null: {0}")]
|
||||
FfiStringNull(#[from] std::ffi::NulError),
|
||||
/// Attempt to build a `WideCString` when the original string contains a null character.
|
||||
#[cfg(all(windows, feature = "profiling"))]
|
||||
#[error("Failed to build CString when original contains null: {0}")]
|
||||
WideFfiStringNull(#[from] widestring::error::ContainsNul<u16>),
|
||||
#[error("{0} pointer should be null")]
|
||||
/// ORT pointer should have been null
|
||||
PointerShouldBeNull(String),
|
||||
|
||||
@@ -204,7 +204,11 @@ impl SessionBuilder {
|
||||
|
||||
/// Enables profiling. Profile information will be writen to `profiling_file` after profiling completes.
|
||||
/// See `Session::end_profiling`.
|
||||
#[cfg(feature = "profiling")]
|
||||
pub fn with_profiling<S: AsRef<str>>(self, profiling_file: S) -> OrtResult<Self> {
|
||||
#[cfg(windows)]
|
||||
let profiling_file = widestring::WideCString::from_str(profiling_file.as_ref())?;
|
||||
#[cfg(not(windows))]
|
||||
let profiling_file = CString::new(profiling_file.as_ref())?;
|
||||
ortsys![unsafe EnableProfiling(self.session_options_ptr, profiling_file.as_ptr()) -> OrtError::CreateSessionOptions];
|
||||
Ok(self)
|
||||
@@ -626,6 +630,7 @@ impl Session {
|
||||
|
||||
/// Ends profiling for this session. Note that this must be explicitly called at the end of profiling, otherwise
|
||||
/// the profiing file will be empty.
|
||||
#[cfg(feature = "profiling")]
|
||||
pub fn end_profiling(&self) -> OrtResult<String> {
|
||||
let mut profiling_name: *mut c_char = std::ptr::null_mut();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user