Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcac2e86

Browse files
committed
use version
1 parentb04403a commitcac2e86

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

‎olive/common/ort_inference.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,25 @@ def initialize_inference_session_options(
7878
provider_options=provider_optionsor []
7979
provider_options_by_ep=dict(zip(providers,provider_options))
8080
ort_device_type=get_ort_hardware_device_type(device)
81-
82-
# ort.get_ep_devices may return ep_devices with the same name and device, for example when connecting remotely or when there are multiple graph cards.
81+
82+
# NOTE: In the current latest version 1.22.0:
83+
# ort.get_ep_devices may return ep_devices with the same ep_name and device, for example when connecting remotely or when there are multiple graph cards.
8384
# However, in onnxruntime, each EP name can only be added once. See: https://github.com/microsoft/onnxruntime/blob/fb0f6c652be5db0a3182c424a995efecf792d41c/onnxruntime/core/framework/execution_providers.h#L75
84-
added_ep_names=set()
85-
forep_deviceinort.get_ep_devices():
86-
ifep_device.device.type==ort_device_typeandep_device.ep_nameinprovider_options_by_epandep_device.ep_namenotinadded_ep_names:
87-
added_ep_names.add(ep_device.ep_name)
88-
sess_options.add_provider_for_devices([ep_device],provider_options_by_ep.get(ep_device.ep_name)or {})
85+
ifversion.parse(ort.__version__)<version.parse("1.22.0"):
86+
added_ep_names=set()
87+
forep_deviceinort.get_ep_devices():
88+
if (
89+
ep_device.device.type==ort_device_type
90+
andep_device.ep_nameinprovider_options_by_ep
91+
andep_device.ep_namenotinadded_ep_names
92+
):
93+
added_ep_names.add(ep_device.ep_name)
94+
sess_options.add_provider_for_devices([ep_device],provider_options_by_ep.get(ep_device.ep_name)or {})
95+
else:
96+
# In ort v1.22.0 and later, we can use add_provider_for_devices to add providers with options.
97+
forep_deviceinort.get_ep_devices():
98+
ifep_device.device.type==ort_device_typeandep_device.ep_nameinprovider_options_by_ep:
99+
sess_options.add_provider_for_devices([ep_device],provider_options_by_ep.get(ep_device.ep_name)or {})
89100

90101
ifprovider_selection_policy:
91102
provider_selection_policy=get_ort_execution_provider_device_policy(provider_selection_policy)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp