Struct dfdx::nn::tensor_collection::RecursiveWalker
source · pub struct RecursiveWalker<'a, M, F> {
pub m: M,
pub f: &'a mut F,
}
Expand description
A standard ModuleVisitor that executes F
on every Tensor encountered.
F
must implement TensorVisitor
Fields§
§m: M
§f: &'a mut F
Trait Implementations§
source§impl<'a, T: TensorCollection<E, D>, E: Dtype, D: Device<E>, F: TensorVisitor<E, D>> ModuleVisitor<T, E, D> for RecursiveWalker<'a, <F::Viewer as TensorViewer>::View<'a, T>, F>
impl<'a, T: TensorCollection<E, D>, E: Dtype, D: Device<E>, F: TensorVisitor<E, D>> ModuleVisitor<T, E, D> for RecursiveWalker<'a, <F::Viewer as TensorViewer>::View<'a, T>, F>
type Err = <F as TensorVisitor<E, D>>::Err
type E2 = <F as TensorVisitor<E, D>>::E2
type D2 = <F as TensorVisitor<E, D>>::D2
source§fn visit_module<Field, GetRef, GetMut>(
&mut self,
name: &str,
get_refs: GetRef,
get_muts: GetMut
) -> Result<Option<Field::To<Self::E2, Self::D2>>, Self::Err>where
GetRef: FnMut(&T) -> &Field,
GetMut: FnMut(&mut T) -> &mut Field,
Field: TensorCollection<E, D>,
fn visit_module<Field, GetRef, GetMut>( &mut self, name: &str, get_refs: GetRef, get_muts: GetMut ) -> Result<Option<Field::To<Self::E2, Self::D2>>, Self::Err>where GetRef: FnMut(&T) -> &Field, GetMut: FnMut(&mut T) -> &mut Field, Field: TensorCollection<E, D>,
Visit a TensorCollection. Do not use this; use visit_fields instead.
source§fn visit_tensor<S: Shape, GetRef, GetMut>(
&mut self,
name: &str,
get_refs: GetRef,
get_muts: GetMut,
opts: TensorOptions<S, E, D>
) -> Result<Option<Tensor<S, Self::E2, Self::D2>>, Self::Err>where
GetRef: FnMut(&T) -> &Tensor<S, E, D>,
GetMut: FnMut(&mut T) -> &mut Tensor<S, E, D>,
fn visit_tensor<S: Shape, GetRef, GetMut>( &mut self, name: &str, get_refs: GetRef, get_muts: GetMut, opts: TensorOptions<S, E, D> ) -> Result<Option<Tensor<S, Self::E2, Self::D2>>, Self::Err>where GetRef: FnMut(&T) -> &Tensor<S, E, D>, GetMut: FnMut(&mut T) -> &mut Tensor<S, E, D>,
Visits an actual named Tensor. Do not use this; use visit_fields instead.
source§fn visit_fields<M: ModuleFields<T, E, D>>(
&mut self,
fields: M,
builder: impl FnOnce(M::Output<Self::E2, Self::D2>) -> T::To<Self::E2, Self::D2>
) -> Result<Option<T::To<Self::E2, Self::D2>>, Self::Err>
fn visit_fields<M: ModuleFields<T, E, D>>( &mut self, fields: M, builder: impl FnOnce(M::Output<Self::E2, Self::D2>) -> T::To<Self::E2, Self::D2> ) -> Result<Option<T::To<Self::E2, Self::D2>>, Self::Err>
Takes something that implements ModuleFields and function that takes
ModuleFields::Output and returns an instance of T.