concision_core/models/layout/
impl_model_layout.rs1use super::ModelLayout;
7
8use crate::models::{Deep, NetworkDepth, RawModelLayout, Shallow};
9
10impl<F, D> ModelLayout<F, D>
11where
12 F: RawModelLayout,
13 D: NetworkDepth,
14{
15 pub const fn new(features: F) -> Self {
17 Self {
18 features,
19 _marker: core::marker::PhantomData::<D>,
20 }
21 }
22 pub const fn features(&self) -> &F {
24 &self.features
25 }
26 pub const fn features_mut(&mut self) -> &mut F {
28 &mut self.features
29 }
30 pub fn input(&self) -> usize {
32 self.features().input()
33 }
34 pub fn output(&self) -> usize {
36 self.features().output()
37 }
38 pub fn hidden(&self) -> usize {
40 self.features().hidden()
41 }
42 pub fn layers(&self) -> usize {
44 self.features().depth()
45 }
46}
47
48impl<F, D> core::ops::Deref for ModelLayout<F, D>
49where
50 F: RawModelLayout,
51 D: NetworkDepth,
52{
53 type Target = F;
54
55 fn deref(&self) -> &Self::Target {
56 &self.features
57 }
58}
59
60impl<F, D> core::ops::DerefMut for ModelLayout<F, D>
61where
62 F: RawModelLayout,
63 D: NetworkDepth,
64{
65 fn deref_mut(&mut self) -> &mut Self::Target {
66 &mut self.features
67 }
68}
69
70impl<F> ModelLayout<F, Deep>
71where
72 F: RawModelLayout,
73{
74 pub const fn deep(features: F) -> Self {
76 Self::new(features)
77 }
78}
79
80impl<F> ModelLayout<F, Shallow>
81where
82 F: RawModelLayout,
83{
84 pub const fn shallow(features: F) -> Self {
86 Self::new(features)
87 }
88}