Skip to main content

StreamingEvaluator

Struct StreamingEvaluator 

Source
pub struct StreamingEvaluator<K: EvalKernel> { /* private fields */ }
Expand description

Streaming COCO evaluator, ADR-0013.

Holds a CocoDataset plus a sparse store of PerImageEval cells produced by per-batch match_image calls. Self::snapshot runs accumulate + summarize over the current store at any time; Self::finalize consumes the evaluator and returns the same Summary. Bit-identical to a batch run over the union of all update() batches submitted in order.

When params.retain_iou is true, the evaluator additionally retains a crate::tables::RetainedIous store keyed by (k, i), populated incrementally as each batch’s evaluate_with returns its per-batch retentions. Consumed by the per_pair / per_detection table builders.

Implementations§

Source§

impl<K: EvalKernel> StreamingEvaluator<K>

Source

pub fn new( dataset: CocoDataset, kernel: K, params: OwnedEvaluateParams, parity_mode: ParityMode, budget: MemoryBudget, ) -> Result<Self, EvalError>

Construct a new streaming evaluator.

§Errors

Returns EvalError::InvalidConfig if params.area_ranges is empty (the batch path tolerates this; the streaming evaluator rejects it because the (K, A, I) grid would be degenerate).

Source

pub fn with_rank(self, rank_id: RankId) -> Result<Self, EvalError>

Set this evaluator’s rank identifier for distributed-eval merge (ADR-0031). Builder shape: returns Self. Calling this after the first Self::update is a programming error and returns EvalError::InvalidConfig — rank identity is a construction-time property, not a mid-run mutable parameter.

§Errors

EvalError::InvalidConfig when n_detections > 0.

Source

pub fn rank_id(&self) -> Option<RankId>

The rank id this evaluator was tagged with, if any.

Source

pub fn images_seen(&self) -> usize

Number of distinct images with at least one accepted detection.

Source

pub fn detections_seen(&self) -> usize

Number of detections accepted across all update() calls.

Source

pub fn images_pending(&self) -> usize

Number of GT images that have not yet received any detection.

Source

pub fn memory_used_bytes(&self) -> usize

Total bytes the evaluator currently holds (sum of the three breakdown components).

Source

pub fn budget(&self) -> MemoryBudget

View of the configured budget.

Source

pub fn grid_meta(&self) -> &EvalGridMeta

Read-only access to the static grid metadata.

Source

pub fn retained_ious(&self) -> Option<&RetainedIous>

Read-only access to the per-(category, image) IoU matrices retained when params.retain_iou was set at construction. None on the default no-retention path.

Source

pub fn update(&mut self, json_bytes: &[u8]) -> Result<UpdateReport, EvalError>

Update with a new batch of detections, parsed from loadRes-shaped JSON bytes.

§Errors

Propagates EvalError from the parse path, the underlying evaluate_with call, and the budget check (EvalError::OutOfBudget). On any error the evaluator state is unchanged and remains usable.

Source

pub fn update_parsed( &mut self, parsed: ParsedDetections<K>, ) -> Result<UpdateReport, EvalError>

Update with a pre-parsed batch.

§Errors
Source

pub fn snapshot(&mut self) -> Result<Summary, EvalError>

Compute a Summary over the current store. Cheap to call repeatedly. Bit-identical to a batch run over the union of all detections submitted via update() so far (modulo stream-order ULP wobble in corrected mode — see ADR-0013 §Determinism).

Takes &mut self because the first call materializes a cached GT-only (K, A, I) grid for images that haven’t received any detection yet; subsequent snapshots reuse the cache.

§Errors

Propagates EvalError from the underlying accumulate or summarize call.

Source

pub fn finalize(self) -> Result<Summary, EvalError>

Consume the evaluator and return its final Summary.

§Errors

Propagates EvalError from the underlying accumulate or summarize call.

Source

pub fn snapshot_with_cells(&mut self) -> Result<SnapshotWithCells, EvalError>

Snapshot the current state, returning both the canonical Summary and a deep copy of the per-image cell store needed by the ADR-0018 calibration summarizer.

The Summary is bit-identical to what Self::snapshot would have produced for the same evaluator state — this method only adds the cell-store retention; the kernel maths are unchanged. Callers that don’t need calibration should prefer Self::snapshot / Self::finalize: this variant pays for an extra densification of the sparse (k, a, i) store, with GT-only overlay applied so the cells are immediately consumable by crate::calibration::summarize_calibration (which folds over dt_scores / dt_matched / dt_ignore and ignores GT-only slots anyway, but the consistency keeps the streaming and batch surfaces interchangeable).

Takes &mut self for the same reason as Self::snapshot: the first call materializes the cached GT-only (K, A, I) grid.

§Errors

Propagates EvalError from the underlying accumulate or summarize call.

Source

pub fn finalize_with_tables( self, request: TablesRequest, config: &TablesConfig, ) -> Result<(Summary, Tables), EvalError>

Consume the evaluator and return both its final Summary and the requested result tables.

v0.5 supports the cheap tables (crate::tables::TablesRequest::per_image, crate::tables::TablesRequest::per_class) on the streaming path — neither needs the per-cell EvalImageMeta the cells store would have to also retain. per_detection / per_pair on streaming returns EvalError::NotImplemented; callers who need those today should run the same workload via crate::evaluate_with in batch mode.

§Errors
Source

pub fn snapshot_with_tables( &mut self, request: TablesRequest, config: &TablesConfig, ) -> Result<(Summary, Tables), EvalError>

Mid-stream version of Self::finalize_with_tables. See Self::snapshot for the determinism caveat.

§Errors

Same conditions as Self::finalize_with_tables.

Source

pub fn snapshot_to_partial(&self) -> Result<Vec<u8>, EvalError>

Serialize the current evaluator state to an opaque byte blob (ADR-0031 partial wire format). Non-consuming variant — the evaluator stays usable for further update calls.

§Errors

EvalError::PartialFormatMismatch if rkyv archiving fails; EvalError::InvalidConfig if params hashing fails.

Source

pub fn finalize_to_partial(self) -> Result<Vec<u8>, EvalError>

Consuming variant of Self::snapshot_to_partial. The evaluator is dropped after the partial is produced — the expected shape for the rank-local final state in a distributed-eval gather (ADR-0031).

§Errors

Same as Self::snapshot_to_partial.

Source

pub fn from_partials( dataset: CocoDataset, kernel: K, params: OwnedEvaluateParams, parity_mode: ParityMode, budget: MemoryBudget, partials: &[&[u8]], ) -> Result<Self, EvalError>

Construct an evaluator equivalent to a batch run over the union of all partials’ submitted detections (ADR-0031).

All partials must share dataset_hash, params_hash, parity_mode, kernel kind, retain_iou, and grid dimensions. In strict mode, every partial must declare a distinct rank_id. Image-id sets across partials must be disjoint.

§Errors

Trait Implementations§

Source§

impl<K: Debug + EvalKernel> Debug for StreamingEvaluator<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K> Freeze for StreamingEvaluator<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for StreamingEvaluator<K>
where K: RefUnwindSafe,

§

impl<K> Send for StreamingEvaluator<K>

§

impl<K> Sync for StreamingEvaluator<K>

§

impl<K> Unpin for StreamingEvaluator<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for StreamingEvaluator<K>
where K: UnsafeUnpin,

§

impl<K> UnwindSafe for StreamingEvaluator<K>
where K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.