Skip to content

Commit 68699ed

Browse files
authored
Merge branch 'main' into kotlin-convertion-test
2 parents fa2ed59 + 5866c19 commit 68699ed

File tree

179 files changed

+2758
-1563
lines changed

Some content is hidden

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

179 files changed

+2758
-1563
lines changed

.ci/scripts/tests/test_gather_benchmark_configs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def test_skip_disabled_configs(self):
5353
"mv3": [
5454
self.gather_benchmark_configs.DisabledConfig(
5555
config_name="disabled_config1",
56-
github_issue="https://github.com/org/repo/issues/123",
56+
github_issue="https://github.com/org/repo/issues/123", # @lint-ignore
5757
),
5858
self.gather_benchmark_configs.DisabledConfig(
5959
config_name="disabled_config2",
60-
github_issue="https://github.com/org/repo/issues/124",
60+
github_issue="https://github.com/org/repo/issues/124", # @lint-ignore
6161
),
6262
]
6363
},
@@ -84,7 +84,9 @@ def test_skip_disabled_configs(self):
8484
self.assertIn("enabled_config2", result)
8585

8686
def test_disabled_configs_have_github_links(self):
87-
github_issue_regex = re.compile(r"https://github\.com/.+/.+/issues/\d+")
87+
github_issue_regex = re.compile(
88+
r"https://github\.com/.+/.+/issues/\d+" # @lint-ignore
89+
)
8890

