Skip to content

Commit

Permalink
fix: clarify behavior of synchronize_inputs, ref #362
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Mar 11, 2025
1 parent 570d7c6 commit fefd639
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/io_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ impl IoBinding {
/// [`IoBinding::clear_inputs`] or [`IoBinding::clear`]).
///
/// The data is only copied upon invocation of this function. Any changes to the given value afterwards will not
/// affect the data seen by the session until the value is re-bound. Subsequent re-binds, or calls to
/// [`IoBinding::synchronize_inputs`] will copy the data again, hence why [`IoBinding`] is really only suitable when
/// one or more inputs do not change between runs.
/// affect the data seen by the session until the value is re-bound.
pub fn bind_input<T: ValueTypeMarker, S: AsRef<str>>(&mut self, name: S, ort_value: &Value<T>) -> Result<()> {
let name = name.as_ref();
let cname = CString::new(name)?;
Expand Down Expand Up @@ -179,15 +177,12 @@ impl IoBinding {
// on the C side - all they do is iterate through all nodes' EPs and call their device synchronize function
// (cudaDeviceSynchronize/hipDeviceSynchronize), which I assume would be thread-safe

/// Synchronize all bound inputs.
///
/// Each input previously bound via [`IoBinding::bind_input`] will have its data re-copied to the session device
/// immediately. Unlike [`IoBinding::bind_input`], this is a **synchronous** operation.
/// Synchronize all bound inputs, ensuring any pending asynchronous transfers are completed.
pub fn synchronize_inputs(&self) -> Result<()> {
ortsys![unsafe SynchronizeBoundInputs(self.ptr().cast_mut())?];
Ok(())
}
/// Synchronize all bound outputs.
/// Synchronize all bound outputs, ensuring any pending asynchronous transfers are completed.
pub fn synchronize_outputs(&self) -> Result<()> {
ortsys![unsafe SynchronizeBoundOutputs(self.ptr().cast_mut())?];
Ok(())
Expand Down

0 comments on commit fefd639

Please sign in to comment.