Correct logic for GPU backend detection (#13944)

Currently these checks yield the opposite of the desired logic.
This commit is contained in:
Joseph Groenenboom 2022-12-12 19:11:25 -06:00 committed by GitHub
parent 526368f4d8
commit 067d425306
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,7 +74,7 @@ def optimize_by_onnxruntime(
import onnxruntime
if use_gpu and not set(onnxruntime.get_available_providers()).isdisjoint(
if use_gpu and set(onnxruntime.get_available_providers()).isdisjoint(
["CUDAExecutionProvider", "ROCMExecutionProvider", "MIGraphXExecutionProvider"]
):
logger.error("There is no gpu for onnxruntime to do optimization.")
@ -112,7 +112,7 @@ def optimize_by_onnxruntime(
gpu_ep.append("ROCMExecutionProvider")
session = onnxruntime.InferenceSession(onnx_model_path, sess_options, providers=gpu_ep, **kwargs)
assert set(onnxruntime.get_available_providers()).isdisjoint(
assert not set(onnxruntime.get_available_providers()).isdisjoint(
["CUDAExecutionProvider", "ROCMExecutionProvider", "MIGraphXExecutionProvider"]
)