Skip to content

Commit

Permalink
[refactor] more compact tri-layer apply method
Browse files Browse the repository at this point in the history
  • Loading branch information
dariogoetz committed Nov 27, 2023
1 parent bd1acac commit 6f21ccf
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,10 @@ struct TriLayer {
}

impl TriLayer {
fn apply(&self, last_layer: usize, second_to_last_layer: usize) -> Option<usize> {
if (last_layer == self.activation_layers.0
&& second_to_last_layer == self.activation_layers.1)
|| (last_layer == self.activation_layers.1
&& second_to_last_layer == self.activation_layers.0)
{
Some(self.target_layer)
} else {
None
}
fn apply(&self, layer_0: usize, layer_1: usize) -> Option<usize> {
(self.activation_layers == (layer_0, layer_1)
|| self.activation_layers == (layer_1, layer_0))
.then_some(self.target_layer)
}
}

Expand Down

0 comments on commit 6f21ccf

Please sign in to comment.