Skip to content

Commit

Permalink
improve antlr import error message (apache#4888)
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi authored and zhiics committed Mar 2, 2020
1 parent 64ef2e6 commit 91ad6ca
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions python/tvm/relay/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ def __new__(cls, *args, **kwds):
from . import op

PYTHON_VERSION = sys.version_info.major
try:
from .grammar.py3.RelayVisitor import RelayVisitor
from .grammar.py3.RelayParser import RelayParser
from .grammar.py3.RelayLexer import RelayLexer
except ImportError:
raise Exception("Couldn't find ANTLR parser. Try building with USE_ANTLR=ON.")

try:
from antlr4 import InputStream, CommonTokenStream
from antlr4.error.ErrorListener import ErrorListener
Expand All @@ -62,6 +55,14 @@ def __new__(cls, *args, **kwds):
"Try running `pip{version} install antlr4-python{version}-runtime`."
.format(version=PYTHON_VERSION))

try:
from .grammar.py3.RelayVisitor import RelayVisitor
from .grammar.py3.RelayParser import RelayParser
from .grammar.py3.RelayLexer import RelayLexer
except ImportError:
raise Exception("Couldn't find ANTLR parser. Try building with USE_ANTLR=ON.")


sys.setrecursionlimit(10000)

class ParseError(Exception):
Expand Down

0 comments on commit 91ad6ca

Please sign in to comment.