Skip to content

Commit b96e6d1

Browse files
committed
Update
[ghstack-poisoned]
2 parents 15504dc + f653a89 commit b96e6d1

File tree

9 files changed

+86
-53
lines changed

9 files changed

+86
-53
lines changed

.ci/docker/common/install_zephyr.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
set -ex
1010

11+
# shellcheck source=/dev/null
12+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
13+
1114
# Double check if the NDK version is set
1215
[ -n "${ZEPHYR_SDK}" ]
1316

@@ -77,16 +80,8 @@ install_prerequiresites() {
7780
chmod +x kitware-archive.sh && \
7881
./kitware-archive.sh && \
7982
rm -f kitware-archive.sh
80-
useradd -d /home/zephyruser -m -s /bin/bash zephyruser
81-
}
82-
83-
install_sdk() {
84-
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \
85-
tar -xf zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \
86-
rm -f zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \
87-
cd zephyr-sdk-0.16.0/ && \
88-
./setup.sh -c -t arm-zephyr-eabi
83+
pip_install --no-cache-dir west
84+
pip_install pyelftools
8985
}
9086

9187
install_prerequiresites
92-
install_sdk

.ci/docker/ubuntu/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ ARG ARM_SDK
8686

8787
ARG ZEPHYR_SDK
8888
COPY ./common/install_zephyr.sh install_zephyr.sh
89+
COPY ./common/utils.sh utils.sh
8990
RUN if [ -n "${ZEPHYR_SDK}" ]; then bash ./install_zephyr.sh; fi
90-
RUN rm install_zephyr.sh
91+
RUN rm install_zephyr.sh utils.sh
9192

9293
ARG QNN_SDK
9394

.ci/scripts/zephyr-utils.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
download_arm_zephyr_sdk () {
9+
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/zephyr-sdk-0.16.0_linux-x86_64.tar.xz
10+
tar -xf zephyr-sdk-0.16.0_linux-x86_64.tar.xz
11+
rm -f zephyr-sdk-0.16.0_linux-x86_64.tar.xz
12+
}
13+
14+
setup_zephyr_et_module () {
15+
git clone --branch executorch-module-integration https://github.com/BujSet/zephyr.git
16+
west init -l zephyr
17+
west config manifest.project-filter -- +executorch
18+
west -v update
19+
}

.github/workflows/trunk.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,49 @@ jobs:
5555
# Build and test executorch
5656
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
5757
58+
test-models-arm-zephyr:
59+
name: test-models-arm-zephyr
60+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
61+
strategy:
62+
matrix:
63+
model: [add]
64+
fail-fast: false
65+
with:
66+
runner: linux.2xlarge
67+
docker-image: ci-image:executorch-ubuntu-22.04-zephyr-sdk
68+
submodules: 'recursive'
69+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
70+
timeout: 120
71+
script: |
72+
MODEL_NAME=${{ matrix.model }}
73+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
74+
conda activate "${CONDA_ENV}"
75+
76+
source .ci/scripts/utils.sh
77+
source .ci/scripts/zephyr-utils.sh
78+
mkdir -p zephyr_scratch/
79+
cd zephyr_scratch
80+
export ZEPHYR_PROJ_ROOT=$(realpath $(pwd))
81+
82+
download_arm_zephyr_sdk
83+
./zephyr-sdk-0.16.0/setup.sh -c -t arm-zephyr-eabi
84+
85+
cd $ZEPHYR_PROJ_ROOT
86+
setup_zephyr_et_module
87+
88+
cd $ZEPHYR_PROJ_ROOT/modules/lib/executorch
89+
install_executorch "--use-pt-pinned-commit"
90+
.ci/scripts/setup-arm-baremetal-tools.sh --target-toolchain zephyr
91+
source examples/arm/ethos-u-scratch/setup_path.sh
92+
source $ZEPHYR_PROJ_ROOT/zephyr/zephyr-env.sh
93+
cd $ZEPHYR_PROJ_ROOT/zephyr/samples/modules/executorch/arm/hello_world
94+
west build -p always -b mps3/corstone300/fvp
95+
FVP_Corstone_SSE-300_Ethos-U55 -a build/zephyr/zephyr.elf -C mps3_board.visualisation.disable-visualisation=1 -C mps3_board.telnetterminal0.start_telnet=0 -C mps3_board.uart0.out_file='sim.out' -C cpu0.CFGITCMSZ=15 -C cpu0.CFGDTCMSZ=15 --simlimit 120
96+
97+
grep -qF "Output[0][0]: (float) 2.000000" sim.out
98+
exit_status=$? #store 0 if found (success), 1 if not (failure)
99+
exit $exit_status
100+
58101
test-models-linux-aarch64:
59102
name: test-models-linux-aarch64
60103
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main

backends/test/harness/tester.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import math
21
import random
32
from collections import Counter, OrderedDict
43
from typing import Any, Callable, Dict, List, Optional, Tuple
@@ -18,7 +17,6 @@
1817
ToExecutorch,
1918
)
2019
from executorch.exir.dim_order_utils import get_memory_format
21-
from torch.ao.ns.fx.utils import compute_sqnr
2220

2321
from torch.export import ExportedProgram
2422
from torch.testing import FileCheck
@@ -304,13 +302,13 @@ def run_method_and_compare_outputs(
304302
atol=1e-03,
305303
rtol=1e-03,
306304
qtol=0,
307-
snr: float | None = None,
308305
):
309306
number_of_runs = 1 if inputs is not None else num_runs
310307
reference_stage = self.stages[StageType.EXPORT]
311308

312309
stage = stage or self.cur
313310

