pytorch/torch/_dynamo/backends/onnxrt.py
Edward Z. Yang d03173e88c Unify MYPYINDUCTOR and MYPY (#118432)
The original motivation for MYPYINDUCTOR was a faster type checking configuration that only checked a subset of files. With the removal of `follow_imports = ignore`, we are now able to use dmypy to do fast incremental typechecking, eliminating the need for this.

Perhaps erroneously, when I tee'ed up this PR I elected to delete the `follow_imports = skip` designations in the mypy-inductor.ini. This lead to a number of extra type error suppressions that I manually edited. You will need to review.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/118432
Approved by: https://github.com/Skylion007
ghstack dependencies: #118414, #118418
2024-01-27 17:23:20 +00:00

38 lines
1.5 KiB
Python

# mypy: ignore-errors
# This backend is maintained by ONNX team. To direct issues
# to the right people, please tag related GitHub issues with `module: onnx`.
#
# Maintainers' Github IDs: wschin, thiagocrepaldi, BowenBao, abock
from torch.onnx._internal.onnxruntime import (
is_onnxrt_backend_supported,
torch_compile_backend,
)
from .registry import register_backend
def has_onnxruntime():
# FIXME(abock): update test/dynamo/test_backends.py to call is_onnxrt_backend_supported()
return is_onnxrt_backend_supported()
if is_onnxrt_backend_supported():
register_backend(name="onnxrt", compiler_fn=torch_compile_backend)
else:
def information_displaying_backend(*args, **kwargs):
raise ImportError(
"onnxrt is not registered as a backend. "
"Please make sure all dependencies such as "
"numpy, onnx, onnxscript, and onnxruntime-training are installed. "
"Suggested procedure to fix dependency problem:\n"
" (1) pip or conda install numpy onnx onnxscript onnxruntime-training.\n"
" (2) Open a new python terminal.\n"
" (3) Call the API `torch.onnx.is_onnxrt_backend_supported()`:\n"
" (4) If it returns `True`, then you can use `onnxrt` backend.\n"
" (5) If it returns `False`, please execute the package importing section in "
"torch/onnx/_internal/onnxruntime.py under pdb line-by-line to see which import fails."
)
register_backend(name="onnxrt", compiler_fn=information_displaying_backend)