Skip to content

Commit

Permalink
Adding docstring to Sequential
Browse files Browse the repository at this point in the history
  • Loading branch information
coreylowman committed Aug 30, 2023
1 parent 1e61b9a commit 13ccd08
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions dfdx-nn-derives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,36 @@ pub fn custom_module(input: proc_macro::TokenStream) -> proc_macro::TokenStream
})
}

/// Implements all of the dfdx_nn traits automatically on your type. Assumes all fields on your type
/// are modules (i.e. they also implement all the dfdx_nn traits).
///
/// [dfdx_nn::Module] is implemented as calling each of the fields on the type in definition order.
///
/// # Example usage
/// Here we define a simple feedforward network with 3 layers.
/// the `#[derive(Sequential)]` means the built module will execute
/// the layers in **specification** order. So it will execute in the following order:
/// 1. linear1
/// 2. act1
/// 3. linear2
/// 4. act2
/// 5. linear3
/// ```rust
/// # use dfdx::prelude::*;
/// # use dfdx_nn::*;
/// #[derive(Debug, Clone, Sequential)]
/// #[built(Mlp)]
/// struct MlpConfig {
/// // Linear with compile time input size & runtime known output size
/// linear1: LinearConfig<Const<784>, usize>,
/// act1: ReLU,
/// // Linear with runtime input & output size
/// linear2: LinearConfig<usize, usize>,
/// act2: Tanh,
/// // Linear with runtime input & compile time output size.
/// linear3: LinearConfig<usize, Const<10>>,
/// }
/// ```
#[proc_macro_derive(Sequential, attributes(built))]
pub fn sequential(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as DeriveInput);
Expand Down

0 comments on commit 13ccd08

Please sign in to comment.