Struct dfdx::nn::modules::SplitInto

source ·
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 = dev.build_module::<Model, f32>();
let _: (Tensor<Rank1<3>, f32, _>, Tensor<Rank1<7>, f32, _>) = model.forward(dev.zeros::<Rank1<5>>());

Tuple Fields§

§0: T

Trait Implementations§

source§

impl<T: BuildOnDevice<D, E>, D: Device<E>, E: Dtype> BuildOnDevice<D, E> for SplitInto<T>

§

type Built = SplitInto<<T as BuildOnDevice<D, E>>::Built>

source§

fn build_on_device(device: &D) -> Self::Built

source§

fn try_build_on_device(device: &D) -> Result<Self::Built, D::Err>

source§

impl<T: Clone> Clone for SplitInto<T>

source§

fn clone(&self) -> SplitInto<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for SplitInto<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Default> Default for SplitInto<T>

source§

fn default() -> SplitInto<T>

Returns the “default value” for a type. Read more
source§

impl<Input: SplitTape, A: Module<Input, Error = B::Error>, B: Module<Input>> Module<Input> for SplitInto<(A, B)>where A::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as Module<Input>>::Output as SplitTape>::NoTape, <B as Module<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <B as Module<Input>>::Error

source§

fn try_forward(&self, x: Input) -> Result<Self::Output, B::Error>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<Input: SplitTape, A: Module<Input, Error = C::Error>, B: Module<Input, Error = C::Error>, C: Module<Input>> Module<Input> for SplitInto<(A, B, C)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as Module<Input>>::Output as SplitTape>::NoTape, <<B as Module<Input>>::Output as SplitTape>::NoTape, <C as Module<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <C as Module<Input>>::Error

source§

fn try_forward(&self, x: Input) -> Result<Self::Output, C::Error>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<Input: SplitTape, A: Module<Input, Error = D::Error>, B: Module<Input, Error = D::Error>, C: Module<Input, Error = D::Error>, D: Module<Input>> Module<Input> for SplitInto<(A, B, C, D)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>, C::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as Module<Input>>::Output as SplitTape>::NoTape, <<B as Module<Input>>::Output as SplitTape>::NoTape, <<C as Module<Input>>::Output as SplitTape>::NoTape, <D as Module<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <D as Module<Input>>::Error

source§

fn try_forward(&self, x: Input) -> Result<Self::Output, D::Error>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<Input: SplitTape, A: Module<Input, Error = E::Error>, B: Module<Input, Error = E::Error>, C: Module<Input, Error = E::Error>, D: Module<Input, Error = E::Error>, E: Module<Input>> Module<Input> for SplitInto<(A, B, C, D, E)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>, C::Output: SplitTape<Tape = Input::Tape>, D::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as Module<Input>>::Output as SplitTape>::NoTape, <<B as Module<Input>>::Output as SplitTape>::NoTape, <<C as Module<Input>>::Output as SplitTape>::NoTape, <<D as Module<Input>>::Output as SplitTape>::NoTape, <E as Module<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <E as Module<Input>>::Error

source§

fn try_forward(&self, x: Input) -> Result<Self::Output, E::Error>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<Input: SplitTape, A: Module<Input, Error = F::Error>, B: Module<Input, Error = F::Error>, C: Module<Input, Error = F::Error>, D: Module<Input, Error = F::Error>, E: Module<Input, Error = F::Error>, F: Module<Input>> Module<Input> for SplitInto<(A, B, C, D, E, F)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>, C::Output: SplitTape<Tape = Input::Tape>, D::Output: SplitTape<Tape = Input::Tape>, E::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as Module<Input>>::Output as SplitTape>::NoTape, <<B as Module<Input>>::Output as SplitTape>::NoTape, <<C as Module<Input>>::Output as SplitTape>::NoTape, <<D as Module<Input>>::Output as SplitTape>::NoTape, <<E as Module<Input>>::Output as SplitTape>::NoTape, <F as Module<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <F as Module<Input>>::Error

source§

fn try_forward(&self, x: Input) -> Result<Self::Output, F::Error>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<Input: SplitTape, A: ModuleMut<Input, Error = B::Error>, B: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B)>where A::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as ModuleMut<Input>>::Output as SplitTape>::NoTape, <B as ModuleMut<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <B as ModuleMut<Input>>::Error

