Struct ai_dataloader::collate::DefaultCollate
source · 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 functionnality 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 copy 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<'a> Collate<&'a str> for DefaultCollate
impl<'a> Collate<&'a str> for DefaultCollate
source§impl<T> Collate<&T> for DefaultCollatewhere
T: Clone,
Self: Collate<T>,
impl<T> Collate<&T> for DefaultCollatewhere T: Clone, Self: Collate<T>,
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,)> for DefaultCollatewhere
A: Clone,
DefaultCollate: Collate<A>,
impl<A> Collate<(A,)> for DefaultCollatewhere A: Clone, DefaultCollate: Collate<A>,
source§impl<A, B> Collate<(A, B)> for DefaultCollatewhere
A: Clone,
B: Clone,
DefaultCollate: Collate<A> + Collate<B>,
impl<A, B> Collate<(A, B)> for DefaultCollatewhere A: Clone, B: Clone, DefaultCollate: Collate<A> + Collate<B>,
source§impl<A, B, C> Collate<(A, B, C)> for DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C>,
impl<A, B, C> Collate<(A, B, C)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C>,
source§impl<A, B, C, D> Collate<(A, B, C, D)> for DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D>,
impl<A, B, C, D> Collate<(A, B, C, D)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E>,
impl<A, B, C, D, E> Collate<(A, B, C, D, E)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F>,
impl<A, B, C, D, E, F> Collate<(A, B, C, D, E, F)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, F: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G>,
impl<A, B, C, D, E, F, G> Collate<(A, B, C, D, E, F, G)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, F: Clone, G: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
H: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H>,
impl<A, B, C, D, E, F, G, H> Collate<(A, B, C, D, E, F, G, H)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, F: Clone, G: Clone, H: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
H: Clone,
I: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I>,
impl<A, B, C, D, E, F, G, H, I> Collate<(A, B, C, D, E, F, G, H, I)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, F: Clone, G: Clone, H: Clone, I: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
H: Clone,
I: Clone,
J: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I> + Collate<J>,
impl<A, B, C, D, E, F, G, H, I, J> Collate<(A, B, C, D, E, F, G, H, I, J)> for DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, F: Clone, G: Clone, H: Clone, I: Clone, J: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I> + Collate<J>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
H: Clone,
I: Clone,
J: Clone,
K: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I> + Collate<J> + Collate<K>,
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 DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, F: Clone, G: Clone, H: Clone, I: Clone, J: Clone, K: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I> + Collate<J> + Collate<K>,
§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 DefaultCollatewhere
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
H: Clone,
I: Clone,
J: Clone,
K: Clone,
L: Clone,
DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I> + Collate<J> + Collate<K> + Collate<L>,
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 DefaultCollatewhere A: Clone, B: Clone, C: Clone, D: Clone, E: Clone, F: Clone, G: Clone, H: Clone, I: Clone, J: Clone, K: Clone, L: Clone, DefaultCollate: Collate<A> + Collate<B> + Collate<C> + Collate<D> + Collate<E> + Collate<F> + Collate<G> + Collate<H> + Collate<I> + Collate<J> + Collate<K> + Collate<L>,
§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<A, D> Collate<ArrayBase<OwnedRepr<A>, D>> for DefaultCollatewhere
A: Clone,
D: Dimension,
D::Larger: RemoveAxis,
impl<A, D> Collate<ArrayBase<OwnedRepr<A>, D>> for DefaultCollatewhere A: Clone, D: Dimension, D::Larger: RemoveAxis,
source§impl<K, V> Collate<BTreeMap<K, V, Global>> for DefaultCollatewhere
K: Ord + Clone,
V: Clone,
Self: Collate<V>,
impl<K, V> Collate<BTreeMap<K, V, Global>> for DefaultCollatewhere K: Ord + Clone, V: Clone, Self: Collate<V>,
source§impl Collate<CString> for DefaultCollate
impl Collate<CString> for DefaultCollate
source§impl<K, V, H> Collate<HashMap<K, V, H>> for DefaultCollatewhere
K: Eq + Hash + Clone,
V: Clone,
Self: Collate<V>,
H: BuildHasher,
impl<K, V, H> Collate<HashMap<K, V, H>> for DefaultCollatewhere K: Eq + Hash + Clone, V: Clone, Self: Collate<V>, H: BuildHasher,
source§impl Collate<NonZeroI128> for DefaultCollate
impl Collate<NonZeroI128> for DefaultCollate
source§impl Collate<NonZeroI16> for DefaultCollate
impl Collate<NonZeroI16> for DefaultCollate
source§impl Collate<NonZeroI32> for DefaultCollate
impl Collate<NonZeroI32> for DefaultCollate
source§impl Collate<NonZeroI64> for DefaultCollate
impl Collate<NonZeroI64> for DefaultCollate
source§impl Collate<NonZeroI8> for DefaultCollate
impl Collate<NonZeroI8> for DefaultCollate
source§impl Collate<NonZeroIsize> for DefaultCollate
impl Collate<NonZeroIsize> for DefaultCollate
source§impl Collate<NonZeroU128> for DefaultCollate
impl Collate<NonZeroU128> for DefaultCollate
source§impl Collate<NonZeroU16> for DefaultCollate
impl Collate<NonZeroU16> for DefaultCollate
source§impl Collate<NonZeroU32> for DefaultCollate
impl Collate<NonZeroU32> for DefaultCollate
source§impl Collate<NonZeroU64> for DefaultCollate
impl Collate<NonZeroU64> for DefaultCollate
source§impl Collate<NonZeroU8> for DefaultCollate
impl Collate<NonZeroU8> for DefaultCollate
source§impl Collate<NonZeroUsize> for DefaultCollate
impl Collate<NonZeroUsize> 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 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
impl Collate<u8> for DefaultCollate
NoOp for binairy, 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<DefaultCollate> for DefaultCollate
impl PartialEq<DefaultCollate> for DefaultCollate
source§fn eq(&self, other: &DefaultCollate) -> bool
fn eq(&self, other: &DefaultCollate) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialOrd<DefaultCollate> for DefaultCollate
impl PartialOrd<DefaultCollate> for DefaultCollate
source§fn partial_cmp(&self, other: &DefaultCollate) -> Option<Ordering>
fn partial_cmp(&self, other: &DefaultCollate) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for DefaultCollate
impl StructuralEq for DefaultCollate
impl StructuralPartialEq for DefaultCollate
Auto Trait Implementations§
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