|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + tags: ["v*.*"] |
| 7 | + pull_request: |
| 8 | + types: [opened, reopened, synchronize, ready_for_review] |
| 9 | + paths: |
| 10 | + - "src/**" |
| 11 | + - "qa/**" |
| 12 | + - "patches/**" |
| 13 | + - "cmake/**" |
| 14 | + - "CMakeLists.txt" |
| 15 | + workflow_dispatch: |
| 16 | + inputs: |
| 17 | + build_type: |
| 18 | + description: "Cmake build type" |
| 19 | + required: true |
| 20 | + default: Release |
| 21 | + type: choice |
| 22 | + options: |
| 23 | + - Release |
| 24 | + - Debug |
| 25 | + - RelWithDebInfo |
| 26 | + - MinSizeRel |
| 27 | + triton_branch: |
| 28 | + description: "Triton container version to use in build and test" |
| 29 | + required: true |
| 30 | + default: main |
| 31 | + type: string |
| 32 | + enable_mali: |
| 33 | + description: "Enable Mali GPU in build" |
| 34 | + required: true |
| 35 | + default: OFF |
| 36 | + type: choice |
| 37 | + options: |
| 38 | + - OFF |
| 39 | + - ON |
| 40 | + enable_ruy: |
| 41 | + description: "Enable RUY in build" |
| 42 | + required: true |
| 43 | + default: ON |
| 44 | + type: choice |
| 45 | + options: |
| 46 | + - OFF |
| 47 | + - ON |
| 48 | + enable_bazel: |
| 49 | + description: "Enable Mali GPU in build" |
| 50 | + required: true |
| 51 | + default: OFF |
| 52 | + type: choice |
| 53 | + options: |
| 54 | + - OFF |
| 55 | + - ON |
| 56 | + enable_flex_ops: |
| 57 | + description: "Enable Flex Ops in build" |
| 58 | + required: true |
| 59 | + default: OFF |
| 60 | + type: choice |
| 61 | + options: |
| 62 | + - OFF |
| 63 | + - ON |
| 64 | + tflite_tag: |
| 65 | + description: "TFLite tag to build against" |
| 66 | + required: true |
| 67 | + default: v2.4.1 |
| 68 | + type: string |
| 69 | + armnn_tag: |
| 70 | + description: "ArmNN tag to build against" |
| 71 | + required: true |
| 72 | + default: v22.08 |
| 73 | + type: string |
| 74 | + enable_armnn_delegate: |
| 75 | + description: "Enable ArmNN Delegate in build" |
| 76 | + required: true |
| 77 | + default: OFF |
| 78 | + type: choice |
| 79 | + options: |
| 80 | + - OFF |
| 81 | + - ON |
| 82 | + |
| 83 | +env: |
| 84 | + BUILD_TYPE: ${{ inputs.build_type || 'Release' }} |
| 85 | + DEBIAN_FRONTEND: noninteractive |
| 86 | + CMAKE_VERSION: 3.21.1 |
| 87 | + TRITON_REPO_TAG: ${{ inputs.triton_branch || 'main' }} |
| 88 | + TRITON_ENABLE_MALI_GPU: ${{ inputs.enable_mali || 'OFF' }} |
| 89 | + TFLITE_ENABLE_RUY: ${{ inputs.enable_ruy || 'ON' }} |
| 90 | + TFLITE_BAZEL_BUILD: ${{ inputs.enable_bazel || 'OFF' }} |
| 91 | + TFLITE_ENABLE_FLEX_OPS: ${{ inputs.enable_flex_ops || 'OFF' }} |
| 92 | + TFLITE_TAG: ${{ inputs.tflite_tag || 'v2.4.1' }} |
| 93 | + ARMNN_TAG: ${{ inputs.armnn_tag || 'v22.08' }} |
| 94 | + ARMNN_DELEGATE_ENABLE: ${{ inputs.enable_armnn_delegate || 'ON' }} |
| 95 | + |
| 96 | +jobs: |
| 97 | + build: |
| 98 | + strategy: |
| 99 | + fail-fast: false |
| 100 | + matrix: |
| 101 | + include: |
| 102 | + - platform: [self-hosted, x86_64] |
| 103 | + arch: amd64 |
| 104 | + - platform: [self-hosted, ARM64] |
| 105 | + arch: arm64 |
| 106 | + runs-on: ${{ matrix.platform }} |
| 107 | + outputs: |
| 108 | + triton_image: ${{ steps.set_image.outputs.triton_image }} |
| 109 | + container: ubuntu:20.04 |
| 110 | + |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v3 |
| 113 | + with: |
| 114 | + fetch-depth: 0 |
| 115 | + |
| 116 | + # Set the image to be used during the test job |
| 117 | + - id: set_image |
| 118 | + run: echo "triton_image=ghcr.io/smarter-project/armnn_tflite_backend/triton:${{env.TRITON_REPO_TAG}}" >> $GITHUB_OUTPUT |
| 119 | + |
| 120 | + - name: Install build tools |
| 121 | + run: | |
| 122 | + apt update |
| 123 | + apt install -yqq --no-install-recommends \ |
| 124 | + build-essential \ |
| 125 | + git \ |
| 126 | + wget \ |
| 127 | + scons \ |
| 128 | + ca-certificates \ |
| 129 | + curl \ |
| 130 | + autoconf \ |
| 131 | + libtool \ |
| 132 | + python3-dev \ |
| 133 | + python3-pip \ |
| 134 | + python3-numpy \ |
| 135 | + libssl-dev \ |
| 136 | + zlib1g-dev \ |
| 137 | + zip \ |
| 138 | + unzip \ |
| 139 | + xxd \ |
| 140 | + rapidjson-dev \ |
| 141 | + ccache \ |
| 142 | + software-properties-common \ |
| 143 | + cppcheck |
| 144 | +
|
| 145 | + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \ |
| 146 | + gpg --dearmor - | \ |
| 147 | + tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null |
| 148 | + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' |
| 149 | + apt-get update |
| 150 | + apt-get install -y --no-install-recommends \ |
| 151 | + cmake-data=${CMAKE_VERSION}-0kitware1ubuntu20.04.1 cmake=${CMAKE_VERSION}-0kitware1ubuntu20.04.1 |
| 152 | + pip3 install -U pip wheel |
| 153 | +
|
| 154 | + - name: Install Bazel |
| 155 | + if: ${{ env.TFLITE_BAZEL_BUILD == 'ON' }} |
| 156 | + run: | |
| 157 | + wget -O bazel-3.1.0-dist.zip https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-dist.zip |
| 158 | + unzip -d bazel bazel-3.1.0-dist.zip |
| 159 | + cd bazel |
| 160 | + ln -s /usr/bin/python3 /usr/bin/python |
| 161 | + env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh |
| 162 | + cp output/bazel /usr/bin/bazel |
| 163 | +
|
| 164 | + - name: ccache |
| 165 | + uses: hendrikmuhs/[email protected] |
| 166 | + |
| 167 | + - name: Configure CMake |
| 168 | + run: | |
| 169 | + cmake -B build \ |
| 170 | + -DCMAKE_INSTALL_PREFIX=$(pwd)/install \ |
| 171 | + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ |
| 172 | + -DTRITON_ENABLE_GPU=OFF \ |
| 173 | + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 174 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ |
| 175 | + -DTRITON_BACKEND_REPO_TAG=${{env.TRITON_REPO_TAG}} \ |
| 176 | + -DTRITON_CORE_REPO_TAG=${{env.TRITON_REPO_TAG}} \ |
| 177 | + -DTRITON_COMMON_REPO_TAG=${{env.TRITON_REPO_TAG}} \ |
| 178 | + -DTRITON_ENABLE_GPU=OFF \ |
| 179 | + -DTRITON_ENABLE_MALI_GPU=${{env.TRITON_ENABLE_MALI_GPU}} \ |
| 180 | + -DTFLITE_ENABLE_RUY=${{env.TFLITE_ENABLE_RUY}} \ |
| 181 | + -DTFLITE_BAZEL_BUILD=${{env.TFLITE_BAZEL_BUILD}} \ |
| 182 | + -DTFLITE_ENABLE_FLEX_OPS=${{env.TFLITE_ENABLE_FLEX_OPS}} \ |
| 183 | + -DTFLITE_TAG=${{env.TFLITE_TAG}} \ |
| 184 | + -DARMNN_TAG=${{env.ARMNN_TAG}} \ |
| 185 | + -DARMNN_DELEGATE_ENABLE=${{env.ARMNN_DELEGATE_ENABLE}} \ |
| 186 | + -DACL_TAG=${{env.ARMNN_TAG}} \ |
| 187 | + -DJOBS=$(nproc) |
| 188 | +
|
| 189 | + - name: Cmake build |
| 190 | + run: cmake --build build -j $(nproc) -t install |
| 191 | + |
| 192 | + - name: ccache statistics |
| 193 | + run: | |
| 194 | + ccache -s |
| 195 | +
|
| 196 | + - name: Upload Backend Artifact |
| 197 | + uses: actions/upload-artifact@v3 |
| 198 | + with: |
| 199 | + path: install/backends/armnn_tflite |
| 200 | + name: armnn_tflite_backend_${{ matrix.arch }} |
| 201 | + if-no-files-found: error |
| 202 | + |
| 203 | + test: |
| 204 | + strategy: |
| 205 | + matrix: |
| 206 | + include: |
| 207 | + - platform: [self-hosted, x86_64] |
| 208 | + arch: amd64 |
| 209 | + - platform: [self-hosted, ARM64] |
| 210 | + arch: arm64 |
| 211 | + runs-on: ${{ matrix.platform }} |
| 212 | + |
| 213 | + # Make sure we have run the build step first |
| 214 | + needs: [build] |
| 215 | + |
| 216 | + # We will install testing tools and run tests from within the context of the tritonserver image |
| 217 | + container: |
| 218 | + image: ${{ needs.build.outputs.triton_image }}_${{ matrix.arch }} |
| 219 | + credentials: |
| 220 | + username: ${{ github.actor }} |
| 221 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 222 | + |
| 223 | + steps: |
| 224 | + - uses: actions/checkout@v3 |
| 225 | + |
| 226 | + # Fetch the built backend from the artifact |
| 227 | + - name: Download armnn_tflite_backend |
| 228 | + uses: actions/download-artifact@v3 |
| 229 | + with: |
| 230 | + name: armnn_tflite_backend_${{ matrix.arch }} |
| 231 | + path: armnn_tflite |
| 232 | + |
| 233 | + - name: Display structure of downloaded files |
| 234 | + run: ls -R armnn_tflite |
| 235 | + |
| 236 | + - name: Make armnn triton backend available |
| 237 | + run: cp -r armnn_tflite /opt/tritonserver/backends/armnn_tflite |
| 238 | + |
| 239 | + - name: Install test dependencies |
| 240 | + run: | |
| 241 | + apt update |
| 242 | + apt install -yqq --no-install-recommends libssl-dev zlib1g-dev rapidjson-dev python3-dev python3-pip wget build-essential git |
| 243 | + python3 -m pip install --upgrade pip setuptools wheel |
| 244 | + python3 -m pip install --upgrade grpcio-tools |
| 245 | + python3 -m pip install --upgrade numpy pillow attrdict future grpcio requests gsutil awscli six grpcio-channelz |
| 246 | + python3 -m pip install --upgrade tritonclient[all] |
| 247 | + python3 -m pip install --upgrade pytest pytest-xdist pytest-xprocess jinja2 |
| 248 | +
|
| 249 | + - name: Run Tests |
| 250 | + run: | |
| 251 | + cd qa |
| 252 | + wget -q https://images.getsmarter.io/ml-models/armnn_tflite_backend_triton_model_repo.tar.gz |
| 253 | + tar -xzf armnn_tflite_backend_triton_model_repo.tar.gz |
| 254 | + python3 -m pytest -v tests/ --model-repo-path $(pwd)/triton_qa_models/accuracy_test_model_repo --triton-path /opt/tritonserver/bin/tritonserver --backend-directory /opt/tritonserver/backends |
0 commit comments