Skip to content

Commit a777e49

Browse files
committed
Update base for Update on "[executorch][weight sharing] Introduce NamedData to PTE schema"
See 'Schema Changes' in the [RFC]( Differential Revision: [D69430152](https://our.internmc.facebook.com/intern/diff/D69430152/) [ghstack-poisoned]
2 parents 4ab67a1 + d651dcd commit a777e49

File tree

76 files changed

+2727
-285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2727
-285
lines changed

.ci/scripts/unittest-linux.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,26 @@ eval "$(conda shell.bash hook)"
2727
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2828
conda activate "${CONDA_ENV}"
2929

30-
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
31-
source .ci/scripts/setup-vulkan-linux-deps.sh
30+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
31+
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
32+
source .ci/scripts/setup-vulkan-linux-deps.sh
3233

33-
PYTHON_EXECUTABLE=python \
34-
EXECUTORCH_BUILD_PYBIND=ON \
35-
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
36-
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
34+
PYTHON_EXECUTABLE=python \
35+
EXECUTORCH_BUILD_PYBIND=ON \
36+
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
37+
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
3738

38-
# Install llama3_2_vision dependencies.
39-
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
39+
# Install llama3_2_vision dependencies.
40+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
4041

41-
if [[ "$BUILD_TOOL" == "cmake" ]]; then
4242
.ci/scripts/unittest-linux-cmake.sh
4343
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
44+
# Removing this breaks sccache in the Buck build, apparently
45+
# because TMPDIR gets messed up? Please feel free to fix this and
46+
# speed up this CI job!
47+
PYTHON_EXECUTABLE=python \
48+
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
49+
4450
.ci/scripts/unittest-buck2.sh
4551
else
4652
echo "Unknown build tool $BUILD_TOOL"

.ci/scripts/unittest-macos.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ export TMP_DIR=$(mktemp -d)
3030
export PATH="${TMP_DIR}:$PATH"
3131
trap 'rm -rfv ${TMP_DIR}' EXIT
3232

33-
# Setup MacOS dependencies as there is no Docker support on MacOS atm
34-
PYTHON_EXECUTABLE=python \
35-
EXECUTORCH_BUILD_PYBIND=ON \
36-
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
37-
${CONDA_RUN} --no-capture-output \
38-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
33+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
34+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
35+
PYTHON_EXECUTABLE=python \
36+
EXECUTORCH_BUILD_PYBIND=ON \
37+
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
38+
${CONDA_RUN} --no-capture-output \
39+
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
3940

40-
# Install llama3_2_vision dependencies.
41-
PYTHON_EXECUTABLE=python \
42-
${CONDA_RUN} --no-capture-output \
43-
./examples/models/llama3_2_vision/install_requirements.sh
41+
# Install llama3_2_vision dependencies.
42+
PYTHON_EXECUTABLE=python \
43+
${CONDA_RUN} --no-capture-output \
44+
./examples/models/llama3_2_vision/install_requirements.sh
4445

45-
if [[ "$BUILD_TOOL" == "cmake" ]]; then
4646
.ci/scripts/unittest-macos-cmake.sh
4747
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
4848
.ci/scripts/unittest-buck2.sh

.github/workflows/pull.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ jobs:
5656
# Build and test ExecuTorch with the add model on portable backend.
5757
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "add" "${BUILD_TOOL}" "portable"
5858
59+
test-pip-install-editable-mode-linux:
60+
name: test-pip-install-editable-mode-linux
61+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
62+
permissions:
63+
id-token: write
64+
contents: read
65+
strategy:
66+
fail-fast: false
67+
with:
68+
runner: linux.2xlarge
69+
docker-image: executorch-ubuntu-22.04-clang12
70+
submodules: 'true'
71+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
72+
timeout: 90
73+
script: |
74+
# The generic Linux job chooses to use base env, not the one setup by the image
75+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
76+
conda activate "${CONDA_ENV}"
77+
# Debug
78+
which pip
79+
PYTHON_EXECUTABLE=python bash ./install_executorch.sh --editable --pybind xnnpack --use-pt-pinned-commit
80+
# Try to import extension library
81+
python -c "from executorch.extension.llm.custom_ops import custom_ops"
82+
5983
test-models-linux:
6084
name: test-models-linux
6185
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
@@ -480,7 +504,7 @@ jobs:
480504
481505
# Setup install_requirements for llama
482506
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
483-
507+
484508
# Test static llama weight sharing and accuracy
485509
PYTHON_EXECUTABLE=python bash .ci/scripts/test_qnn_static_llama.sh
486510

.github/workflows/trunk.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ jobs:
3636
3737
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --target-os macos --event "${GITHUB_EVENT_NAME}"
3838
39+
test-pip-install-editable-mode-macos:
40+
name: test-pip-install-editable-mode-macos
41+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
42+
permissions:
43+
id-token: write
44+
contents: read
45+
strategy:
46+
fail-fast: false
47+
with:
48+
runner: macos-m1-stable
49+
python-version: '3.11'
50+
submodules: 'true'
51+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
52+
timeout: 90
53+
script: |
54+
# The generic Linux job chooses to use base env, not the one setup by the image
55+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
56+
conda activate "${CONDA_ENV}"
57+
# Debug
58+
which pip
59+
bash .ci/scripts/setup-conda.sh
60+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash ./install_executorch.sh --editable --pybind xnnpack
61+
# Try to import extension library
62+
python -c "from executorch.extension.llm.custom_ops import custom_ops"
63+
3964
test-models-macos:
4065
name: test-models-macos
4166
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main

backends/arm/arm_vela.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
from typing import List
1313

1414
import numpy as np
15-
from ethosu.vela import vela # type: ignore
15+
16+
try:
17+
from ethosu.vela import vela # type: ignore
18+
19+
has_vela = True
20+
except ImportError:
21+
has_vela = False
1622

1723

1824
# Pack either input or output tensor block, compose the related arrays into
@@ -45,6 +51,11 @@ def vela_compile(
4551
"""
4652
Compile a TOSA graph to a binary stream for ArmBackendEthosU using Vela.
4753
"""
54+
if not has_vela:
55+
raise RuntimeError(
56+
"ethos-u-vela pip package couldn't be imported. Make sure it's installed!"
57+
)
58+
4859
with tempfile.TemporaryDirectory() as tmpdir:
4960
tosaname = "out.tosa"
5061
tosa_path = os.path.join(tmpdir, tosaname)

backends/arm/operators/op_avg_pool2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _build_generic_avgpool2d(
4141
output: TosaArg,
4242
input_zp: int,
4343
output_zp: int,
44-
accumulator_type,
44+
accumulator_type: ts.DType,
4545
) -> None:
4646
input_tensor = inputs[0]
4747

backends/arm/operators/op_conv2d.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
from executorch.backends.arm.tosa_quant_utils import build_rescale_conv_output
2323
from executorch.backends.arm.tosa_utils import build_reshape, tosa_shape
2424

25-
from serializer.tosa_serializer import TosaOp
26-
2725

2826
@register_node_visitor
2927
class Conv2dVisitor(NodeVisitor):
@@ -36,8 +34,12 @@ def __init__(self, *args):
3634
# `(input + 2 * pad - dilation * (weight - 1) - 1) / stride`
3735
# must be an integer, but tosa currently strictly require this property.
3836
# This function adjusts the pad value to meet the requirement.
39-
def adjust_pad_if_needed(self, input, weight, stride, pad, dilation):
40-
mod_remainder = (input + 2 * pad - dilation * (weight - 1) - 1) % stride
37+
def adjust_pad_if_needed(
38+
self, input_size: int, input_weight: int, stride: int, pad: int, dilation: int
39+
) -> int:
40+
mod_remainder = (
41+
input_size + 2 * pad - dilation * (input_weight - 1) - 1
42+
) % stride
4143

4244
# No need to adjust
4345
if mod_remainder == 0:
@@ -143,11 +145,11 @@ def define_node(
143145
build_reshape(
144146
tosa_graph, weight.name, weight_post_shape, weight_reshaped.name
145147
)
146-
tosa_op = TosaOp.Op().DEPTHWISE_CONV2D
148+
tosa_op = ts.TosaOp.Op().DEPTHWISE_CONV2D
147149
weight_name = weight_reshaped.name
148150
else:
149151
"""Regular convolution case"""
150-
tosa_op = TosaOp.Op().CONV2D
152+
tosa_op = ts.TosaOp.Op().CONV2D
151153
weight_name = weight.name
152154

153155
tosa_graph.addOperator(

backends/arm/test/TARGETS

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ python_library(
3939
]
4040
)
4141

42-
python_library(
43-
name = "common",
44-
srcs = ["common.py"],
45-
deps = [
46-
":runner_utils",
47-
"//executorch/backends/xnnpack/test/tester:tester",
48-
"//executorch/backends/arm:arm_backend",
49-
"//executorch/exir:lib",
50-
"//executorch/exir/backend:compile_spec_schema",
51-
"fbsource//third-party/pypi/pytest:pytest",
52-
]
53-
)
54-
5542
python_library(
5643
name = "arm_tester",
5744
srcs = glob(["tester/*.py"]),
@@ -67,4 +54,4 @@ python_library(
6754
]
6855
)
6956

70-
define_arm_tests()
57+
define_arm_tests()

backends/arm/tosa_mapping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# the standardised TOSA representation.
1212
#
1313

14-
from typing import Sequence
14+
from typing import Any, Sequence
1515

1616
import serializer.tosa_serializer as ts # type: ignore
1717
import torch
@@ -44,7 +44,7 @@
4444
}
4545

4646

47-
def map_dtype(data_type):
47+
def map_dtype(data_type: torch.dtype) -> ts.DType:
4848
if data_type in UNSUPPORTED_DTYPES:
4949
raise ValueError(f"Unsupported type: {data_type}")
5050
if data_type not in DTYPE_MAP:
@@ -88,7 +88,7 @@ def __process_list(self, argument):
8888
def __process_number(self, argument: float | int):
8989
self.number = argument
9090

91-
def __init__(self, argument) -> None:
91+
def __init__(self, argument: Any) -> None:
9292
self.name = None # type: ignore[assignment]
9393
self.dtype = None
9494
self.shape = None

0 commit comments

Comments
 (0)