TVM is a compiler for machine learning frameworks that can optimize and target kernels to several different backends. Relay is a high level intermediate representation for the TVM framework. The goal of Relay is to replace old computation graph based IRs with a more expressive IR. More information can be found in this paper.
The TVM Relay frontend lives in the relay-lang folder in the Calyx repository and generates Calyx components from the Relay intermediate representation.
Clone the TVM repository with commit hash
git clone --recursive email@example.com:apache/incubator-tvm.git cd incubator-tvm && git reset --hard ccacb1ec1
Set up to build (the default configuration is fine because we don't need any fancy backends like LLVM or CUDA):
mkdir build && cd build cp ../cmake/config.cmake .
cmake -G Ninja .. && ninja
tvmPython package by building a wheel:
cd ../python && python3 setup.py bdist_wheel pip3 install --user dist/tvm-*.whl
Install the accompanying
cd ../topi/python && python3 setup.py bdist_wheel pip3 install --user dist/topi-*.whl
Install ANTLR v4.7.2 (required for the Relay text format parser):
pip3 install -Iv antlr4-python3-runtime==4.7.2
pip3 install pytest
Install Dahlia, which is used when lowering Relay call nodes to Calyx.
Install the calyx-py library.
Try this to run a simple example:
cd calyx/frontends/relay python3 example.py tensor_add
-h: Help option; shows available examples.
-r: Dumps the Relay IR. Otherwise, it dumps the Calyx output.