pub struct IoBinding<'s> { /* private fields */ }
Expand description
Enables binding of session inputs and/or outputs to pre-allocated memory.
Note that this arrangement is designed to minimize data copies, and to that effect, your memory allocations must
match what is expected by the model, whether you run on CPU or GPU. Data will still be copied if the
pre-allocated memory location does not match the one expected by the model. However, copies with IoBinding
s are
only done once, at the time of the binding, not at run time. This means, that if your input data required a copy,
your further input modifications would not be seen by ONNX Runtime unless you rebind it, even if it is the same
buffer. If your scenario requires that the data is copied, IoBinding
may not be the best match for your use case.
The fact that data copy is not made during runtime may also have performance implications.
Implementations§
source§impl<'s> IoBinding<'s>
impl<'s> IoBinding<'s>
sourcepub fn bind_input<'i: 's, T: ValueTypeMarker, S: AsRef<str>>(
&mut self,
name: S,
ort_value: &'i mut Value<T>
) -> Result<ValueRefMut<'i, T>>
pub fn bind_input<'i: 's, T: ValueTypeMarker, S: AsRef<str>>( &mut self, name: S, ort_value: &'i mut Value<T> ) -> Result<ValueRefMut<'i, T>>
Bind a Value
to a session input.
sourcepub fn bind_output<'o: 's, T: ValueTypeMarker, S: AsRef<str>>(
&mut self,
name: S,
ort_value: &'o mut Value<T>
) -> Result<ValueRefMut<'o, T>>
pub fn bind_output<'o: 's, T: ValueTypeMarker, S: AsRef<str>>( &mut self, name: S, ort_value: &'o mut Value<T> ) -> Result<ValueRefMut<'o, T>>
Bind a session output to a pre-allocated Value
.
sourcepub fn bind_output_to_device<S: AsRef<str>>(
&mut self,
name: S,
mem_info: &MemoryInfo
) -> Result<()>
pub fn bind_output_to_device<S: AsRef<str>>( &mut self, name: S, mem_info: &MemoryInfo ) -> Result<()>
Bind a session output to a device which is specified by mem_info
.