Skip to main content

TensorSourceRegistry

Struct TensorSourceRegistry 

Source
pub struct TensorSourceRegistry { /* private fields */ }
Expand description

Registry for managing tensor sources.

Tensor sources are named collections of data (e.g., “train”, “test”) that neural predicates can index into.

Implementations§

Source§

impl TensorSourceRegistry

Source

pub fn new() -> Self

Create a new empty registry.

Source

pub fn add_with_metadata(&mut self, name: &str, metadata: TensorMetadata)

Add a tensor source with metadata only (for testing without Python).

Source

pub fn add(&mut self, name: &str, tensor: PyObject, metadata: TensorMetadata)

Add a tensor source with PyTorch tensor.

Source

pub fn set_active(&mut self, name: &str) -> Result<(), TensorSourceError>

Set the active tensor source.

Source

pub fn active_name(&self) -> Option<&str>

Get the name of the active source.

Source

pub fn active_size(&self) -> Result<usize, TensorSourceError>

Get the size of the active source.

Source

pub fn get_active(&self) -> Result<&PyObject, TensorSourceError>

Get the PyTorch tensor for the active source.

Source

pub fn get_named(&self, name: &str) -> Result<&PyObject, TensorSourceError>

Get the PyTorch tensor for a specific named source (regardless of which source is active). Used by the Stage-B existential-join forward, which reads the per-event feature batch from a fixed nsr_domain source while the per-query examples source stays active.

Source

pub fn get_metadata(&self, name: &str) -> Option<&TensorMetadata>

Get metadata for a specific source.

Source

pub fn contains(&self, name: &str) -> bool

Check if a source exists.

Source

pub fn check_index(&self, index: usize) -> Result<(), TensorSourceError>

Check if an index is valid for the active source.

Source

pub fn validate_indices( &self, indices: &[usize], ) -> Result<(), TensorSourceError>

Validate multiple indices at once.

Source

pub fn source_names(&self) -> Vec<String>

Get names of all sources.

Source

pub fn len(&self) -> usize

Number of sources.

Source

pub fn is_empty(&self) -> bool

Check if registry is empty.

Source

pub fn remove(&mut self, name: &str)

Remove a source.

Source

pub fn clear(&mut self)

Clear all sources.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &TensorMetadata)>

Iterate over source names and metadata.

Trait Implementations§

Source§

impl Default for TensorSourceRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, 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.
§

impl<T> Ungil for T
where T: Send,