Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new OpenVINO Python API features #2

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change args
  • Loading branch information
jiwaszki committed Jun 29, 2023
commit 6873608af2c63d074a2bc6491aa114ceb3002e87
10 changes: 5 additions & 5 deletions whisper/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from torch import nn

from huggingface_hub import hf_hub_download
from openvino.runtime import Core, ReturnPolicy
from openvino.runtime import Core

from .transcribe import transcribe as transcribe_function
from .decoding import detect_language as detect_language_function, decode as decode_function
Expand Down Expand Up @@ -41,8 +41,8 @@ def __init__(self, model: str):
def forward(self, x: Tensor):
result = self.model(
x,
shared_memory=True,
return_policy=ReturnPolicy.VIEW,
share_inputs=True,
share_outputs=True,
)
return torch.from_numpy(result[0])

Expand All @@ -66,8 +66,8 @@ def forward(self, x: Tensor, xa: Union[Tensor, np.ndarray], kv_cache: Tensor, of
"kv_cache": kv_cache,
"offset": np.array(offset, dtype=int),
},
shared_memory=True,
return_policy=ReturnPolicy.VIEW,
share_inputs=True,
share_outputs=True,
)
return torch.from_numpy(output["logits"]), output["output_kv_cache"]

Expand Down