Getting code coverage info in PyTorch
- Build pytorch from source with the necessary flags for coverage -
-DUSE_CPP_CODE_COVERAGE=ON -DBUILD_TEST=ON -DCMAKE_BUILD_TYPE=Debug
:- If using GCC:
python setup.py build --cmake-only
cd build && \
cmake .. -DUSE_CPP_CODE_COVERAGE=ON -DBUILD_TEST=ON -DCMAKE_BUILD_TYPE=Debug && \
cd ../
MAX_JOBS=8 python setup.py develop - If using clang:
sudo apt install clang-12 libomp-12-dev --install-suggests
sudo ln -s /usr/bin/clang++-12 /usr/bin/clang++
sudo ln -s /usr/bin/clang-12 /usr/bin/clang
CC=clang CXX=clang++ python setup.py build --cmake-only
cd build && \
cmake .. -DUSE_CPP_CODE_COVERAGE=ON -DBUILD_TEST=ON -DCMAKE_BUILD_TYPE=Debug && \
cd ../
MAX_JOBS=8 python setup.py develop
- If using GCC:
- Run
pytorch/tools/code_coverage/oss_coverage.py
:- If using GCC:
python oss_coverage.py --export --summary
- If using clang:
CXX=clang++ LLVM_TOOL_PATH=/usr/lib/llvm-12/bin/ python oss_coverage.py
/usr/lib/llvm-12/bin/llvm-cov show -output-dir=out/report -format=html -instr-profile=/home/syeahmed/workspace/pytorch/tools/code_coverage/package/util/../../profile/merged/test_jit.merged -object /home/syeahmed/workspace/pytorch/build/bin/test_jit - Use
--run-only
and--interest-only
options to create focused reports (README)
- If using GCC: