|
| 1 | +name: '_ascend_npu_build' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + runner: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + description: 'The runner selected to run on' |
| 10 | + image: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + description: 'The docker image which will be used to build' |
| 14 | + outputs: |
| 15 | + artifact_name: |
| 16 | + description: 'The result of the called workflow' |
| 17 | + value: ${{ steps.list-dist.outputs.dist_name }} |
| 18 | + |
| 19 | +# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly |
| 20 | +# declared as "shell: bash -el {0}" on steps that need to be properly activated. |
| 21 | +# It's used to activate ascend-toolkit environment variables. |
| 22 | +defaults: |
| 23 | + run: |
| 24 | + shell: bash -el {0} |
| 25 | + |
| 26 | +jobs: |
| 27 | + build: |
| 28 | + name: build torch_npu |
| 29 | + runs-on: ${{ inputs.runner }} |
| 30 | + container: |
| 31 | + image: ${{ inputs.image }} |
| 32 | + volumes: |
| 33 | + - /home/runner/actions-runner/codes:/root/codes |
| 34 | + steps: |
| 35 | + - name: Prepare the codes |
| 36 | + run: | |
| 37 | + cp -rf /root/codes /root/build |
| 38 | +
|
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + uses: ./.github/actions/dependencies-action |
| 44 | + with: |
| 45 | + pip_packages: | |
| 46 | + - wheel |
| 47 | + pip_requirements: | |
| 48 | + - /root/build/npu/pytorch/requirements.txt |
| 49 | +
|
| 50 | + - name: List Python version |
| 51 | + id: list-py-version |
| 52 | + run: | |
| 53 | + py_version=$(python --version | awk '{print $2}' | cut -d '.' -f 1,2) |
| 54 | + echo "py_version=${py_version}" >> $GITHUB_OUTPUT |
| 55 | +
|
| 56 | + - name: Build torch_npu |
| 57 | + working-directory: /root/build/npu/pytorch |
| 58 | + run: | |
| 59 | + bash ci/build.sh --python=${{ steps.list-py-version.outputs.py_version }} |
| 60 | +
|
| 61 | + - name: List distribution package |
| 62 | + id: list-dist |
| 63 | + working-directory: /root/build/npu/pytorch/dist |
| 64 | + run: | |
| 65 | + dist_name=$(ls torch_npu*.whl) |
| 66 | + dist_path=$(pwd)/${dist_name} |
| 67 | + echo "dist_name=${dist_name}" >> $GITHUB_OUTPUT |
| 68 | + echo "dist_path=${dist_path}" >> $GITHUB_OUTPUT |
| 69 | +
|
| 70 | + - name: Upload distribution artifact |
| 71 | + id: upload-dist |
| 72 | + continue-on-error: true |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: ${{ steps.list-dist.outputs.dist_name }} |
| 76 | + path: ${{ steps.list-dist.outputs.dist_path }} |
| 77 | + retention-days: 1 |
| 78 | + |
| 79 | + - name: Write to workflow job summary |
| 80 | + if: ${{ steps.upload-dist.outputs.artifact-url }} |
| 81 | + run: | |
| 82 | + echo "## torch_npu built successfully! :rocket:" >> $GITHUB_STEP_SUMMARY |
| 83 | + echo "You can download the distribution package [here](${{ steps.upload-dist.outputs.artifact-url }})." >> $GITHUB_STEP_SUMMARY |
0 commit comments