pub struct DefaultCollate;Expand description
Default Collate function that mimic the default_collate function from PyTorch.
As they are no such lib with the same functionality as PyTorch tensor in Rust,
data is collated inside ndarray. Ndarray is the rust equivalent of numpy.ndarray with
almost the same capabilities. Nevertheless, they can’t run on the GPU.
Basic transformation implemented for the default Collate :
- Vec<Scalar>->- ndarray<scalar>
- Vec<tuple>->- tuple(ndarray)
- Vec<HashMap<Key, Value>>->- HasMap<Key, DefaultCollate::default().collate(Vec<Value>)
- Vec<Array>->- Vec<Stack Array>
- Vec[V1_i, V2_i, ...]->- Vec[DefaultCollate::default().collate([V1_1, V1_2, ...]), DefaultCollate::default().collate([V2_1, V2_2, ...]), ...]
Like for PyTorch version, String and u8 aren’t changed by the collation (No Op).
- Vec<String>->- Vec<String>
- Vec<&str>->- Vec<&str>
- Vec<u8>->- Vec<u8>
Trait Implementations§
Source§impl Clone for DefaultCollate
 
impl Clone for DefaultCollate
Source§fn clone(&self) -> DefaultCollate
 
fn clone(&self) -> DefaultCollate
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moreSource§impl<'a> Collate<&'a CStr> for DefaultCollate
 
impl<'a> Collate<&'a CStr> for DefaultCollate
Source§impl<T> Collate<&T> for DefaultCollate
We think it makes no sense to but a bench of reference into a Tensor. That’s why if the dataset yield reference a
we clone them them.
It is useful for having a non-consuming Iterator over the Dataloader.
 
impl<T> Collate<&T> for DefaultCollate
We think it makes no sense to but a bench of reference into a Tensor. That’s why if the dataset yield reference a
we clone them them.
It is useful for having a non-consuming Iterator over the Dataloader.
Source§impl<'a> Collate<&'a str> for DefaultCollate
 
impl<'a> Collate<&'a str> for DefaultCollate
Source§impl<A> Collate<(A,)> for DefaultCollate
 
impl<A> Collate<(A,)> for DefaultCollate
Source§impl<A, B> Collate<(A, B)> for DefaultCollate
 
impl<A, B> Collate<(A, B)> for DefaultCollate
Source§impl<A, B, C> Collate<(A, B, C)> for DefaultCollate
 
impl<A, B, C> Collate<(A, B, C)> for DefaultCollate
Source§impl<A, B, C, D> Collate<(A, B, C, D)> for DefaultCollate
 
impl<A, B, C, D> Collate<(A, B, C, D)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E> Collate<(A, B, C, D, E)> for DefaultCollate
 
impl<A, B, C, D, E> Collate<(A, B, C, D, E)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E, F> Collate<(A, B, C, D, E, F)> for DefaultCollate
 
impl<A, B, C, D, E, F> Collate<(A, B, C, D, E, F)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E, F, G> Collate<(A, B, C, D, E, F, G)> for DefaultCollate
 
impl<A, B, C, D, E, F, G> Collate<(A, B, C, D, E, F, G)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E, F, G, H> Collate<(A, B, C, D, E, F, G, H)> for DefaultCollate
 
impl<A, B, C, D, E, F, G, H> Collate<(A, B, C, D, E, F, G, H)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E, F, G, H, I> Collate<(A, B, C, D, E, F, G, H, I)> for DefaultCollate
 
impl<A, B, C, D, E, F, G, H, I> Collate<(A, B, C, D, E, F, G, H, I)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E, F, G, H, I, J> Collate<(A, B, C, D, E, F, G, H, I, J)> for DefaultCollate
 
impl<A, B, C, D, E, F, G, H, I, J> Collate<(A, B, C, D, E, F, G, H, I, J)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output, <DefaultCollate as Collate<J>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output, <DefaultCollate as Collate<J>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E, F, G, H, I, J, K> Collate<(A, B, C, D, E, F, G, H, I, J, K)> for DefaultCollate
 
impl<A, B, C, D, E, F, G, H, I, J, K> Collate<(A, B, C, D, E, F, G, H, I, J, K)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output, <DefaultCollate as Collate<J>>::Output, <DefaultCollate as Collate<K>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output, <DefaultCollate as Collate<J>>::Output, <DefaultCollate as Collate<K>>::Output)
The type of the collate function’s output
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L> Collate<(A, B, C, D, E, F, G, H, I, J, K, L)> for DefaultCollate
 
