Change RuntimeError to ImportError (#17380)

The `onnxruntime-validation` for ORTModule checks for `ImportError`:


44101e8771/onnxruntime/python/onnxruntime_validation.py (L73-L75)

If any other kind of error is raised, it does not silently fail and will
raise an exception. This causes a problem when ortmodule is explicitly
not made available on win/mac packages since we currently raise a
RuntimeError.

Resolves issue:
https://github.com/microsoft/onnxruntime-training-examples/issues/161
This commit is contained in:
Baiju Meswani 2023-08-31 18:56:40 -07:00 committed by GitHub
parent 16cfcd0590
commit 8b98ecad70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,7 +18,7 @@ from ._fallback import ORTModuleFallbackException, ORTModuleInitException, _Fall
from .torch_cpp_extensions import is_installed as is_torch_cpp_extensions_installed
if not is_ortmodule_available():
raise RuntimeError("ORTModule is not supported on this platform.")
raise ImportError("ORTModule is not supported on this platform.")
def _defined_from_envvar(name, default_value, warn=True):