source§

fn try_forward_mut(&mut self, x: Input) -> Result<Self::Output, B::Error>

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<Input: SplitTape, A: ModuleMut<Input, Error = C::Error>, B: ModuleMut<Input, Error = C::Error>, C: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<B as ModuleMut<Input>>::Output as SplitTape>::NoTape, <C as ModuleMut<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <C as ModuleMut<Input>>::Error

source§

fn try_forward_mut(&mut self, x: Input) -> Result<Self::Output, C::Error>

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<Input: SplitTape, A: ModuleMut<Input, Error = D::Error>, B: ModuleMut<Input, Error = D::Error>, C: ModuleMut<Input, Error = D::Error>, D: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>, C::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<B as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<C as ModuleMut<Input>>::Output as SplitTape>::NoTape, <D as ModuleMut<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <D as ModuleMut<Input>>::Error

source§

fn try_forward_mut(&mut self, x: Input) -> Result<Self::Output, D::Error>

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<Input: SplitTape, A: ModuleMut<Input, Error = E::Error>, B: ModuleMut<Input, Error = E::Error>, C: ModuleMut<Input, Error = E::Error>, D: ModuleMut<Input, Error = E::Error>, E: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D, E)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>, C::Output: SplitTape<Tape = Input::Tape>, D::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<B as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<C as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<D as ModuleMut<Input>>::Output as SplitTape>::NoTape, <E as ModuleMut<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <E as ModuleMut<Input>>::Error

source§

fn try_forward_mut(&mut self, x: Input) -> Result<Self::Output, E::Error>

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<Input: SplitTape, A: ModuleMut<Input, Error = F::Error>, B: ModuleMut<Input, Error = F::Error>, C: ModuleMut<Input, Error = F::Error>, D: ModuleMut<Input, Error = F::Error>, E: ModuleMut<Input, Error = F::Error>, F: ModuleMut<Input>> ModuleMut<Input> for SplitInto<(A, B, C, D, E, F)>where A::Output: SplitTape<Tape = Input::Tape>, B::Output: SplitTape<Tape = Input::Tape>, C::Output: SplitTape<Tape = Input::Tape>, D::Output: SplitTape<Tape = Input::Tape>, E::Output: SplitTape<Tape = Input::Tape>,

§

type Output = (<<A as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<B as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<C as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<D as ModuleMut<Input>>::Output as SplitTape>::NoTape, <<E as ModuleMut<Input>>::Output as SplitTape>::NoTape, <F as ModuleMut<Input>>::Output)

The type that this unit produces given Input.
§

type Error = <F as ModuleMut<Input>>::Error

source§

fn try_forward_mut(&mut self, x: Input) -> Result<Self::Output, F::Error>

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<E: Dtype, D: Device<E>, T: TensorCollection<E, D>> TensorCollection<E, D> for SplitInto<T>

§

type To<E2: Dtype, D2: Device<E2>> = SplitInto<<T as TensorCollection<E, D>>::To<E2, D2>>

Type alias that specifies the how a module’s type changes when using a different dtype and/or device.
source§

fn iter_tensors<V: ModuleVisitor<Self, E, D>>( visitor: &mut V ) -> Result<Option<Self::To<V::E2, V::D2>>, V::Err>

Specifies how to iterate through tensors or modules containted within this module, and how to contruct this module given values for its fields. Returns Err(_) to indicate an error, Ok(None) to indicate that there is no error and a module has not been built, and Ok(Some(_)) contains Self::Output<E2, D2>
source§

fn module<F1, F2, Field>( name: &str, get_ref: F1, get_mut: F2 ) -> ModuleField<'_, F1, F2, Self, Field>where F1: FnMut(&Self) -> &Field, F2: FnMut(&mut Self) -> &mut Field, Field: TensorCollection<E, D>,

Creates a ModuleFields that represents a field that may contain one or more tensors. Read more
source§

fn tensor<F1, F2, S>( name: &str, get_ref: F1, get_mut: F2, options: TensorOptions<S, E, D> ) -> TensorField<'_, F1, F2, Self, S, E, D>where F1: FnMut(&Self) -> &Tensor<S, E, D>, F2: FnMut(&mut Self) -> &mut Tensor<S, E, D>, S: Shape,

Creates a ModuleFields that represents a tensor field. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V