Skip to content

Commit 053292a

Browse files
committed
update smoke test
1 parent 8c03d04 commit 053292a

File tree

13 files changed

+130
-151
lines changed

13 files changed

+130
-151
lines changed

.ci/scripts/wheel/__init__.py

Whitespace-only changes.

.ci/scripts/wheel/envvar_linux.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# This file is sourced into the environment before building a pip wheel. It
8+
# should typically only contain shell variable assignments. Be sure to export
9+
# any variables so that subprocesses will see them.
10+
11+
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/wheel/envvar_base.sh"

build/packaging/env_var_script_macos.sh renamed to .ci/scripts/wheel/envvar_macos.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@
88
# should typically only contain shell variable assignments. Be sure to export
99
# any variables so that subprocesses will see them.
1010

11-
# Enable pybindings so that users can execute ExecuTorch programs from python.
12-
export EXECUTORCH_BUILD_PYBIND=1
13-
14-
# Ensure that CMAKE_ARGS is defined before referencing it. Defaults to empty
15-
# if not defined.
16-
export CMAKE_ARGS="${CMAKE_ARGS:-}"
17-
18-
# Link the XNNPACK backend into the pybindings runtime so that users can execute
19-
# ExecuTorch programs that delegate to it.
20-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_XNNPACK=ON"
11+
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/wheel/envvar_base.sh"
2112

2213
# When building for macOS, link additional backends into the pybindings runtime.
2314
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_COREML=ON"

build/packaging/pre_build_script.sh renamed to .ci/scripts/wheel/pre_build_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ set -euxo pipefail
1414
# which does install them. Though we'd need to disable build isolation to be
1515
# able to see the installed torch package.
1616

17-
pip install --progress-bar off -r requirements-dev.txt
17+
"${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh"

.ci/scripts/wheel/test_base.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
import os
8+
import subprocess
9+
import sys
10+
from functools import lru_cache
11+
from typing import List
12+
from dataclasses import dataclass
13+
from enum import Enum
14+
15+
16+
class Model(str, Enum):
17+
Mv3 = "mv3"
18+
19+
def __str__(self) -> str:
20+
return self.value
21+
22+
class Backend(str, Enum):
23+
XnnpackQuantizationDelegation = "xnnpack-quantization-delegation"
24+
25+
def __str__(self) -> str:
26+
return self.value
27+
28+
@dataclass
29+
class ModelTest:
30+
model: Model
31+
backend: Backend
32+
33+
34+
@lru_cache()
35+
def _repository_root_dir() -> str:
36+
workspace_dir = os.getenv("GITHUB_WORKSPACE")
37+
if workspace_dir is None:
38+
print("GITHUB_WORKSPACE is not set")
39+
sys.exit(1)
40+
41+
repository_dir = os.getenv("REPOSITORY")
42+
if repository_dir is None:
43+
print("REPOSITORY is not set")
44+
sys.exit(1)
45+
46+
return os.path.join(workspace_dir, repository_dir)
47+
48+
49+
def run_tests(model_tests: List[ModelTest]) -> None:
50+
# Why are we doing this envvar shenanigans? Since we build the testers, which
51+
# uses buck, we cannot run as root. This is a sneaky of getting around that
52+
# test.
53+
#
54+
# This can be reverted if either:
55+
# - We remove usage of buck in our builds
56+
# - We stop running the Docker image as root: https://github.com/pytorch/test-infra/issues/5091
57+
envvars = os.environ.copy()
58+
envvars.pop("HOME")
59+
60+
for model_test in model_tests:
61+
subprocess.run(
62+
[
63+
os.path.join(_repository_root_dir(), ".ci/scripts/test_model.sh"),
64+
str(model_test.model),
65+
# What to build `executor_runner` with for testing.
66+
"cmake",
67+
str(model_test.backend),
68+
],
69+
env=envvars,
70+
check=True,
71+
cwd=_repository_root_dir(),
72+
)

