Skip to main content

CaptureBackend

Trait CaptureBackend 

Source
pub trait CaptureBackend {
    type Tensor;
    type Error: Error + 'static;

    // Required methods
    fn shape(&self, tensor: &Self::Tensor) -> Result<Vec<u64>, Self::Error>;
    fn estimate(
        &self,
        tensor: &Self::Tensor,
        selection: &CaptureSelection,
        slice: &ResolvedCaptureSlice,
    ) -> Result<CaptureUsage, CaptureError>;
    fn transform(
        &mut self,
        tensor: &Self::Tensor,
        selection: &CaptureSelection,
        slice: &ResolvedCaptureSlice,
    ) -> Result<CapturePayload, Self::Error>;
}
Expand description

Backend mechanism for capture. The estimator is side-effect-free and must conservatively cover all collector-owned native storage (including retained backing arrays and dependencies), host buffers/transfers, and JSON payloads. transform may run only after successful reservation. It must not retain the tensor beyond the call or fall back to copying an unsliced source to the host.

Required Associated Types§

Source

type Tensor

Backend-native tensor type; never crosses the host-record boundary.

Source

type Error: Error + 'static

Backend transformation error.

Required Methods§

Source

fn shape(&self, tensor: &Self::Tensor) -> Result<Vec<u64>, Self::Error>

Reads tensor shape without evaluation, copying, or retaining the tensor.

Source

fn estimate( &self, tensor: &Self::Tensor, selection: &CaptureSelection, slice: &ResolvedCaptureSlice, ) -> Result<CaptureUsage, CaptureError>

Computes a conservative reservation without evaluating or retaining the tensor.

Source

fn transform( &mut self, tensor: &Self::Tensor, selection: &CaptureSelection, slice: &ResolvedCaptureSlice, ) -> Result<CapturePayload, Self::Error>

Performs the reserved transformation without retaining native handles after return.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§