From b51f60c7296c300ade78846fd44c100dd7d962ca Mon Sep 17 00:00:00 2001 From: "Carson M." Date: Sat, 19 Oct 2024 12:20:17 -0500 Subject: [PATCH] feat: add run config entries --- src/session/run_options.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/session/run_options.rs b/src/session/run_options.rs index c17b9d3..5ee6a9b 100644 --- a/src/session/run_options.rs +++ b/src/session/run_options.rs @@ -283,6 +283,26 @@ impl RunOptions { 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, value: impl AsRef) -> 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 Drop for RunOptions {