diff --git a/python/tvm/relay/_parser.py b/python/tvm/relay/_parser.py index 78ab8ff63ec3..49bdbb393c2e 100644 --- a/python/tvm/relay/_parser.py +++ b/python/tvm/relay/_parser.py @@ -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 @@ -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):