Skip to content

Commit

Permalink
guard on whisper
Browse files Browse the repository at this point in the history
  • Loading branch information
fxmarty committed Oct 5, 2023
1 parent 9ac3402 commit 21f3b07
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions optimum/exporters/onnx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,13 @@ def main_export(
device=device,
library_name=library_name,
)
import torch
model = model.eval()
with torch.no_grad():
for i in range(len(model.model.decoder.layers)):
model.model.decoder.layers[i].encoder_attn = torch.jit.script(model.model.decoder.layers[i].encoder_attn)

if model.config.model_type == "whisper":
import torch
model = model.eval()
with torch.no_grad():
for i in range(len(model.model.decoder.layers)):
model.model.decoder.layers[i].encoder_attn = torch.jit.script(model.model.decoder.layers[i].encoder_attn)

custom_architecture = False
is_stable_diffusion = "stable-diffusion" in task
Expand Down

0 comments on commit 21f3b07

Please sign in to comment.