Skip to content

Commit 9816f62

Browse files
committed
coreml : skip model load in convert-whisper-to-coreml.py
This commit adds the `skip_model_load` argument to the `convert_encoder` and `convert_decoder` functions in the `convert-whisper-to-coreml.py` file. The motivation for this is that this is only needed if one intends to perform inference on the model after conversion. In this case it also seem to avoid an issue with larger models where the following error is throws: ```console Running MIL backend_neuralnetwork pipeline: 100%|█████████| 9/9 [00:00<00:00, 35.44 passes/s] Translating MIL ==> NeuralNetwork Ops: 100%|███████████| 5641/5641 [03:31<00:00, 26.65 ops/s] Traceback (most recent call last): File "/Users/danbev/work/ai/whisper-work/models/convert-whisper-to-coreml.py", line 322, in <module> encoder = convert_encoder(hparams, encoder, quantize=args.quantize) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/danbev/work/ai/whisper-work/models/convert-whisper-to-coreml.py", line 255, in convert_encoder model = ct.convert( ^^^^^^^^^^^ File "/Users/danbev/work/ai/whisper-work/venv/lib/python3.11/site-packages/coremltools/converters/_converters_entry.py", line 635, in convert mlmodel = mil_convert( ^^^^^^^^^^^^ File "/Users/danbev/work/ai/whisper-work/venv/lib/python3.11/site-packages/coremltools/converters/mil/converter.py", line 186, in mil_convert return _mil_convert( ^^^^^^^^^^^^^ File "/Users/danbev/work/ai/whisper-work/venv/lib/python3.11/site-packages/coremltools/converters/mil/converter.py", line 245, in _mil_convert return modelClass( ^^^^^^^^^^^ File "/Users/danbev/work/ai/whisper-work/venv/lib/python3.11/site-packages/coremltools/models/model.py", line 489, in __init__ self.__proxy__, self._spec, self._framework_error = self._get_proxy_and_spec( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/danbev/work/ai/whisper-work/venv/lib/python3.11/site-packages/coremltools/models/model.py", line 550, in _get_proxy_and_spec _MLModelProxy( ValueError: basic_string ``` Refs: #3012
1 parent f0d2bfb commit 9816f62

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

models/convert-whisper-to-coreml.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ def convert_encoder(hparams, model, quantize=False):
257257
convert_to="neuralnetwork",
258258
inputs=[ct.TensorType(name="logmel_data", shape=input_shape)],
259259
outputs=[ct.TensorType(name="output")],
260-
compute_units=ct.ComputeUnit.ALL
260+
compute_units=ct.ComputeUnit.ALL,
261+
skip_model_load=True,
261262
)
262263

263264
if quantize:
@@ -282,7 +283,8 @@ def convert_decoder(hparams, model, quantize=False):
282283
inputs=[
283284
ct.TensorType(name="token_data", shape=tokens_shape, dtype=int),
284285
ct.TensorType(name="audio_data", shape=audio_shape)
285-
]
286+
],
287+
skip_model_load=True,
286288
)
287289

288290
if quantize:

0 commit comments

Comments
 (0)