Struct async_tensorrt::engine::ExecutionContext
source · pub struct ExecutionContext<'engine> { /* private fields */ }
Expand description
Context for executing inference using an engine.
Implementations§
source§impl ExecutionContext<'static>
impl ExecutionContext<'static>
sourcepub async fn from_engine(engine: Engine) -> Result<Self, Error>
pub async fn from_engine(engine: Engine) -> Result<Self, Error>
Create an execution context from an Engine
.
This is the owned version of ExecutionContext::new()
. It consumes the engine. In
exchange, it produces an execution context with a 'static
lifetime.
Arguments
engine
- Parent engine.
sourcepub async fn from_engine_many(
engine: Engine,
num: usize
) -> Result<Vec<Self>, Error>
pub async fn from_engine_many( engine: Engine, num: usize ) -> Result<Vec<Self>, Error>
Create multiple execution contexts from an Engine
.
This is the owned version of ExecutionContext::new()
. It consumes the engine. In
exchange, it produces a set of execution contexts with a 'static
lifetime.
Arguments
engine
- Parent engine.num
- Number of execution contexsts to produce.
source§impl<'engine> ExecutionContext<'engine>
impl<'engine> ExecutionContext<'engine>
sourcepub async fn new(engine: &mut Engine) -> Result<ExecutionContext<'_>, Error>
pub async fn new(engine: &mut Engine) -> Result<ExecutionContext<'_>, Error>
sourcepub async fn enqueue<T: Copy>(
&mut self,
io_buffers: &mut HashMap<&str, &mut DeviceBuffer<T>>,
stream: &Stream
) -> Result<(), Error>
pub async fn enqueue<T: Copy>( &mut self, io_buffers: &mut HashMap<&str, &mut DeviceBuffer<T>>, stream: &Stream ) -> Result<(), Error>
Asynchronously execute inference.
Stream ordered semantics
This function exhibits stream ordered semantics. This means that it is only guaranteed to complete serially with respect to other operations on the same stream.
Thread-safety
Calling this function from the same context with a different CUDA stream concurrently results in undefined behavior. To perform inference concurrently in multiple streams, use one execution context per stream.
Arguments
io_buffers
- Input and output buffers.stream
- CUDA stream to execute on.