Skip to content

Commit

Permalink
disable dynamic axes
Browse files Browse the repository at this point in the history
  • Loading branch information
mertalev committed Feb 3, 2024
1 parent b768eef commit 16ba6ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions machine-learning/app/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,17 @@ def provider_options_default(self) -> list[dict[str, Any]]:
case "CPUExecutionProvider" | "CUDAExecutionProvider":
option = {"arena_extend_strategy": "kSameAsRequested"}
case "OpenVINOExecutionProvider":
option = {"disable_dynamic_shapes": True}
try:
device_ids: list[str] = ort.capi._pybind_state.get_available_openvino_device_ids()
log.debug(f"Available OpenVINO devices: {device_ids}")
gpu_devices = [device_id for device_id in device_ids if device_id.startswith("GPU")]
option = {"device_id": gpu_devices[0]} if gpu_devices else {}
if gpu_devices:
option["device_id"] = gpu_devices[0]

except AttributeError as e:
log.warning("Failed to get OpenVINO device IDs. Using default options.")
log.error(e)
option = {}
case _:
option = {}
options.append(option)
Expand Down
2 changes: 1 addition & 1 deletion machine-learning/app/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_sets_default_provider_options(self) -> None:
encoder = OpenCLIPEncoder("ViT-B-32__openai", providers=["OpenVINOExecutionProvider", "CPUExecutionProvider"])

assert encoder.provider_options == [
{},
{"disable_dynamic_shapes": True},
{"arena_extend_strategy": "kSameAsRequested"},
]

Expand Down

0 comments on commit 16ba6ca

Please sign in to comment.