Skip to main content

DefaultCollate

Trait DefaultCollate 

Source
pub trait DefaultCollate: Sized {
    type Batch;

    // Required method
    fn default_collate(samples: Vec<Self>) -> Result<Self::Batch, CollateError>;
}
Expand description

Recursively converts one Rust sample type into its default batch type.

Tensor samples stack on dimension zero. Scalar kinds are u8 → Uint8, i8 → Int8, i16 → Int16, i32 → Int, i64 → Int64, f32 → Float, f64 → Double, and bool → Bool. Strings and Bytes remain records. Options, equal-length vectors, tuples of arity two through eight, and BTreeMap values recurse through this trait.

Use this trait through DefaultCollator, whose example demonstrates numeric, Tensor, and typed recursive output.

Required Associated Types§

Source

type Batch

Batch produced from a vector of this sample type.

Required Methods§

Source

fn default_collate(samples: Vec<Self>) -> Result<Self::Batch, CollateError>

Applies built-in typed collation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DefaultCollate for String

Source§

impl DefaultCollate for Tensor

Source§

impl DefaultCollate for bool

Source§

impl DefaultCollate for f32

Source§

impl DefaultCollate for f64

Source§

impl DefaultCollate for i8

Source§

impl DefaultCollate for i16

Source§

impl DefaultCollate for i32

Source§

impl DefaultCollate for i64

Source§

impl DefaultCollate for u8

Source§

impl<A, B, C, D, E, F, G, H> DefaultCollate for (A, B, C, D, E, F, G, H)

Source§

impl<A, B, C, D, E, F, G> DefaultCollate for (A, B, C, D, E, F, G)

Source§

impl<A, B, C, D, E, F> DefaultCollate for (A, B, C, D, E, F)

Source§

impl<A, B, C, D, E> DefaultCollate for (A, B, C, D, E)

Source§

impl<A, B, C, D> DefaultCollate for (A, B, C, D)

Source§

impl<A, B, C> DefaultCollate for (A, B, C)

Source§

impl<A, B> DefaultCollate for (A, B)

Source§

impl<K, V> DefaultCollate for BTreeMap<K, V>
where K: Ord, V: DefaultCollate,

Source§

impl<T> DefaultCollate for Option<T>
where T: DefaultCollate,

Source§

impl<T> DefaultCollate for Vec<T>
where T: DefaultCollate,

Implementors§