pub struct SplitInto<T>(pub T);
Expand description
Splits input into multiple heads. T
should be a tuple,
where every element of the tuple accepts the same input type.
This provides a utility for multi headed structures where the tape needs to be moved around a number of times.
Generics
T
the module to split the input into.
Examples
type Model = SplitInto<(Linear<5, 3>, Linear<5, 7>)>;
let model: Model = Default::default();
let _: (Tensor1D<3>, Tensor1D<7>) = model.forward(Tensor1D::<5>::zeros());
Tuple Fields
0: T
Trait Implementations
sourceimpl<T: CanUpdateWithGradients> CanUpdateWithGradients for SplitInto<T>
impl<T: CanUpdateWithGradients> CanUpdateWithGradients for SplitInto<T>
sourcefn update<G: GradientProvider>(
&mut self,
grads: &mut G,
unused: &mut UnusedTensors
)
fn update<G: GradientProvider>(
&mut self,
grads: &mut G,
unused: &mut UnusedTensors
)
Updates self given the GradientProvider. When any parameters that
are NOT present in
G
, then this function should
add the tensor’s UniqueId to UnusedTensors. Read moresourceimpl<T: LoadFromNpz> LoadFromNpz for SplitInto<T>
impl<T: LoadFromNpz> LoadFromNpz for SplitInto<T>
sourceimpl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>, D: Module<Input>, E: Module<Input>, F: Module<Input>> Module<Input> for SplitInto<(A, B, C, D, E, F)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
E::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>, D: Module<Input>, E: Module<Input>, F: Module<Input>> Module<Input> for SplitInto<(A, B, C, D, E, F)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
E::Output: Tensor<Tape = Input::Tape>,
type Output = (<<A as Module<Input>>::Output as Tensor>::NoTape, <<B as Module<Input>>::Output as Tensor>::NoTape, <<C as Module<Input>>::Output as Tensor>::NoTape, <<D as Module<Input>>::Output as Tensor>::NoTape, <<E as Module<Input>>::Output as Tensor>::NoTape, <F as Module<Input>>::Output)
type Output = (<<A as Module<Input>>::Output as Tensor>::NoTape, <<B as Module<Input>>::Output as Tensor>::NoTape, <<C as Module<Input>>::Output as Tensor>::NoTape, <<D as Module<Input>>::Output as Tensor>::NoTape, <<E as Module<Input>>::Output as Tensor>::NoTape, <F as Module<Input>>::Output)
The type that this unit produces given
Input
.sourceimpl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>, D: Module<Input>, E: Module<Input>> Module<Input> for SplitInto<(A, B, C, D, E)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>, D: Module<Input>, E: Module<Input>> Module<Input> for SplitInto<(A, B, C, D, E)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
type Output = (<<A as Module<Input>>::Output as Tensor>::NoTape, <<B as Module<Input>>::Output as Tensor>::NoTape, <<C as Module<Input>>::Output as Tensor>::NoTape, <<D as Module<Input>>::Output as Tensor>::NoTape, <E as Module<Input>>::Output)
type Output = (<<A as Module<Input>>::Output as Tensor>::NoTape, <<B as Module<Input>>::Output as Tensor>::NoTape, <<C as Module<Input>>::Output as Tensor>::NoTape, <<D as Module<Input>>::Output as Tensor>::NoTape, <E as Module<Input>>::Output)
The type that this unit produces given
Input
.sourceimpl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>, D: Module<Input>> Module<Input> for SplitInto<(A, B, C, D)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>, D: Module<Input>> Module<Input> for SplitInto<(A, B, C, D)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
sourceimpl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>> Module<Input> for SplitInto<(A, B, C)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: Module<Input>, B: Module<Input>, C: Module<Input>> Module<Input> for SplitInto<(A, B, C)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
sourceimpl<Input: Tensor, A: Module<Input>, B: Module<Input>> Module<Input> for SplitInto<(A, B)>where
A::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: Module<Input>, B: Module<Input>> Module<Input> for SplitInto<(A, B)>where
A::Output: Tensor<Tape = Input::Tape>,
sourceimpl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>, D: ModuleMut<Input>, E: ModuleMut<Input>, F: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D, E, F)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
E::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>, D: ModuleMut<Input>, E: ModuleMut<Input>, F: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D, E, F)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
E::Output: Tensor<Tape = Input::Tape>,
type Output = (<<A as ModuleMut<Input>>::Output as Tensor>::NoTape, <<B as ModuleMut<Input>>::Output as Tensor>::NoTape, <<C as ModuleMut<Input>>::Output as Tensor>::NoTape, <<D as ModuleMut<Input>>::Output as Tensor>::NoTape, <<E as ModuleMut<Input>>::Output as Tensor>::NoTape, <F as ModuleMut<Input>>::Output)
type Output = (<<A as ModuleMut<Input>>::Output as Tensor>::NoTape, <<B as ModuleMut<Input>>::Output as Tensor>::NoTape, <<C as ModuleMut<Input>>::Output as Tensor>::NoTape, <<D as ModuleMut<Input>>::Output as Tensor>::NoTape, <<E as ModuleMut<Input>>::Output as Tensor>::NoTape, <F as ModuleMut<Input>>::Output)
The type that this unit produces given
Input
.sourcefn forward_mut(&mut self, x: Input) -> Self::Output
fn forward_mut(&mut self, x: Input) -> Self::Output
sourceimpl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>, D: ModuleMut<Input>, E: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D, E)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>, D: ModuleMut<Input>, E: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D, E)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
D::Output: Tensor<Tape = Input::Tape>,
type Output = (<<A as ModuleMut<Input>>::Output as Tensor>::NoTape, <<B as ModuleMut<Input>>::Output as Tensor>::NoTape, <<C as ModuleMut<Input>>::Output as Tensor>::NoTape, <<D as ModuleMut<Input>>::Output as Tensor>::NoTape, <E as ModuleMut<Input>>::Output)
type Output = (<<A as ModuleMut<Input>>::Output as Tensor>::NoTape, <<B as ModuleMut<Input>>::Output as Tensor>::NoTape, <<C as ModuleMut<Input>>::Output as Tensor>::NoTape, <<D as ModuleMut<Input>>::Output as Tensor>::NoTape, <E as ModuleMut<Input>>::Output)
The type that this unit produces given
Input
.sourcefn forward_mut(&mut self, x: Input) -> Self::Output
fn forward_mut(&mut self, x: Input) -> Self::Output
sourceimpl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>, D: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>, D: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
C::Output: Tensor<Tape = Input::Tape>,
type Output = (<<A as ModuleMut<Input>>::Output as Tensor>::NoTape, <<B as ModuleMut<Input>>::Output as Tensor>::NoTape, <<C as ModuleMut<Input>>::Output as Tensor>::NoTape, <D as ModuleMut<Input>>::Output)
type Output = (<<A as ModuleMut<Input>>::Output as Tensor>::NoTape, <<B as ModuleMut<Input>>::Output as Tensor>::NoTape, <<C as ModuleMut<Input>>::Output as Tensor>::NoTape, <D as ModuleMut<Input>>::Output)
The type that this unit produces given
Input
.sourcefn forward_mut(&mut self, x: Input) -> Self::Output
fn forward_mut(&mut self, x: Input) -> Self::Output
sourceimpl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>, C: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C)>where
A::Output: Tensor<Tape = Input::Tape>,
B::Output: Tensor<Tape = Input::Tape>,
sourceimpl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B)>where
A::Output: Tensor<Tape = Input::Tape>,
impl<Input: Tensor, A: ModuleMut<Input>, B: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B)>where
A::Output: Tensor<Tape = Input::Tape>,
sourceimpl<T: ResetParams> ResetParams for SplitInto<T>
impl<T: ResetParams> ResetParams for SplitInto<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for SplitInto<T>where
T: RefUnwindSafe,
impl<T> Send for SplitInto<T>where
T: Send,
impl<T> Sync for SplitInto<T>where
T: Sync,
impl<T> Unpin for SplitInto<T>where
T: Unpin,
impl<T> UnwindSafe for SplitInto<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more