Skip to content

Commit a43371e

Browse files
authored
Whisper export traced with dynamic shapes (#34)
1 parent d89efa7 commit a43371e

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

models/whisper/export.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,17 @@ def create_whisper(
107107

108108
example_inputs = reference_inputs(model_name, dtype)
109109

110+
example_inputs["decoder_input_ids"] = torch.tensor(
111+
[[50258, 50259, 50360, 50364]], dtype=torch.int32
112+
)
113+
dynamic_shapes = {
114+
"input_features": {},
115+
"decoder_input_ids": {1: torch.export.Dim("dec_seq_len", min=1, max=448)},
116+
}
110117
with torch.autocast(device_type="cpu", dtype=dtype):
111-
exported = torch.export.export(model, args=(), kwargs=example_inputs)
118+
exported = torch.export.export(
119+
model, args=(), kwargs=example_inputs, dynamic_shapes=dynamic_shapes
120+
)
112121
exported = exported.run_decompositions(get_decomp_table())
113122
print("[INFO] Model exported. Converting to Core AI...")
114123

0 commit comments

Comments
 (0)