Skip to main content

Executable

Trait Executable 

Source
pub trait Executable {
    // Required method
    fn run(&self, inputs: &[Tensor]) -> Result<Vec<Tensor>, Error>;

    // Provided method
    fn run_many(
        &self,
        batches: &[Vec<Tensor>],
    ) -> Result<Vec<Vec<Tensor>>, Error> { ... }
}

Required Methods§

Source

fn run(&self, inputs: &[Tensor]) -> Result<Vec<Tensor>, Error>

inputs follow the graph’s declared input order; the result follows the graph’s output order.

Provided Methods§

Source

fn run_many(&self, batches: &[Vec<Tensor>]) -> Result<Vec<Vec<Tensor>>, Error>

Runs the graph once per element of batches and returns the results in the same order; every result equals what run returns for that element. The default runs them one after another. The GPU backend overrides it to submit the whole batch at once and wait once, which hides the per-run wait; its memory use grows with the batch.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§