Skip to main content

Transform

Trait Transform 

Source
pub trait Transform<T>: Send + Sync {
    type Output;

    // Required method
    fn transform(&self, input: T) -> Result<Self::Output>;

    // Provided methods
    fn transform_batch(&self, inputs: Vec<T>) -> Result<Vec<Self::Output>> { ... }
    fn is_deterministic(&self) -> bool { ... }
}
Expand description

Trait for data transformations

This is the core abstraction for all data transformations in the ToRSh ecosystem. Implementations should be stateless where possible and thread-safe.

Required Associated Types§

Source

type Output

Output type after transformation

Required Methods§

Source

fn transform(&self, input: T) -> Result<Self::Output>

Apply the transformation to a single input

Provided Methods§

Source

fn transform_batch(&self, inputs: Vec<T>) -> Result<Vec<Self::Output>>

Transform multiple items in batch

Default implementation applies transform individually, but implementations can override this for more efficient batch processing.

Source

fn is_deterministic(&self) -> bool

Check if the transform is deterministic

A deterministic transform always produces the same output for the same input. Non-deterministic transforms include random augmentations.

Implementors§

Source§

impl<From: TensorElement, To: TensorElement> Transform<Tensor<From>> for ToType<From, To>

Source§

impl<T> Transform<T> for Compose<T>

Source§

impl<T, O, F> Transform<T> for Lambda<F>
where F: Fn(T) -> Result<O> + Send + Sync,

Source§

impl<T, T1, T2> Transform<T> for Chain<T1, T2>
where T1: Transform<T>, T2: Transform<T1::Output>,

Source§

type Output = <T2 as Transform<<T1 as Transform<T>>::Output>>::Output

Source§

impl<T, U, P> Transform<T> for Conditional<U, P>
where U: Transform<T, Output = T>, P: Fn(&T) -> bool + Send + Sync,

Source§

impl<T: TensorElement> Transform<Tensor<T>> for Normalize<T>