1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
    Appellation: impl_linear <impls>
    Contrib: FL03 <jo3mccain@icloud.com>
*/
use crate::{Config, Linear, LinearParams};
use core::borrow::{Borrow, BorrowMut};
use nd::RemoveAxis;

impl<T> Linear<T> {
    pub fn std(config: Config) -> Self
    where
        T: Clone + Default,
    {
        let params = LinearParams::default(config.is_biased(), config.shape);
        Self { config, params }
    }
}

impl<T, D> Borrow<Config> for Linear<T, D>
where
    D: RemoveAxis,
{
    fn borrow(&self) -> &Config {
        &self.config
    }
}

impl<T, D> Borrow<LinearParams<T, D>> for Linear<T, D>
where
    D: RemoveAxis,
{
    fn borrow(&self) -> &LinearParams<T, D> {
        &self.params
    }
}

impl<T, D> BorrowMut<LinearParams<T, D>> for Linear<T, D>
where
    D: RemoveAxis,
{
    fn borrow_mut(&mut self) -> &mut LinearParams<T, D> {
        &mut self.params
    }
}