Skip to content

Commit

Permalink
moved technical import under a condition related to TVM EP only
Browse files Browse the repository at this point in the history
  • Loading branch information
KJlaccHoeUM9l committed Jan 17, 2022
1 parent 816658d commit 47e89f8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions onnxruntime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@
except ImportError:
pass

try:
# Working between the C++ and Python parts in TVM EP is done using the PackedFunc and Registry classes.
# In order to use a Python function in C++ code, it must be registered in the global table of functions.
# Registration is carried out through the JIT interface, so it is necessary to call
# special functions for registration. To do this, we need to make the following import.
import onnxruntime.providers.stvm
except ImportError:
pass
if "StvmExecutionProvider" in get_available_providers():
try:
# Working between the C++ and Python parts in TVM EP is done using the PackedFunc and Registry classes.
# In order to use a Python function in C++ code, it must be registered in the global table of functions.
# Registration is carried out through the JIT interface, so it is necessary to call
# special functions for registration. To do this, we need to make the following import.
import onnxruntime.providers.stvm
except ImportError as e:
onnxruntime_validation.warnings.warn(
f"WARNING: Failed to register python functions to work with TVM EP. More details: {e}"
)

from onnxruntime.capi.onnxruntime_validation import package_name, version, cuda_version
if version:
Expand Down

0 comments on commit 47e89f8

Please sign in to comment.