Skip to content

Commit

Permalink
feat: add run config entries
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Oct 19, 2024
1 parent c1c736b commit b51f60c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/session/run_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,26 @@ impl<O: SelectedOutputMarker> RunOptions<O> {
ortsys![unsafe RunOptionsUnsetTerminate(self.run_options_ptr.as_ptr())?];
Ok(())
}

/// Adds a custom configuration option to the `RunOptions`.
///
/// This can be used to, for example, configure the graph ID when using compute graphs with an execution provider
/// like CUDA:
/// ```no_run
/// # use std::sync::Arc;
/// # use ort::{Session, RunOptions, Value, ValueType, TensorElementType};
/// # fn main() -> ort::Result<()> {
/// let mut run_options = RunOptions::new()?;
/// run_options.add_config_entry("gpu_graph_id", "1")?;
/// # Ok(())
/// # }
/// ```
pub fn add_config_entry(&mut self, key: impl AsRef<str>, value: impl AsRef<str>) -> Result<()> {
let key = CString::new(key.as_ref())?;
let value = CString::new(value.as_ref())?;
ortsys![unsafe AddRunConfigEntry(self.run_options_ptr.as_ptr(), key.as_ptr(), value.as_ptr())?];
Ok(())
}
}

impl<O: SelectedOutputMarker> Drop for RunOptions<O> {
Expand Down

0 comments on commit b51f60c

Please sign in to comment.