Skip to content

Commit

Permalink
Update append_token_to_bloks
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler committed Jul 12, 2024
1 parent ad5a600 commit 2f86be5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/scheduler/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,22 @@ impl _Sequence {

fn append_token_to_blocks(&mut self, token: usize) {
let last = self.logical_token_blocks.last_mut();
if last.is_some() && !last.as_ref().is_some_and(|last| last.is_full()) {
// If we have space
let last = last.unwrap();
last.append_token_id(token);
} else {
self.logical_token_blocks
.push(LogicalTokenBlock::new(self.block_size));
match last {
Some(last) => {
last.append_token_id(tok);
}
None => {
self.logical_token_blocks
.push(LogicalTokenBlock::new(self.block_size));
self.logical_token_blocks
.last_mut()
.unwrap()
.append_token_id(tok);
}
}
if self.logical_token_blocks.last().as_ref().unwrap().is_full() {
self.logical_token_blocks
.last_mut()
.unwrap()
.append_token_id(token);
.push(LogicalTokenBlock::new(*block_size));
}
}
}
Expand Down

0 comments on commit 2f86be5

Please sign in to comment.