rwkv.cpp python38 compatibility

This commit is contained in:
josc146 2023-12-12 23:19:18 +08:00
parent 26b30f0dbe
commit 82c9825da8

View File

@ -1,4 +1,4 @@
from typing import Any, List from typing import Any, List, Union
from . import rwkv_cpp_model from . import rwkv_cpp_model
from . import rwkv_cpp_shared_library from . import rwkv_cpp_shared_library
@ -10,5 +10,5 @@ class RWKV:
self.w = {} # fake weight self.w = {} # fake weight
self.w["emb.weight"] = [0] * self.model.n_vocab self.w["emb.weight"] = [0] * self.model.n_vocab
def forward(self, tokens: List[int], state: Any | None): def forward(self, tokens: List[int], state: Union[Any, None] = None):
return self.model.eval_sequence_in_chunks(tokens, state, use_numpy=True) return self.model.eval_sequence_in_chunks(tokens, state, use_numpy=True)