Skip to content

Commit

Permalink
[Frontend] Make onnx dependency optional (#33)
Browse files Browse the repository at this point in the history
make onnx dependency optional
  • Loading branch information
yaoyaoding committed Dec 19, 2022
1 parent 8c77350 commit bfef9df
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions python/hidet/graph/frontend/onnx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .availability import available

if available():
from .onnx import from_onnx
19 changes: 19 additions & 0 deletions python/hidet/graph/frontend/onnx/availability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
try:
import onnx # pylint: disable=unused-import
except ImportError:
onnx = None
_available = False
else:
_available = True


def available():
"""
Check if onnx is installed.
Returns
-------
ret: bool
True if torch is installed.
"""
return _available
File renamed without changes.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ torchvision
transformers

# check the correctness with onnxruntime
onnx
onnxruntime-gpu
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ tqdm
# in Nsight System.
nvtx

# for onnx frontend
onnx

# for print python ast node
astunparse

Expand Down
2 changes: 2 additions & 0 deletions scripts/build_wheel.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e # exit immediately if a command exits with a non-zero status.

###############################################################################
# This script builds a wheel for the current platform and Python version.
###############################################################################
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def is_pure(self):
package_dir={"": "python"},
include_package_data=True,
install_requires=[
"onnx",
"numpy",
"psutil",
"tqdm",
Expand Down

0 comments on commit bfef9df

Please sign in to comment.