|
| 1 | +name: Reusable build, test and release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + python3-minor-version: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + runner: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + distro: |
| 13 | + default: centos7 |
| 14 | + type: string |
| 15 | + compat-tests: |
| 16 | + default: false |
| 17 | + type: boolean |
| 18 | + release: |
| 19 | + default: false |
| 20 | + type: boolean |
| 21 | + secrets: |
| 22 | + token: |
| 23 | + required: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + build-test: |
| 27 | + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main |
| 28 | + with: |
| 29 | + runner: ${{ inputs.runner }} |
| 30 | + upload-artifact: multipy_runtime_python3.${{ inputs.python3-minor-version }} |
| 31 | + repository: pytorch/multipy |
| 32 | + gpu-arch-type: cuda |
| 33 | + gpu-arch-version: 116 |
| 34 | + script: | |
| 35 | + python_version=3.${{ inputs.python3-minor-version }} |
| 36 | +
|
| 37 | + echo "::group::Install runtime build dependencies" |
| 38 | + xargs yum install -y <build-requirements-${{ inputs.distro }}.txt |
| 39 | + echo "::endgroup::" |
| 40 | +
|
| 41 | + echo "::group::Sync git submodules" |
| 42 | + git submodule update --init --recursive --jobs 0 |
| 43 | + echo "::endgroup::" |
| 44 | +
|
| 45 | + echo "::group::Setup virtual environment" |
| 46 | + if [[ ${{ inputs.python3-minor-version }} -gt 7 ]]; |
| 47 | + then |
| 48 | + conda install -y python=${python_version} mkl mkl-include conda-build pyyaml numpy ipython |
| 49 | + conda install -y -c conda-forge libpython-static=${python_version} |
| 50 | + conda install -y pytorch torchvision torchaudio cpuonly -c pytorch |
| 51 | + conda clean -ya; |
| 52 | + else |
| 53 | + conda deactivate |
| 54 | + pip install virtualenv |
| 55 | + git clone https://github.com/pyenv/pyenv.git ~/.pyenv |
| 56 | + export CFLAGS="-fPIC -g" |
| 57 | + ~/.pyenv/bin/pyenv install --force ${python_version} |
| 58 | + virtualenv -p ~/.pyenv/versions/$(~/.pyenv/bin/pyenv latest ${python_version})/bin/python3 ~/venvs/multipy |
| 59 | + source ~/venvs/multipy/bin/activate |
| 60 | + pip install \ |
| 61 | + torch torchvision torchaudio \ |
| 62 | + --extra-index-url https://download.pytorch.org/whl/cpu; |
| 63 | + fi |
| 64 | + echo "::endgroup::" |
| 65 | +
|
| 66 | + echo "::group::Install" |
| 67 | + python -m pip install -e . --install-option="--cudatests" |
| 68 | + echo "::endgroup::" |
| 69 | +
|
| 70 | + echo "::group::Generate examples" |
| 71 | + python multipy/runtime/example/generate_examples.py |
| 72 | + cd examples |
| 73 | + cmake -S . -B build/ -DMULTIPY_PATH=".." && cmake --build build/ --config Release -j |
| 74 | + cd - |
| 75 | + echo "::endgroup::" |
| 76 | +
|
| 77 | + export PYTHONPATH=$(pwd) |
| 78 | + export LIBTEST_DEPLOY_LIB=$(pwd)/multipy/runtime/build/libtest_deploy_lib.so |
| 79 | + export LD_LIBRARY_PATH=/opt/conda/lib/:$LD_LIBRARY_PATH |
| 80 | +
|
| 81 | + echo "::group::Test C++" |
| 82 | + multipy/runtime/build/test_deploy |
| 83 | + echo "::endgroup::" |
| 84 | +
|
| 85 | + echo "::group::Test Pybind" |
| 86 | + python multipy/runtime/test_pybind.py |
| 87 | + echo "::endgroup::" |
| 88 | +
|
| 89 | + echo "::group::Run examples" |
| 90 | + examples/build/hello_world_example |
| 91 | + python3 examples/quickstart/gen_package.py |
| 92 | + ./examples/build/quickstart my_package.pt |
| 93 | + ./examples/build/movable_example |
| 94 | + echo "::endgroup::" |
| 95 | +
|
| 96 | + echo "::group::Benchmark" |
| 97 | + ./multipy/runtime/build/deploy_benchmark 2 none jit multipy/runtime/example/generated/resnet |
| 98 | + echo "::endgroup::" |
| 99 | +
|
| 100 | + if [[ ${{ inputs.python3-minor-version }} -gt 7 ]]; |
| 101 | + then |
| 102 | + echo "::group::Compat test" |
| 103 | + pip install -r compat-requirements.txt |
| 104 | + multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py |
| 105 | + echo "::endgroup::"; |
| 106 | + fi |
| 107 | +
|
| 108 | + echo "::group::Test GPU" |
| 109 | + # Separating GPU tests due to issues with py37 and py38: https://github.com/pytorch/multipy/issues/239 |
| 110 | + pip install --upgrade --force-reinstall torch \ |
| 111 | + --extra-index-url https://download.pytorch.org/whl/cu116 |
| 112 | + multipy/runtime/build/test_deploy_gpu |
| 113 | + echo "::endgroup::" |
| 114 | +
|
| 115 | + echo "::group::Create tarball" |
| 116 | + cp -r multipy/runtime/build/dist/* . |
| 117 | + rm -rf multipy/runtime/build |
| 118 | + tar -czf multipy_runtime_python${python_version}.tar.gz multipy/ |
| 119 | + echo "::endgroup::" |
| 120 | +
|
| 121 | + echo "::group::Move artifact for upload" |
| 122 | + mv multipy_runtime_python${python_version}.tar.gz ${RUNNER_ARTIFACT_DIR}/ |
| 123 | + echo "::endgroup::" |
| 124 | +
|
| 125 | + release: |
| 126 | + needs: [build-test] |
| 127 | + runs-on: ubuntu-latest |
| 128 | + if: ${{ inputs.release }} |
| 129 | + steps: |
| 130 | + - name: Download artifact |
| 131 | + uses: actions/download-artifact@v3 |
| 132 | + with: |
| 133 | + name: multipy_runtime_python3.${{ inputs.python3-minor-version }} |
| 134 | + path: ./ |
| 135 | + |
| 136 | + - name: Update nightly release |
| 137 | + uses: pyTooling/Actions/releaser@main |
| 138 | + with: |
| 139 | + tag: multipy_runtime_python3.${{ inputs.python3-minor-version }} |
| 140 | + rm: true |
| 141 | + token: ${{ secrets.token }} |
| 142 | + files: multipy_runtime_python3.${{ inputs.python3-minor-version }}.tar.gz |
0 commit comments