1# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com> 2# 3# SPDX-License-Identifier: Apache-2.0 4# 5# Licensed under the Apache License, Version 2.0 (the License); you may 6# not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an AS IS BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17name: TFL Microspeech Example on Arm Virtual Hardware 18on: 19 push: 20 branches: 21 - microspeech 22 workflow_run: 23 workflows: ["Build documentation and pack"] 24 types: 25 - completed 26 workflow_dispatch: 27 28env: 29 AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} 30 AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} 31 AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} 32 AWS_IAM_PROFILE: ${{ secrets.AWS_IAM_PROFILE }} 33 AWS_SECURITY_GROUP_ID: ${{ secrets.AWS_SECURITY_GROUP_ID }} 34 AWS_SUBNET_ID: ${{ secrets.AWS_SUBNET_ID }} 35 36jobs: 37 set_pending_status_to_pr: 38 runs-on: ubuntu-latest 39 steps: 40 - name: Set a pending status to the PR 41 if: github.event.workflow_run 42 env: 43 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 44 run: | 45 curl --request POST \ 46 --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \ 47 --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ 48 --header 'content-type: application/json' \ 49 --data '{ 50 "state": "pending", 51 "context": "Microspeech", 52 "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" 53 }' \ 54 --fail 55 56 build_and_run: 57 name: Build and run projects on AVH 58 runs-on: ubuntu-latest 59 needs: set_pending_status_to_pr 60 permissions: 61 id-token: write 62 contents: read 63 issues: read 64 checks: write 65 pull-requests: write 66 67 steps: 68 - uses: actions/checkout@v4 69 with: 70 repository: ARM-software/AVH-TFLmicrospeech 71 ref: main 72 73 - name: Set up Python 3.10 74 uses: actions/setup-python@v5 75 with: 76 python-version: '3.10' 77 78 - name: Install AVH Client for Python 79 run: | 80 pip install arm-avhclient 81 82 - name: Download pack from upstream workflow 83 if: github.event.workflow_run 84 env: 85 GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 86 run: | 87 mkdir -p artifacts && cd artifacts 88 89 artifacts_url=${{ github.event.workflow_run.artifacts_url }} 90 91 gh api "$artifacts_url" -q '.artifacts[] | select(.name=="artifact") | [.name, .archive_download_url] | @tsv' | \ 92 while read artifact; do 93 IFS=$'\t' read name url <<< "$artifact" 94 gh api $url > "$name.zip" 95 unzip -d "$name" "$name.zip" 96 done 97 98 cp artifact/ARM.CMSIS-NN.*.pack ../Platform_FVP_Corstone_SSE-300_Ethos-U55/ 99 100 - name: Download latest release pack 101 if: ${{ ! github.event.workflow_run }} 102 env: 103 GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 104 run: | 105 gh -R ${{ github.repository }} release download -p "*.pack" -D Platform_FVP_Corstone_SSE-300_Ethos-U55 106 107 - name: Configure AWS Credentials 108 uses: aws-actions/configure-aws-credentials@v4.0.2 109 with: 110 role-to-assume: ${{ env.AWS_ASSUME_ROLE }} 111 aws-region: ${{ env.AWS_DEFAULT_REGION }} 112 113 - name: Apply patch 114 run: | 115 VERSION=$(\ 116 basename $(ls Platform_FVP_Corstone_SSE-300_Ethos-U55/ARM.CMSIS-NN.*.pack) | \ 117 cut -d. -f 3-5 | cut -d+ -f 1 \ 118 ) 119 patch -p0 <<EOF 120 --- Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Example.Reference.cprj 121 +++ Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Example.Reference.cprj 122 @@ -11,2 +11,3 @@ 123 <packages> 124 + <package name="CMSIS-NN" vendor="ARM" version="${VERSION}:${VERSION}"/> 125 <package name="CMSIS" vendor="ARM" version="5.9.0:5.9.0"/> 126 @@ -130,3 +131,2 @@ 127 <file category="sourceCpp" name="../micro_speech/src/recognize_commands.cc"/> 128 - <file category="sourceC" name="../micro_speech/src/arm_nn_softmax_common_s8.c"/> 129 </group> 130 --- Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Example.SIMD.cprj 131 +++ Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Example.SIMD.cprj 132 @@ -11,2 +11,3 @@ 133 <packages> 134 + <package name="CMSIS-NN" vendor="ARM" version="${VERSION}:${VERSION}"/> 135 <package name="CMSIS" vendor="ARM" version="5.9.0:5.9.0"/> 136 @@ -130,3 +131,2 @@ 137 <file category="sourceCpp" name="../micro_speech/src/recognize_commands.cc"/> 138 - <file category="sourceC" name="../micro_speech/src/arm_nn_softmax_common_s8.c"/> 139 </group> 140 --- Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Example.Helium.cprj 141 +++ Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Example.Helium.cprj 142 @@ -11,2 +11,3 @@ 143 <packages> 144 + <package name="CMSIS-NN" vendor="ARM" version="${VERSION}:${VERSION}"/> 145 <package name="CMSIS" vendor="ARM" version="5.9.0:5.9.0"/> 146 @@ -130,3 +131,2 @@ 147 <file category="sourceCpp" name="../micro_speech/src/recognize_commands.cc"/> 148 - <file category="sourceC" name="../micro_speech/src/arm_nn_softmax_common_s8.c"/> 149 </group> 150 --- avh.yml Tue Nov 22 12:01:56 2022 151 +++ avh.yml Tue Nov 22 12:02:08 2022 152 @@ -12,2 +12,5 @@ 153 steps: 154 + - run: | 155 + cd Platform_FVP_Corstone_SSE-300_Ethos-U55 156 + cpackget add ARM.CMSIS-NN.*.pack 157 - run: | 158 EOF 159 160 - name: Execute test suite on Arm Virtual Hardware at AWS 161 run: | 162 avhclient -b aws execute --specfile ./avh.yml 163 164 - name: Fetch results from Arm Virtual Hardware 165 run: | 166 cat ./Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Reference.log 167 cat ./Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.SIMD.log 168 cat ./Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Helium.log 169 170 - name: Decode EventRecorder logs 171 run: | 172 wget https://github.com/ARM-software/CMSIS-View/releases/download/tools%2Feventlist%2F1.0.10/eventlist-linux64.tar.gz 173 tar -xvf eventlist-linux64.tar.gz 174 chmod +x eventlist-linux64/eventlist 175 eventlist-linux64/eventlist -s ./Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Reference.EventRecorder.log 176 eventlist-linux64/eventlist -s ./Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.SIMD.EventRecorder.log 177 eventlist-linux64/eventlist -s ./Platform_FVP_Corstone_SSE-300_Ethos-U55/microspeech.Helium.EventRecorder.log 178 179 set_success_status_to_pr: 180 runs-on: ubuntu-latest 181 needs: build_and_run 182 if: github.event.workflow_run && success() 183 steps: 184 - name: Set success status to the PR 185 env: 186 GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 187 run: | 188 curl --request POST \ 189 --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \ 190 --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ 191 --header 'content-type: application/json' \ 192 --data '{ 193 "state": "success", 194 "context": "Microspeech", 195 "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" 196 }' \ 197 --fail 198 199 set_failure_status_to_pr: 200 runs-on: ubuntu-latest 201 needs: build_and_run 202 if: github.event.workflow_run && failure() 203 steps: 204 - name: Set failure status to the PR 205 env: 206 GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 207 run: | 208 curl --request POST \ 209 --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \ 210 --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ 211 --header 'content-type: application/json' \ 212 --data '{ 213 "state": "failure", 214 "context": "Microspeech", 215 "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" 216 }' \ 217 --fail 218