8991
for (
9092
model_name,

.ci/scripts/unittest-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
2020
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
2121
source .ci/scripts/setup-vulkan-linux-deps.sh
2222

23+
# We need the runner to test the built library.
2324
PYTHON_EXECUTABLE=python \
24-
CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2526
.ci/scripts/setup-linux.sh "$@"
2627

2728
.ci/scripts/unittest-linux-cmake.sh

.ci/scripts/unittest-macos.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export PATH="${TMP_DIR}:$PATH"
2020
trap 'rm -rfv ${TMP_DIR}' EXIT
2121

2222
# Setup MacOS dependencies as there is no Docker support on MacOS atm
23+
# We need the runner to test the built library.
2324
PYTHON_EXECUTABLE=python \
24-
CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2526
${CONDA_RUN} --no-capture-output \
2627
.ci/scripts/setup-macos.sh "$@"
2728

.ci/scripts/wheel/envvar_base.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@
1111
# Ensure that CMAKE_ARGS is defined before referencing it. Defaults to empty
1212
# if not defined.
1313
export CMAKE_ARGS="${CMAKE_ARGS:-}"
14-
15-
# Link the XNNPACK backend into the pybindings runtime so that users can execute
16-
# ExecuTorch programs that delegate to it.
17-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_XNNPACK=ON"

.ci/scripts/wheel/envvar_macos.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@
99
# any variables so that subprocesses will see them.
1010

1111
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/wheel/envvar_base.sh"
12-
13-
# When building for macOS, link additional backends into the pybindings runtime.
14-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_COREML=ON"
15-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_MPS=ON"

.github/scripts/label_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def get_last_page_num_from_header(header: Any) -> int:
5151
# rel="next", <https://api.github.com/repositories/65600975/labels?per_page=100&page=3>; rel="last"
5252
link_info = header["link"]
5353
# Docs does not specify that it should be present for projects with just few labels
54-
# And https://github.com/malfet/deleteme/actions/runs/7334565243/job/19971396887 it's not the case
5554
if link_info is None:
5655
return 1
5756
prefix = "&page="

.github/scripts/test_extract_benchmark_results.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
2929
"name": "Syslog",
3030
"type": "DEVICE_LOG",
3131
"extension": "syslog",
32-
"url": "https://job_arn_1_device_log",
33-
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog",
32+
"url": "https://job_arn_1_device_log", # @lint-ignore
33+
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog", # @lint-ignore
3434
"app_type": app_type,
3535
"job_name": "job_arn_1_name",
3636
"os": "14",
@@ -55,8 +55,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
5555
"name": "Customer Artifacts",
5656
"type": "CUSTOMER_ARTIFACT",
5757
"extension": "zip",
58-
"url": "https://job_arn_1_customer_artifact",
59-
"s3_url": "https://job_arn_1_customer_artifact1",
58+
"url": "https://job_arn_1_customer_artifact", # @lint-ignore
59+
"s3_url": "https://job_arn_1_customer_artifact1", # @lint-ignore
6060
"app_type": app_type,
6161
"job_name": "job_arn_1_device_name",
6262
"os": "14",
@@ -68,8 +68,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
6868
"name": "Syslog",
6969
"type": "DEVICE_LOG",
7070
"extension": "syslog",
71-
"url": "https://job_arn_1_device_log",
72-
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog",
71+
"url": "https://job_arn_1_device_log", # @lint-ignore
72+
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog", # @lint-ignore
7373
"app_type": app_type,
7474
"job_name": "job_arn_2_name",
7575
"os": "14",
@@ -94,8 +94,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
9494
"name": "Customer Artifacts",
9595
"type": "CUSTOMER_ARTIFACT",
9696
"extension": "zip",
97-
"url": "https://job_arn_1_customer_artifact",
98-
"s3_url": "https://job_arn_1_customer_artifact1",
97+
"url": "https://job_arn_1_customer_artifact", # @lint-ignore
98+
"s3_url": "https://job_arn_1_customer_artifact1", # @lint-ignore
9999
"app_type": app_type,
100100
"job_name": "job_arn_2_name",
101101
"os": "14",

.github/scripts/trymerge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ def check_for_sev(org: str, project: str, skip_mandatory_checks: bool) -> None:
19641964
response = cast(
19651965
Dict[str, Any],
19661966
gh_fetch_json_list(
1967-
"https://api.github.com/search/issues",
1967+
"https://api.github.com/search/issues", # @lint-ignore
19681968
params={"q": f'repo:{org}/{project} is:open is:issue label:"ci: sev"'},
19691969
),
19701970
)

.github/workflows/_link_check.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
timeout: 120
1919
script: |
2020
./scripts/lint_urls.sh $(
21-
{ [ "${{ github.event_name }}" = "pull_request" ] \
22-
&& git diff --name-only "${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"; } \
23-
|| \
24-
{ [ "${{ github.event_name }}" = "push" ] \
25-
&& git diff --name-only "${{ github.event.before }}...${{ github.sha }}"; }
21+
if [ "${{ github.event_name }}" = "pull_request" ]; then
22+
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
23+
else
24+
echo "${{ github.event.before }}" "${{ github.sha }}"
25+
fi
2626
) || {
2727
echo
2828
echo "URL lint failed."
@@ -43,11 +43,11 @@ jobs:
4343
timeout: 60
4444
script: |
4545
./scripts/lint_xrefs.sh $(
46-
{ [ "${{ github.event_name }}" = "pull_request" ] \
47-
&& git diff --name-only "${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"; } \
48-
|| \
49-
{ [ "${{ github.event_name }}" = "push" ] \
50-
&& git diff --name-only "${{ github.event.before }}...${{ github.sha }}"; }
46+
if [ "${{ github.event_name }}" = "pull_request" ]; then
47+
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
48+
else
49+
echo "${{ github.event.before }}" "${{ github.sha }}"
50+
fi
5151
) || {
5252
echo
5353
echo "Xref lint failed."

.github/workflows/android-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ jobs:
367367
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
368368
369369
mkdir -p aar-out
370-
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029 bash scripts/build_android_library.sh
370+
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029 EXECUTORCH_ANDROID_PROFILING=ON bash scripts/build_android_library.sh
371371
mkdir -p extension/benchmark/android/benchmark/app/libs
372372
cp aar-out/executorch.aar extension/benchmark/android/benchmark/app/libs
373373
pushd extension/benchmark/android/benchmark

CMakePresets.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
{
2-
"version": 10,
3-
"cmakeMinimumRequired": {
4-
"major": 3,
5-
"minor": 31,
6-
"patch": 0
7-
},
8-
"$comment": "On-device AI across mobile, embedded and edge for PyTorch.",
2+
"version": 6,
93
"configurePresets": [
104
{
115
"name": "common",
126
"hidden": true,
13-
"binaryDir": "${sourceDir}/cmake-out",
14-
"generator": "Unix Makefiles"
7+
"binaryDir": "${sourceDir}/cmake-out"
158
},
169
{
1710
"name": "macos-arm64",

backends/arm/operators/op_avg_pool2d.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
register_node_visitor,
1818
)
1919
from executorch.backends.arm.operators.operator_validation_utils import (
20+
adjust_pooling_pad_if_needed,
2021
validate_num_inputs,
2122
validate_same_dtype,
2223
)
@@ -63,6 +64,20 @@ def _build_generic_avgpool2d(
6364
except IndexError:
6465
pad_size_list = [0, 0, 0, 0]
6566

67+
# Adjust the padding as necessary
68+
pad_size_list[1] = adjust_pooling_pad_if_needed(
69+
input_tensor.shape[2],
70+
kernel_size_list[0],
71+
stride_size_list[0],
72+
pad_size_list[1],
73+
)
74+
pad_size_list[3] = adjust_pooling_pad_if_needed(
75+
input_tensor.shape[3],
76+
kernel_size_list[1],
77+
stride_size_list[1],
78+
pad_size_list[3],
79+
)
80+
6681
attr = ts.TosaSerializerAttribute()
6782
attr.PoolAttribute(
6883
kernel=kernel_size_list,
@@ -192,6 +207,20 @@ def _build_generic_avgpool2d(
192207
except IndexError:
193208
pad_size_list = [0, 0, 0, 0]
194209

210+
# Adjust the padding as necessary
211+
pad_size_list[1] = adjust_pooling_pad_if_needed(
212+
input_tensor.shape[2],
213+
kernel_size_list[0],
214+
stride_size_list[0],
215+
pad_size_list[1],
216+
)
217+
pad_size_list[3] = adjust_pooling_pad_if_needed(
218+
input_tensor.shape[3],
219+
kernel_size_list[1],
220+
stride_size_list[1],
221+
pad_size_list[3],
222+
)
223+
195224
attr = ts.TosaSerializerAttribute()
196225
attr.AvgPool2dAttribute(
197226
kernel=kernel_size_list,

backends/arm/operators/op_max_pool2d.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,14 @@
1717
register_node_visitor,
1818
)
1919
from executorch.backends.arm.operators.operator_validation_utils import (
20+
adjust_pooling_pad_if_needed,
2021
validate_num_inputs,
2122
validate_same_dtype,
2223
)
2324
from executorch.backends.arm.tosa_mapping import TosaArg
2425
from executorch.backends.arm.tosa_specification import TosaSpecification
2526

2627

27-
# Similarly to Conv2d, the TOSA spec requires that following is exactly divisible:
28-
# `(input + 2 * pad - kernel_size) / stride`
29-
# PyTorch however, does not require this, so as needed, we must adjust the padding.
30-
def adjust_pad_if_needed(
31-
input_size: int, kernel_size: int, stride: int, pad: int
32-
) -> int:
33-
if pad == 0:
34-
return pad
35-
36-
mod_remainder = (input_size + 2 * pad - kernel_size) % stride
37-
38-
# No need to adjust
39-
if mod_remainder == 0:
40-
return pad
41-
42-
return pad - mod_remainder
43-
44-
4528
@register_node_visitor
4629
class MaxPool2dVisitor_0_80(NodeVisitor):
4730
target = "aten.max_pool2d.default"
@@ -82,13 +65,13 @@ def define_node(
8265
pad_size_list = [0, 0, 0, 0]
8366

8467
# Adjust the padding as necessary
85-
pad_size_list[1] = adjust_pad_if_needed(
68+
pad_size_list[1] = adjust_pooling_pad_if_needed(
8669
input_tensor.shape[2],
8770
kernel_size[0],
8871
stride[0],
8972
pad_size_list[1],
9073
)
91-
pad_size_list[3] = adjust_pad_if_needed(
74+
pad_size_list[3] = adjust_pooling_pad_if_needed(
9275
input_tensor.shape[3],
9376
kernel_size[1],
9477
stride[1],
@@ -167,13 +150,13 @@ def define_node(
167150
pad_size_list = [0, 0, 0, 0]
168151

169152
# Adjust the padding as necessary
170-
pad_size_list[1] = adjust_pad_if_needed(
153+
pad_size_list[1] = adjust_pooling_pad_if_needed(
171154
input_tensor.shape[2],
172155
kernel_size[0],
173156
stride[0],
174157
pad_size_list[1],
175158
)
176-
pad_size_list[3] = adjust_pad_if_needed(
159+
pad_size_list[3] = adjust_pooling_pad_if_needed(
177160
input_tensor.shape[3],
178161
kernel_size[1],
179162
stride[1],

backends/arm/operators/operator_validation_utils.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,40 @@ def validate_same_dtype(op_name: str, tensors: List[Any]):
9999
f"{op_name}: Expected all tensors to have dtype {reference_dtype}, but "
100100
f"found inconsistent dtype {tensor.dtype}."
101101
)
102+
103+
104+
def adjust_pooling_pad_if_needed(
105+
input_size: int, kernel_size: int, stride: int, pad: int
106+
) -> int:
107+
"""
108+
Calculates the padding that needs to be removed to a pooling window to make it
109+
divisible by the kernels stride. All inputs should correspond to the same dimension.
110+
111+
Parameters:
112+
-----------
113+
input_size : int
114+
The size of the input to the operator.
115+
116+
kernel_size : int
117+
The size of the kernel.
118+
119+
stride : int
120+
The size of the stride.
121+
122+
pad : int
123+
The amount of padding.
124+
125+
Output:
126+
-------
127+
An int, representing the padding to remove to make the window divisible.
128+
"""
129+
if pad == 0:
130+
return pad
131+
132+
mod_remainder = (input_size + 2 * pad - kernel_size) % stride
133+
134+
# No need to adjust
135+
if mod_remainder == 0:
136+
return pad
137+
138+
return pad - mod_remainder

0 commit comments

Comments
 (0)