Skip to content

Commit

Permalink
token preproc
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsteyk committed Feb 18, 2023
1 parent bfa05f6 commit 4e1d03e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rwkv_rs"
version = "0.2.1"
version = "0.2.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
6 changes: 6 additions & 0 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ impl Rwkv {
Ok(self.inner.rwkv().forward_raw(tokens.last().unwrap(), &mut state.inner))
}

pub fn forward_token_preproc(&self, token: usize, state: &mut State) -> PyResult<()> {
let x = self.inner.rwkv().emb.get(token).ok_or(anyhow::anyhow!(RwkvError::InvalidToken(token)))?;
self.inner.rwkv().forward_raw_preproc(x, &mut state.inner);
Ok(())
}

pub fn forward_token(&self, token: usize, state: &mut State) -> PyResult<Vec<f32>> {
let x = self.inner.rwkv().emb.get(token).ok_or(anyhow::anyhow!(RwkvError::InvalidToken(token)))?;
Ok(self.inner.rwkv().forward_raw(x, &mut state.inner))
Expand Down

0 comments on commit 4e1d03e

Please # to comment.