Submit a Pull Request

Guidelines

  • We recommend authors send well scoped PRs that are easy to review and revert in case there is a problem. As such, authors should avoid merging multiple unrelated changes into a single PR

  • Before you submit a PR, please rebase your code on the most recent version of main, you can do it by running

    git remote add upstream [url to tvm repo]
    git fetch upstream
    git rebase upstream/main
    
  • Make sure code passes lint checks

    # While the lint commands used should be identical to those run in CI, this command reproduces
    # the CI lint procedure exactly (typically helpful for debugging lint script errors or
    # to avoid installing tools manually)
    python tests/scripts/ci.py lint
    
    # Run all lint steps.
    docker/lint.sh
    
    # To run steps individually, specify their step names on the command-line. An incorrectly
    # spelled step name causes the tool to print all available steps.
    docker/lint.sh <step_name> ...
    

    If the clang-format lint check fails, run git-clang-format as follows to automatically reformat your code:

    # Run clang-format check for all the files that changed since upstream/main
    docker/bash.sh ci_lint ./tests/lint/git-clang-format.sh upstream/main
    
  • Add test-cases to cover the new features or bugfix the patch introduces.

  • Document the code you wrote, see more at Documentation

  • Create a pull request and fix the problems reported by CI checks.

  • Request code reviews from other contributors and improve your patch according to their reviews by @-ing them in your pull request. Tags in PR titles will automatically tag subscribed users, so make sure to put relevant topics in your PR titles (e.g. [microTVM] a cool change and not a cool change for microTVM).

    • To get your code reviewed quickly, we encourage you to help review others’ code so they can do the favor in return.

    • Code review is a shepherding process that helps to improve contributor’s code quality. We should treat it proactively, to improve the code as much as possible before the review. We highly value patches that can get in without extensive reviews.

    • The detailed guidelines and summarizes useful lessons.

  • The PR can be merged after the reviewers approve the pull request.

CI Environment

We use Docker images to create stable CI environments that can be deployed to multiple machines. Follow the steps in this issue template to update a CI Docker image.

Testing

Even though we have hooks to run unit tests automatically for each pull request, it’s always recommended to run unit tests locally beforehand to reduce reviewers’ burden and speedup review process.

C++ (local)

Running the C++ tests requires installation of gtest, following the instructions in Enable C++ Tests

# assume you are in tvm source root
TVM_ROOT=`pwd`

./tests/scripts/task_cpp_unittest.sh

Python (local)

Necessary dependencies:

pip install --user pytest Cython synr

If you want to run all tests:

# build tvm
make

./tests/scripts/task_python_unittest.sh

If you want to run a single test:

# build tvm
make

# let python know where to find tvm related libraries
export PYTHONPATH=python
rm -rf python/tvm/*.pyc python/tvm/*/*.pyc python/tvm/*/*/*.pyc

TVM_FFI=ctypes python -m pytest -v tests/python/unittest/test_pass_storage_rewrite.py

# Additionally if you want to run a single test, for example test_all_elemwise inside a file.
TVM_FFI=ctypes python -m pytest -v -k "test_all_elemwise" tests/python/frontend/tflite/test_forward.py