Trouble enabling ANTLR

I’m trying to enable ANTLR so I can use the tvm.relay.fromtext() function.

I followed the steps to install from source. I am running in an Ubuntu 16.04 Docker container. My Python version is 3.6.

I also ran the scripts to install the ANTLR dependencies that I found here, set USE_ANTLR to ON in build/config.cmake, and rebuilt with cd build && cmake .. && make -j4. However, when I try to run relay.fromtext(), I am still getting the following error:

  ...
  File "/workspace/python/tvm/relay/_parser.py", line 55, in <module>
    raise ParseError("Couldn't find ANTLR parser. Try building with USE_ANTLR=ON.")
ModuleNotFoundError: No module named 'antlr4'
During handling of the above exception, another exception occurred:

tvm.relay._parser.ParseError

How can I enable ANTLR?

Edit: I have also tried running in the tvmai/ci-cpu Docker container (image ID b845517dd3f9). The same function call gives me this error in the container.

  ...
  File "/workspace/python/tvm/relay/_parser.py", line 86, in <module>
    Scope = Deque[Tuple[str, T]]
NameError: name 'Deque' is not defined
1 Like

Thanks for trying out the parser!

This line lists all the python packages you need for TVM.

For the first error: It looks like you haven’t installed the antlr4 python? You can find it here or else use the link above.

For the second: It looks like mypy isn’t installed You can get it here or use the link above.

1 Like

This PR should hopefully help others in the future with installing the parser.

Awesome, thanks! Both fixes worked.