Skip to content

Commit c6751ea

Browse files
ydshiehlewtun
authored andcommitted
Fix Yolos ONNX export test (huggingface#18606)
Co-authored-by: lewtun <[email protected]> Co-authored-by: ydshieh <[email protected]>
1 parent a316ea3 commit c6751ea

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/onnx/test_onnx_v2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ def _onnx_export(self, test_name, name, model_name, feature, onnx_config_class_c
284284
model_class = FeaturesManager.get_model_class_for_feature(feature)
285285
config = AutoConfig.from_pretrained(model_name)
286286
model = model_class.from_config(config)
287+
288+
# Dynamic axes aren't supported for YOLO-like models. This means they cannot be exported to ONNX on CUDA devices.
289+
# See: https://github.com/ultralytics/yolov5/pull/8378
290+
if model.__class__.__name__.startswith("Yolos") and device != "cpu":
291+
return
292+
287293
onnx_config = onnx_config_class_constructor(model.config)
288294

289295
if is_torch_available():

0 commit comments

Comments
 (0)