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 more
sourceimpl<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
.
sourcefn forward(&self, x: Input) -> Self::Output
fn forward(&self, x: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourcefn forward_mut(&mut self, input: Input) -> Self::Output
fn forward_mut(&mut self, input: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
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
.
sourcefn forward(&self, x: Input) -> Self::Output
fn forward(&self, x: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourcefn forward_mut(&mut self, input: Input) -> Self::Output
fn forward_mut(&mut self, input: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
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>,
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)
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)
The type that this unit produces given Input
.
sourcefn forward(&self, x: Input) -> Self::Output
fn forward(&self, x: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourcefn forward_mut(&mut self, input: Input) -> Self::Output
fn forward_mut(&mut self, input: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
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>,
type Output = (<<A as Module<Input>>::Output as Tensor>::NoTape, <<B as Module<Input>>::Output as Tensor>::NoTape, <C 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)
The type that this unit produces given Input
.
sourcefn forward(&self, x: Input) -> Self::Output
fn forward(&self, x: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourcefn forward_mut(&mut self, input: Input) -> Self::Output
fn forward_mut(&mut self, input: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
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>,
type Output = (<<A as Module<Input>>::Output as Tensor>::NoTape, <B as Module<Input>>::Output)
type Output = (<<A as Module<Input>>::Output as Tensor>::NoTape, <B as Module<Input>>::Output)
The type that this unit produces given Input
.
sourcefn forward(&self, x: Input) -> Self::Output
fn forward(&self, x: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourcefn forward_mut(&mut self, input: Input) -> Self::Output
fn forward_mut(&mut self, input: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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