pub struct TorchCollate;
Available on crate feature
tch
only.Expand description
Torch Collate function that mimic the default_collate
function from PyTorch
.
Data is collated inside a tch
Tensor
.
Basic transformation implemented for the default Collate :
Vec<Scalar>
->tch::Tensor<scalar>
Vec<tuple>
->tuple(ndarray)
Vec<HashMap<Key, Value>>
->HasMap<Key, TorchCollate::default().collate(Vec<Value>)
Vec<Array>
->Vec<Stack Array>
Vec[V1_i, V2_i, ...]
->Vec[TorchCollate::default().collate([V1_1, V1_2, ...]), TorchCollate::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 TorchCollate
impl Clone for TorchCollate
Source§fn clone(&self) -> TorchCollate
fn clone(&self) -> TorchCollate
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 TorchCollate
impl<'a> Collate<&'a CStr> for TorchCollate
Source§impl<T> Collate<&T> for TorchCollate
We think it makes no sense to but a bench of reference into a Tensor. That’s why if the dataset yield reference and they
we clone their value.
It is useful for having a non-consuming Iterator
over the Dataloader
.
impl<T> Collate<&T> for TorchCollate
We think it makes no sense to but a bench of reference into a Tensor. That’s why if the dataset yield reference and they
we clone their value.
It is useful for having a non-consuming Iterator
over the Dataloader
.
Source§impl<'a> Collate<&'a str> for TorchCollate
impl<'a> Collate<&'a str> for TorchCollate
Source§impl<A> Collate<(A,)> for TorchCollate
impl<A> Collate<(A,)> for TorchCollate
Source§impl<A, B> Collate<(A, B)> for TorchCollate
impl<A, B> Collate<(A, B)> for TorchCollate
Source§impl<A, B, C> Collate<(A, B, C)> for TorchCollate
impl<A, B, C> Collate<(A, B, C)> for TorchCollate
Source§impl<A, B, C, D> Collate<(A, B, C, D)> for TorchCollate
impl<A, B, C, D> Collate<(A, B, C, D)> for TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate 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 TorchCollate
impl<A, B, C, D, E> Collate<(A, B, C, D, E)> for TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate 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 TorchCollate
impl<A, B, C, D, E, F> Collate<(A, B, C, D, E, F)> for TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate 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 TorchCollate
impl<A, B, C, D, E, F, G> Collate<(A, B, C, D, E, F, G)> for TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate 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 TorchCollate
impl<A, B, C, D, E, F, G, H> Collate<(A, B, C, D, E, F, G, H)> for TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate 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 TorchCollate
impl<A, B, C, D, E, F, G, H, I> Collate<(A, B, C, D, E, F, G, H, I)> for TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate as Collate<I>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate 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 TorchCollate
impl<A, B, C, D, E, F, G, H, I, J> Collate<(A, B, C, D, E, F, G, H, I, J)> for TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate as Collate<I>>::Output, <TorchCollate as Collate<J>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate as Collate<I>>::Output, <TorchCollate 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 TorchCollate
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 TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate as Collate<I>>::Output, <TorchCollate as Collate<J>>::Output, <TorchCollate as Collate<K>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate as Collate<I>>::Output, <TorchCollate as Collate<J>>::Output, <TorchCollate 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 TorchCollate
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 TorchCollate
Source§type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate as Collate<I>>::Output, <TorchCollate as Collate<J>>::Output, <TorchCollate as Collate<K>>::Output, <TorchCollate as Collate<L>>::Output)
type Output = (<TorchCollate as Collate<A>>::Output, <TorchCollate as Collate<B>>::Output, <TorchCollate as Collate<C>>::Output, <TorchCollate as Collate<D>>::Output, <TorchCollate as Collate<E>>::Output, <TorchCollate as Collate<F>>::Output, <TorchCollate as Collate<G>>::Output, <TorchCollate as Collate<H>>::Output, <TorchCollate as Collate<I>>::Output, <TorchCollate as Collate<J>>::Output, <TorchCollate as Collate<K>>::Output, <TorchCollate as Collate<L>>::Output)
The type of the collate function’s output
Source§impl<K, V> Collate<BTreeMap<K, V>> for TorchCollate
impl<K, V> Collate<BTreeMap<K, V>> for TorchCollate
Source§impl Collate<CString> for TorchCollate
impl Collate<CString> for TorchCollate
Source§impl<K, V, H> Collate<HashMap<K, V, H>> for TorchCollate
impl<K, V, H> Collate<HashMap<K, V, H>> for TorchCollate
Source§impl Collate<OsString> for TorchCollate
impl Collate<OsString> for TorchCollate
Source§impl Collate<String> for TorchCollate
impl Collate<String> for TorchCollate
Source§impl<T> Collate<Vec<T>> for TorchCollate
impl<T> Collate<Vec<T>> for TorchCollate
Source§impl<T> Collate<VecDeque<T>> for TorchCollate
impl<T> Collate<VecDeque<T>> for TorchCollate
Source§impl Collate<bool> for TorchCollate
impl Collate<bool> for TorchCollate
Source§impl Collate<f32> for TorchCollate
impl Collate<f32> for TorchCollate
Source§impl Collate<f64> for TorchCollate
impl Collate<f64> for TorchCollate
Source§impl Collate<i16> for TorchCollate
impl Collate<i16> for TorchCollate
Source§impl Collate<i32> for TorchCollate
impl Collate<i32> for TorchCollate
Source§impl Collate<i64> for TorchCollate
impl Collate<i64> for TorchCollate
Source§impl Collate<i8> for TorchCollate
impl Collate<i8> for TorchCollate
Source§impl Collate<u8> for TorchCollate
NoOp
for binary, as pytorch default_collate
function.
impl Collate<u8> for TorchCollate
NoOp
for binary, as pytorch default_collate
function.
Source§impl Debug for TorchCollate
impl Debug for TorchCollate
Source§impl Default for TorchCollate
impl Default for TorchCollate
Source§fn default() -> TorchCollate
fn default() -> TorchCollate
Returns the “default value” for a type. Read more
Source§impl Ord for TorchCollate
impl Ord for TorchCollate
Source§fn cmp(&self, other: &TorchCollate) -> Ordering
fn cmp(&self, other: &TorchCollate) -> 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 TorchCollate
impl PartialEq for TorchCollate
Source§impl PartialOrd for TorchCollate
impl PartialOrd for TorchCollate
impl Eq for TorchCollate
impl StructuralPartialEq for TorchCollate
Auto Trait Implementations§
impl Freeze for TorchCollate
impl RefUnwindSafe for TorchCollate
impl Send for TorchCollate
impl Sync for TorchCollate
impl Unpin for TorchCollate
impl UnwindSafe for TorchCollate
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