Skip to content

Commit

Permalink
feat: option to serialize optimized graph, closes #167
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Mar 5, 2024
1 parent f159bfe commit 80e0092
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ impl SessionBuilder {
Ok(self)
}

/// After performing optimization (configurable with [`SessionBuilder::with_optimization_level`]), serializes the
/// newly optimized model to the given path (for 'offline' graph optimization).
///
/// Note that the file will only be created after the model is committed.
pub fn with_optimized_model_path<S: AsRef<str>>(self, path: S) -> Result<Self> {
#[cfg(windows)]
let path = path.as_ref().encode_utf16().chain([0]).collect::<Vec<_>>();
#[cfg(not(windows))]
let path = CString::new(path.as_ref())?;
ortsys![unsafe SetOptimizedModelFilePath(self.session_options_ptr.as_ptr(), path.as_ptr()) -> Error::CreateSessionOptions];
Ok(self)
}

/// Enables profiling. Profile information will be writen to `profiling_file` after profiling completes.
/// See [`Session::end_profiling`].
pub fn with_profiling<S: AsRef<str>>(self, profiling_file: S) -> Result<Self> {
Expand Down

0 comments on commit 80e0092

Please sign in to comment.