.ci/scripts/wheel/test_linux.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
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+
from test_base import run_tests, ModelTest, Model, Backend
9+
10+
if __name__ == "__main__":
11+
run_tests(model_tests=[
12+
ModelTest(
13+
model=Model.Mv3,
14+
backend=Backend.XnnpackQuantizationDelegation,
15+
)
16+
])

.ci/scripts/wheel/test_macos.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
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+
from test_base import run_tests, ModelTest, Model, Backend
9+
10+
if __name__ == "__main__":
11+
run_tests(model_tests=[
12+
ModelTest(
13+
model=Model.Mv3,
14+
backend=Backend.XnnpackQuantizationDelegation,
15+
)
16+
])

.github/workflows/build-wheels-linux.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Build Linux Wheels
44
on:
55
pull_request:
66
paths:
7-
- build/packaging/**
7+
- .ci/**/*
88
- .github/workflows/build-wheels-linux.yml
99
push:
1010
branches:
@@ -39,9 +39,9 @@ jobs:
3939
matrix:
4040
include:
4141
- repository: pytorch/executorch
42-
pre-script: build/packaging/pre_build_script.sh
43-
post-script: build/packaging/post_build_script.sh
44-
smoke-test-script: build/packaging/smoke_test.py
42+
pre-script: .ci/scripts/wheel/pre_build_script.sh
43+
post-script: .ci/scripts/wheel/post_build_script.sh
44+
smoke-test-script: .ci/scripts/wheel/test_linux.py
4545
package-name: executorch
4646
name: ${{ matrix.repository }}
4747
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
@@ -51,11 +51,8 @@ jobs:
5151
test-infra-repository: pytorch/test-infra
5252
test-infra-ref: main
5353
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
54-
# ExecuTorch only needs the first layer of submodules; override the
55-
# "recursive" default to do less work, and to give the buck daemon fewer
56-
# files to look at.
57-
submodules: true
58-
env-var-script: build/packaging/env_var_script_linux.sh
54+
submodules: recursive
55+
env-var-script: .ci/scripts/wheel/envvar_linux.sh
5956
pre-script: ${{ matrix.pre-script }}
6057
post-script: ${{ matrix.post-script }}
6158
package-name: ${{ matrix.package-name }}

.github/workflows/build-wheels-macos.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Build macOS Wheels
44
on:
55
pull_request:
66
paths:
7-
- build/packaging/**
7+
- .ci/**/*
88
- .github/workflows/build-wheels-macos.yml
99
push:
1010
branches:
@@ -39,9 +39,9 @@ jobs:
3939
matrix:
4040
include:
4141
- repository: pytorch/executorch
42-
pre-script: build/packaging/pre_build_script.sh
43-
post-script: build/packaging/post_build_script.sh
44-
smoke-test-script: build/packaging/smoke_test.py
42+
pre-script: .ci/scripts/wheel/pre_build_script.sh
43+
post-script: .ci/scripts/wheel/post_build_script.sh
44+
smoke-test-script: .ci/scripts/wheel/test_macos.py
4545
package-name: executorch
4646
name: ${{ matrix.repository }}
4747
uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main
@@ -51,12 +51,9 @@ jobs:
5151
test-infra-repository: pytorch/test-infra
5252
test-infra-ref: main
5353
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
54-
# ExecuTorch only needs the first layer of submodules; override the
55-
# "recursive" default to do less work, and to give the buck daemon fewer
56-
# files to look at.
57-
submodules: true
54+
submodules: recursive
5855
delocate-wheel: false
59-
env-var-script: build/packaging/env_var_script_macos.sh
56+
env-var-script: .ci/scripts/wheel/envvar_macos.sh
6057
pre-script: ${{ matrix.pre-script }}
6158
post-script: ${{ matrix.post-script }}
6259
package-name: ${{ matrix.package-name }}

build/packaging/smoke_test.py

Lines changed: 0 additions & 121 deletions
This file was deleted.

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake # For building binary targets in the wheel.
1+
cmake>=3.19 # For building binary targets in the wheel.
22
pip>=23 # For building the pip package.
33
pyyaml # Imported by the kernel codegen tools.
44
setuptools>=63 # For building the pip package contents.

0 commit comments

Comments
 (0)