From 18e81f8785a160977561769e7183a466b302615d Mon Sep 17 00:00:00 2001 From: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com> Date: Fri, 11 Oct 2024 17:37:36 -0700 Subject: [PATCH] Fix Whisper export for FP16 CUDA (#22410) ### Description This PR fixes a bug when the ONNX checker is called while exporting Whisper for FP16 CUDA with optional flags. ### Motivation and Context Sometimes, the ONNX checker raises an error depending on the optional flags passed. By wrapping the ONNX checker in a try-except, the conversion can continue even if the checker fails. --- .../tools/transformers/models/whisper/whisper_chain.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/onnxruntime/python/tools/transformers/models/whisper/whisper_chain.py b/onnxruntime/python/tools/transformers/models/whisper/whisper_chain.py index be05ebc9d5dac..87ac45101f0c0 100644 --- a/onnxruntime/python/tools/transformers/models/whisper/whisper_chain.py +++ b/onnxruntime/python/tools/transformers/models/whisper/whisper_chain.py @@ -323,4 +323,7 @@ def chain_model(args): convert_attribute=True, location=f"{os.path.basename(args.beam_model_output_dir)}.data", ) - onnx.checker.check_model(args.beam_model_output_dir, full_check=True) + try: + onnx.checker.check_model(args.beam_model_output_dir, full_check=True) + except Exception as e: + logger.error(f"An error occurred while running the ONNX checker: {e}", exc_info=True) # noqa: G201