311+
print(f"Comparing Stage {stage} with Stage {reference_stage}")
314312
for run_iteration in range(number_of_runs):
315313
inputs_to_run = inputs if inputs else next(self.generate_random_inputs())
316314
input_shapes = [
@@ -330,21 +328,13 @@ def run_method_and_compare_outputs(
330328
# Output from running artifact at stage
331329
stage_output = self.stages[stage].run_artifact(inputs_to_run)
332330
self._compare_outputs(
333-
reference_output,
334-
stage_output,
335-
quantization_scale,
336-
atol,
337-
rtol,
338-
qtol,
339-
snr,
331+
reference_output, stage_output, quantization_scale, atol, rtol, qtol
340332
)
341333

342334
return self
343335

344336
@staticmethod
345-
def _assert_outputs_equal(
346-
model_output, ref_output, atol=1e-03, rtol=1e-03, snr: float | None = None
347-
):
337+
def _assert_outputs_equal(model_output, ref_output, atol=1e-03, rtol=1e-03):
348338
"""
349339
Helper testing function that asserts that the model output and the reference output
350340
are equal with some tolerance. Due to numerical differences between eager mode and
@@ -369,22 +359,15 @@ def _assert_outputs_equal(
369359
f"\tMismatched count: {(model != ref).sum().item()} / {model.numel()}\n"
370360
)
371361
else:
372-
computed_snr = compute_sqnr(model.to(torch.float), ref.to(torch.float))
373-
snr = snr or float("-inf")
374-
375-
assert (
376-
torch.allclose(
377-
model,
378-
ref,
379-
atol=atol,
380-
rtol=rtol,
381-
equal_nan=True,
382-
)
383-
and computed_snr >= snr
384-
or math.isnan(computed_snr)
362+
assert torch.allclose(
363+
model,
364+
ref,
365+
atol=atol,
366+
rtol=rtol,
367+
equal_nan=True,
385368
), (
386369
f"Output {i} does not match reference output.\n"
387-
f"\tGiven atol: {atol}, rtol: {rtol}, snr: {snr}.\n"
370+
f"\tGiven atol: {atol}, rtol: {rtol}.\n"
388371
f"\tOutput tensor shape: {model.shape}, dtype: {model.dtype}\n"
389372
f"\tDifference: max: {torch.max(model-ref)}, abs: {torch.max(torch.abs(model-ref))}, mean abs error: {torch.mean(torch.abs(model-ref).to(torch.double))}.\n"
390373
f"\t-- Model vs. Reference --\n"
@@ -393,7 +376,6 @@ def _assert_outputs_equal(
393376
f"\t Mean: {model.to(torch.double).mean()}, {ref.to(torch.double).mean()}\n"
394377
f"\t Max: {model.max()}, {ref.max()}\n"
395378
f"\t Min: {model.min()}, {ref.min()}\n"
396-
f"\t SNR: {computed_snr}\n"
397379
)
398380

399381
@staticmethod
@@ -404,7 +386,6 @@ def _compare_outputs(
404386
atol=1e-03,
405387
rtol=1e-03,
406388
qtol=0,
407-
snr: float | None = None,
408389
):
409390
"""
410391
Compares the original of the original nn module with the output of the generated artifact.
@@ -427,7 +408,6 @@ def _compare_outputs(
427408
reference_output,
428409
atol=atol,
429410
rtol=rtol,
430-
snr=snr,
431411
)
432412

433413
@staticmethod

backends/test/suite/operators/test_abs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def test_abs_edge_cases(self, flow: TestFlow) -> None:
4949
# Test edge cases
5050

5151
# Tensor with infinity
52-
x = (torch.tensor([float("inf"), float("-inf"), 1.0, -1.0]),)
52+
x = torch.tensor([float("inf"), float("-inf"), 1.0, -1.0])
5353
self._test_op(AbsModel(), (x,), flow, generate_random_test_inputs=False)
5454

5555
# Tensor with NaN
56-
x = (torch.tensor([float("nan"), 1.0, -1.0]),)
56+
x = torch.tensor([float("nan"), 1.0, -1.0])
5757
self._test_op(AbsModel(), (x,), flow, generate_random_test_inputs=False)

backends/test/suite/runner.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ def build_result(
104104
# AssertionErrors to catch output mismatches, but this might catch more than that.
105105
try:
106106
tester.run_method_and_compare_outputs(
107-
inputs=None if generate_random_test_inputs else inputs,
108-
atol=5e-2,
109-
rtol=5e-2,
110-
snr=40,
107+
inputs=None if generate_random_test_inputs else inputs
111108
)
112109
except AssertionError as e:
113110
return build_result(TestResult.OUTPUT_MISMATCH_FAIL, e)

extension/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ allprojects {
1717

1818
dependencies {
1919
classpath 'com.android.tools.build:gradle:8.9.0'
20-
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.31.0'
20+
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.34.0'
2121
}
2222

2323
}

extension/android/executorch_android/build.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ dependencies {
5858
androidTestImplementation 'org.jetbrains.kotlin:kotlin-test:1.9.23'
5959
}
6060

61-
import com.vanniktech.maven.publish.SonatypeHost
62-
6361
mavenPublishing {
64-
publishToMavenCentral(SonatypeHost.DEFAULT)
62+
publishToMavenCentral()
6563
signAllPublications()
6664

67-
coordinates("org.pytorch", "executorch-android", "0.7.0")
65+
coordinates("org.pytorch", "executorch-android", "0.7.0-SNAPSHOT")
6866

6967
pom {
7068
name = "ExecuTorch Android"
@@ -96,6 +94,6 @@ mavenPublishing {
9694

9795
repositories {
9896
maven {
99-
url "https://oss.sonatype.org/content/repositories/snapshots"
97+
url "https://central.sonatype.com/repository/maven-snapshots/"
10098
}
10199
}

0 commit comments

Comments
 (0)