impl<A, B, C, D, E, F, G, H, I, J, K, L> Collate<(A, B, C, D, E, F, G, H, I, J, K, L)> for DefaultCollate
Source§type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output, <DefaultCollate as Collate<J>>::Output, <DefaultCollate as Collate<K>>::Output, <DefaultCollate as Collate<L>>::Output)
 
type Output = (<DefaultCollate as Collate<A>>::Output, <DefaultCollate as Collate<B>>::Output, <DefaultCollate as Collate<C>>::Output, <DefaultCollate as Collate<D>>::Output, <DefaultCollate as Collate<E>>::Output, <DefaultCollate as Collate<F>>::Output, <DefaultCollate as Collate<G>>::Output, <DefaultCollate as Collate<H>>::Output, <DefaultCollate as Collate<I>>::Output, <DefaultCollate as Collate<J>>::Output, <DefaultCollate as Collate<K>>::Output, <DefaultCollate as Collate<L>>::Output)
The type of the collate function’s output
Source§impl<K, V> Collate<BTreeMap<K, V>> for DefaultCollate
 
impl<K, V> Collate<BTreeMap<K, V>> for DefaultCollate
Source§impl Collate<CString> for DefaultCollate
 
impl Collate<CString> for DefaultCollate
Source§impl<K, V, H> Collate<HashMap<K, V, H>> for DefaultCollate
 
impl<K, V, H> Collate<HashMap<K, V, H>> for DefaultCollate
Source§impl Collate<OsString> for DefaultCollate
 
impl Collate<OsString> for DefaultCollate
Source§impl Collate<String> for DefaultCollate
 
impl Collate<String> for DefaultCollate
Source§impl<T> Collate<Vec<T>> for DefaultCollate
 
impl<T> Collate<Vec<T>> for DefaultCollate
Source§impl<T> Collate<VecDeque<T>> for DefaultCollate
 
impl<T> Collate<VecDeque<T>> for DefaultCollate
Source§impl Collate<bool> for DefaultCollate
 
impl Collate<bool> for DefaultCollate
Source§impl Collate<char> for DefaultCollate
 
impl Collate<char> for DefaultCollate
Source§impl Collate<f32> for DefaultCollate
 
impl Collate<f32> for DefaultCollate
Source§impl Collate<f64> for DefaultCollate
 
impl Collate<f64> for DefaultCollate
Source§impl Collate<i128> for DefaultCollate
 
impl Collate<i128> for DefaultCollate
Source§impl Collate<i16> for DefaultCollate
 
impl Collate<i16> for DefaultCollate
Source§impl Collate<i32> for DefaultCollate
 
impl Collate<i32> for DefaultCollate
Source§impl Collate<i64> for DefaultCollate
 
impl Collate<i64> for DefaultCollate
Source§impl Collate<i8> for DefaultCollate
 
impl Collate<i8> for DefaultCollate
Source§impl Collate<isize> for DefaultCollate
 
impl Collate<isize> for DefaultCollate
Source§impl Collate<u128> for DefaultCollate
 
impl Collate<u128> for DefaultCollate
Source§impl Collate<u16> for DefaultCollate
 
impl Collate<u16> for DefaultCollate
Source§impl Collate<u32> for DefaultCollate
 
impl Collate<u32> for DefaultCollate
Source§impl Collate<u64> for DefaultCollate
 
impl Collate<u64> for DefaultCollate
Source§impl Collate<u8> for DefaultCollate
NoOp for binary, as pytorch default_collate function.
 
impl Collate<u8> for DefaultCollate
NoOp for binary, as pytorch default_collate function.
Source§impl Collate<usize> for DefaultCollate
 
impl Collate<usize> for DefaultCollate
Source§impl Debug for DefaultCollate
 
impl Debug for DefaultCollate
Source§impl Default for DefaultCollate
 
impl Default for DefaultCollate
Source§fn default() -> DefaultCollate
 
fn default() -> DefaultCollate
Returns the “default value” for a type. Read more
Source§impl Ord for DefaultCollate
 
impl Ord for DefaultCollate
Source§fn cmp(&self, other: &DefaultCollate) -> Ordering
 
fn cmp(&self, other: &DefaultCollate) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
    Self: Sized,
 
fn max(self, other: Self) -> Selfwhere
    Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for DefaultCollate
 
impl PartialEq for DefaultCollate
Source§impl PartialOrd for DefaultCollate
 
impl PartialOrd for DefaultCollate
impl Eq for DefaultCollate
impl StructuralPartialEq for DefaultCollate
Auto Trait Implementations§
impl Freeze for DefaultCollate
impl RefUnwindSafe for DefaultCollate
impl Send for DefaultCollate
impl Sync for DefaultCollate
impl Unpin for DefaultCollate
impl UnwindSafe for DefaultCollate
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
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>
Converts 
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>
Converts 
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