diff --git a/.github/workflows/build-and-push-docker-image.yml b/.github/workflows/build-and-push-docker-image.yml new file mode 100644 index 0000000..2ad455d --- /dev/null +++ b/.github/workflows/build-and-push-docker-image.yml @@ -0,0 +1,69 @@ +# The workflow copied from [docker docs](https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images#publishing-images-to-github-packages) +# with some changes. Notably the trigger is changed to `workflow_dispatch` and there is a suffix `-test` added to the generated tag in the metadata step. +name: Create and publish a Docker image + +# Configures this workflow to run only on manual dispatch +on: workflow_dispatch + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + labels: | + org.opencontainers.image.vendor=pulp-platform + org.opencontainers.image.description=Image for testing the pulp-nnx library + tags: | + type=ref,suffix=-test,event=tag + type=ref,suffix=-test,event=branch + + - run: echo "Docker tags ${{ steps.meta.outputs.tags }}" + - run: echo "Docker labels ${{ steps.meta.outputs.labels }}" + + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: ./test + file: ./test/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/.github/workflows/test-neureka.yml b/.github/workflows/test-neureka.yml new file mode 100644 index 0000000..a65eade --- /dev/null +++ b/.github/workflows/test-neureka.yml @@ -0,0 +1,15 @@ +name: Test Neureka +on: push +jobs: + test: + runs-on: ubuntu-latest + container: ghcr.io/pulp-platform/pulp-nnx:main-test + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run test + shell: bash + working-directory: test + run: | + source /pulp-sdk/configs/siracusa.sh + pytest test.py -T tests -R -A neureka diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c7b267..e0e3ce0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,12 +49,3 @@ run_ne16_test: untracked: true script: - cd test && pytest test.py --test-dir tests --recursive -A ne16 - -run_neureka_test: - stage: test - tags: - - siracusa-sdk - artifacts: - untracked: true - script: - - cd test && pytest test.py --test-dir tests --recursive -A neureka diff --git a/CHANGELOG.md b/CHANGELOG.md index f655e53..c30608e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added +- github action for testing neureka - add NnxMapping dictionary that maps accelerator name to the accelerator specific classes - choice of data generation method (ones, incremented, or random) - N-EUREKA accelerator support: 3x3, 1x1, and 3x3 depthwise convolution kernels @@ -17,6 +18,7 @@ ### Changed +- python requirements are changed into requirements-pip and requirements-conda - conftest now passes only strings to test.py to improve readability of pytest logs - NnxMemoryLayout is now NnxWeight and also has a method for source generation - the `wmem` field in the test configurations is now required diff --git a/test/Dockerfile b/test/Dockerfile new file mode 100644 index 0000000..06c99e8 --- /dev/null +++ b/test/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:22.04 + +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update && \ + apt-get upgrade && \ + apt-get install -y --no-install-recommends \ + bzip2 \ + ca-certificates \ + cmake \ + curl \ + gcc \ + git \ + git-lfs \ + g++ \ + make \ + python3 \ + python3-pip \ + python-is-python3 \ + zlib1g-dev \ + && apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY requirements-pip.txt docker/requirements-pulp-sdk.txt ./ +RUN pip3 install --no-cache-dir -r requirements-pip.txt -r requirements-pulp-sdk.txt --extra-index-url https://download.pytorch.org/whl/cpu + +ENV PULP_SDK_HOME="/pulp-sdk" +ENV PULP_RISCV_GCC_TOOLCHAIN="/toolchains/pulp-riscv-gnu-toolchain" + +COPY docker/get_pulp_riscv_gnu_toolchain.sh ./ +RUN ./get_pulp_riscv_gnu_toolchain.sh + +COPY docker/get_pulp_sdk.sh ./ +RUN ./get_pulp_sdk.sh diff --git a/test/docker/get_pulp_riscv_gnu_toolchain.sh b/test/docker/get_pulp_riscv_gnu_toolchain.sh new file mode 100755 index 0000000..ab6208a --- /dev/null +++ b/test/docker/get_pulp_riscv_gnu_toolchain.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail + +curl -L https://github.com/pulp-platform/pulp-riscv-gnu-toolchain/releases/download/v1.0.16/v1.0.16-pulp-riscv-gcc-ubuntu-18.tar.bz2 > pulp-riscv-gnu-toolchain.tar.bz2 +mkdir toolchains +tar -xvjf ./pulp-riscv-gnu-toolchain.tar.bz2 -C ./toolchains +mv ./toolchains/v1.0.16-pulp-riscv-gcc-ubuntu-18 ./toolchains/pulp-riscv-gnu-toolchain +rm ./pulp-riscv-gnu-toolchain.tar.bz2 diff --git a/test/docker/get_pulp_sdk.sh b/test/docker/get_pulp_sdk.sh new file mode 100755 index 0000000..665e184 --- /dev/null +++ b/test/docker/get_pulp_sdk.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -eo pipefail + +git clone https://github.com/Scheremo/pulp-sdk.git --branch scheremo --depth=1 && rm -rf pulp-sdk/.git + +cd pulp-sdk + +source configs/siracusa.sh +make all diff --git a/test/docker/requirements-pulp-sdk.txt b/test/docker/requirements-pulp-sdk.txt new file mode 100644 index 0000000..c7719e6 --- /dev/null +++ b/test/docker/requirements-pulp-sdk.txt @@ -0,0 +1,4 @@ +argcomplete +pyelftools +scons +six diff --git a/test/requirements.txt b/test/requirements-conda.txt similarity index 72% rename from test/requirements.txt rename to test/requirements-conda.txt index eee0644..2770601 100644 --- a/test/requirements.txt +++ b/test/requirements-conda.txt @@ -1,4 +1,4 @@ -numpy +numpy==1.26.4 pydantic pytest pytorch==1.11.0 diff --git a/test/requirements-pip.txt b/test/requirements-pip.txt new file mode 100644 index 0000000..76adfa4 --- /dev/null +++ b/test/requirements-pip.txt @@ -0,0 +1,6 @@ +numpy==1.26.4 +pydantic +pytest +torch==1.11.0 +toml +ninja