Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TensorRT EP] Avoid calling unavailable function with cpu python package #19251

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions onnxruntime/python/onnxruntime_inference_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def _create_inference_session(self, providers, provider_options, disabled_optimi

session_options = self._sess_options if self._sess_options else C.get_default_session_options()

self._register_ep_custom_ops(session_options, providers, provider_options)
self._register_ep_custom_ops(session_options, providers, provider_options, available_providers)

if self._model_path:
sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
Expand Down Expand Up @@ -510,11 +510,11 @@ def _reset_session(self, providers, provider_options):
self._sess_options = self._sess_options_initial
self._create_inference_session(providers, provider_options)

def _register_ep_custom_ops(self, session_options, providers, provider_options):
def _register_ep_custom_ops(self, session_options, providers, provider_options, available_providers):
for i in range(len(providers)):
if providers[i] == "TensorrtExecutionProvider":
if providers[i] in available_providers and providers[i] == "TensorrtExecutionProvider":
C.register_tensorrt_plugins_as_custom_ops(session_options, provider_options[i])
elif isinstance(providers[i], tuple) and providers[i][0] == "TensorrtExecutionProvider":
elif isinstance(providers[i], tuple) and providers[i][0] in available_providers and providers[i][0] == "TensorrtExecutionProvider":
C.register_tensorrt_plugins_as_custom_ops(session_options, providers[i][1])


Expand Down
Loading