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§
Required Methods§
Sourcefn shape(&self, tensor: &Self::Tensor) -> Result<Vec<u64>, Self::Error>
fn shape(&self, tensor: &Self::Tensor) -> Result<Vec<u64>, Self::Error>
Reads tensor shape without evaluation, copying, or retaining the tensor.
Sourcefn estimate(
&self,
tensor: &Self::Tensor,
selection: &CaptureSelection,
slice: &ResolvedCaptureSlice,
) -> Result<CaptureUsage, CaptureError>
fn estimate( &self, tensor: &Self::Tensor, selection: &CaptureSelection, slice: &ResolvedCaptureSlice, ) -> Result<CaptureUsage, CaptureError>
Computes a conservative reservation without evaluating or retaining the tensor.
Sourcefn transform(
&mut self,
tensor: &Self::Tensor,
selection: &CaptureSelection,
slice: &ResolvedCaptureSlice,
) -> Result<CapturePayload, Self::Error>
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".