pub struct TensorProvenanceTracker {
pub records: HashMap<u64, ProvenanceRecord>,
pub tensor_records: HashMap<u64, Vec<u64>>,
pub next_record_id: u64,
}Expand description
Tracks the full provenance of tensor values and inference results.
Records are keyed by a globally unique record_id and can also be looked up
by tensor_id (returning all records for that tensor in insertion order).
Fields§
§records: HashMap<u64, ProvenanceRecord>All records, keyed by record_id.
tensor_records: HashMap<u64, Vec<u64>>Maps each tensor_id to the ordered list of record_ids for that tensor.
next_record_id: u64Monotonically increasing counter used to assign record IDs.
Implementations§
Source§impl TensorProvenanceTracker
impl TensorProvenanceTracker
Sourcepub fn record(
&mut self,
tensor_id: u64,
kind: ProvenanceKind,
confidence: f64,
tick: u64,
) -> u64
pub fn record( &mut self, tensor_id: u64, kind: ProvenanceKind, confidence: f64, tick: u64, ) -> u64
Records a new provenance entry for tensor_id.
Returns the newly assigned record_id.
Sourcepub fn chain_for(&self, tensor_id: u64) -> ProvenanceChain
pub fn chain_for(&self, tensor_id: u64) -> ProvenanceChain
Returns the ProvenanceChain for tensor_id in insertion order.
Returns an empty chain when tensor_id is not known.
Sourcepub fn get_record(&self, record_id: u64) -> Option<&ProvenanceRecord>
pub fn get_record(&self, record_id: u64) -> Option<&ProvenanceRecord>
Returns a reference to the record with the given record_id, or None.
Sourcepub fn records_for_tensor(&self, tensor_id: u64) -> Vec<&ProvenanceRecord>
pub fn records_for_tensor(&self, tensor_id: u64) -> Vec<&ProvenanceRecord>
Returns all records for tensor_id in insertion order.
Sourcepub fn externally_sourced_tensors(&self) -> Vec<u64>
pub fn externally_sourced_tensors(&self) -> Vec<u64>
Returns a sorted list of tensor IDs for which at least one record is
externally sourced (i.e., ProvenanceRecord::is_externally_sourced
returns true).
Sourcepub fn delete_tensor(&mut self, tensor_id: u64) -> bool
pub fn delete_tensor(&mut self, tensor_id: u64) -> bool
Removes all records associated with tensor_id.
Returns true on success, false if tensor_id was not found.
Sourcepub fn stats(&self) -> ProvenanceStats
pub fn stats(&self) -> ProvenanceStats
Returns aggregate statistics across all stored records.
Trait Implementations§
Source§impl Debug for TensorProvenanceTracker
impl Debug for TensorProvenanceTracker
Source§impl Default for TensorProvenanceTracker
impl Default for TensorProvenanceTracker
Source§fn default() -> TensorProvenanceTracker
fn default() -> TensorProvenanceTracker
Auto Trait Implementations§
impl Freeze for TensorProvenanceTracker
impl RefUnwindSafe for TensorProvenanceTracker
impl Send for TensorProvenanceTracker
impl Sync for TensorProvenanceTracker
impl Unpin for TensorProvenanceTracker
impl UnsafeUnpin for TensorProvenanceTracker
impl UnwindSafe for TensorProvenanceTracker
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more