Map a flat layer index to (stack_idx, layer_in_stack).
(&self, flat_idx: usize)
| 101 | |
| 102 | /// Map a flat layer index to (stack_idx, layer_in_stack). |
| 103 | pub fn flat_to_stack(&self, flat_idx: usize) -> (usize, usize) { |
| 104 | let mut remaining = flat_idx; |
| 105 | for (stack_idx, &count) in self.model.fm_decoder_num_layers.iter().enumerate() { |
| 106 | if remaining < count { |
| 107 | return (stack_idx, remaining); |
| 108 | } |
| 109 | remaining -= count; |
| 110 | } |
| 111 | panic!("flat_idx {} out of range", flat_idx); |
| 112 | } |
| 113 | |
| 114 | /// Check if a flat layer index is the first layer of its stack. |
| 115 | pub fn is_stack_first(&self, flat_idx: usize) -> bool { |
no outgoing calls
no test coverage detected