Skip to content

Commit 9d60711

Browse files
authored
Merge branch 'main' into gh/lucylq/79/orig
2 parents 9b075b0 + 074b392 commit 9d60711

File tree

33 files changed

+449
-477
lines changed

33 files changed

+449
-477
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
)

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/cadence/aot/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ python_library(
211211
typing = True,
212212
deps = [
213213
":pass_utils",
214+
":utils",
214215
"//executorch/backends/cadence/aot:pass_utils",
215216
"//executorch/exir:pass_base",
216217
"//executorch/exir/dialects:lib",

backends/cadence/aot/simplify_ops.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
CadencePassAttribute,
1717
register_cadence_pass,
1818
)
19+
from executorch.backends.cadence.aot.utils import rebind
1920
from executorch.exir.dialects._ops import ops as exir_ops
2021
from executorch.exir.dialects.edge._ops import EdgeOpOverload
2122
from executorch.exir.pass_base import ExportPass, ProxyValue
22-
from torch.fx.operator_schemas import get_signature_for_torch_op
2323

2424

2525
@register_cadence_pass(CadencePassAttribute(opt_level=0))
@@ -117,32 +117,11 @@ class BindOptionalArgsPass(ExportPass):
117117
def call_operator(self, op, args, kwargs, meta):
118118
if not isinstance(op, EdgeOpOverload):
119119
return super().call_operator(op, args, kwargs, meta)
120-
assert callable(op)
121120

122-
torch_op_schemas = get_signature_for_torch_op(op._op)
123-
if len(torch_op_schemas) == 0:
124-
return super().call_operator(op, args, kwargs, meta)
125-
126-
matched_schemas = []
127-
# Iterate through all of the schema until we find one that matches
128-
# If one matches, populate `new_args_and_kwargs` with the new args/kwargs
129-
# values. If none matches, `new_args_and_kwargs` will be None
130-
for candidate_signature in torch_op_schemas:
131-
try:
132-
candidate_signature.bind(*args, **kwargs)
133-
matched_schemas.append(candidate_signature)
134-
except TypeError:
135-
continue
136-
137-
if len(matched_schemas) != 1:
138-
# Did not match any schema. Cannot normalize
139-
return super().call_operator(op, args, kwargs, meta)
140-
141-
sig = matched_schemas[0]
142-
bound_args = sig.bind(*args, **kwargs)
143-
bound_args.apply_defaults()
121+
if (updated_args := rebind(op, args, kwargs)) is not None:
122+
args, kwargs = updated_args
144123

145-
return super().call_operator(op, bound_args.args, bound_args.kwargs, meta)
124+
return super().call_operator(op, args, kwargs, meta)
146125

147126

148127
# This class encapsulates all the functions that simplify the op's args

backends/cadence/aot/tests/test_fusion_ops_passes.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -248,32 +248,28 @@ def forward(self, x):
248248
)
249249

250250
def test_force_quant_dequant_fusion(self):
251-
class M(torch.nn.Module):
252-
def __init__(self):
253-
super().__init__()
254-
255-
def forward(self, x):
256-
x = torch.ops.quantized_decomposed.quantize_per_tensor(
257-
x, 1.2, 3, 0, 127, torch.int8
258-
)
259-
x = torch.permute(x, [2, 0, 1, 3])
260-
x = torch.ops.quantized_decomposed.dequantize_per_tensor(
261-
x, 4.5, 6, 0, 127, torch.int8
262-
)
263-
return x
264-
265-
inputs = torch.randn(2, 12, 1, 6)
266-
model = M()
267-
graph_module = export_to_edge(model, (inputs,)).exported_program().graph_module
268-
269-
graph_module = FuseQuantDequantToRequantizePass(
251+
builder = GraphBuilder()
252+
x = builder.placeholder("x", torch.randn(2, 12, 1, 6, dtype=torch.float32))
253+
quant = builder.call_operator(
254+
op=exir_ops.edge.quantized_decomposed.quantize_per_tensor.default,
255+
args=(x, 1.2, 3, 0, 127, torch.int8),
256+
)
257+
permute = builder.call_operator(
258+
op=exir_ops.edge.aten.permute_copy.default, args=(quant, [2, 0, 1, 3])
259+
)
260+
dequant = builder.call_operator(
261+
op=exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default,
262+
args=(permute, 4.5, 6, 0, 127, torch.int8),
263+
)
264+
builder.output(dequant)
265+
original_graph = builder.get_graph_module()
266+
converted_graph = FuseQuantDequantToRequantizePass(
270267
force_quant_dequant_fusion=True
271-
)(graph_module).graph_module
268+
)(original_graph).graph_module
272269
self.check_op_counts(
273-
graph_module,
270+
converted_graph,
274271
expected_op_counts={
275-
# Verify that no dequant/quant pair was replaced with requantize.
276-
# quantize -> permute -> dequantize should not be replaced with requantize.
272+
# Verify that dequant/quant pair was replaced with requantize.
277273
exir_ops.edge.quantized_decomposed.quantize_per_tensor.default: 0,
278274
exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default: 0,
279275
exir_ops.edge.cadence.requantize.default: 1,

backends/cadence/aot/utils.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
from executorch.exir import ExecutorchProgramManager, memory
1919
from executorch.exir.dialects._ops import ops as exir_ops
2020
from executorch.exir.dialects.edge._ops import EdgeOpOverload, EdgeOpOverloadPacket
21+
from executorch.exir.pass_base import Argument
2122
from tabulate import tabulate
23+
from torch.fx.operator_schemas import get_signature_for_torch_op
2224

2325
from torch.utils._pytree import tree_flatten
2426

@@ -308,3 +310,30 @@ def get_size(self, exir_id: int) -> int:
308310
# Return default memory config for the backend
309311
def get_default_memory_config() -> MemoryConfig:
310312
return MemoryConfig(memory_sizes=[0x1000000000])
313+
314+
315+
def rebind(
316+
op: EdgeOpOverload, args: tuple[Argument, ...], kwargs: dict[str, Argument]
317+
) -> Optional[tuple[tuple[Argument, ...], dict[str, Argument]]]:
318+
"""Populates optional args and binds args/kwargs based on schema."""
319+
torch_op_schemas = get_signature_for_torch_op(op._op)
320+
321+
matched_schemas = []
322+
# Iterate through all of the schema until we find one that matches
323+
# If one matches, populate `new_args_and_kwargs` with the new args/kwargs
324+
# values. If none matches, `new_args_and_kwargs` will be None
325+
for candidate_signature in torch_op_schemas:
326+
try:
327+
candidate_signature.bind(*args, **kwargs)
328+
matched_schemas.append(candidate_signature)
329+
except TypeError:
330+
continue
331+
332+
if len(matched_schemas) != 1:
333+
# Did not match any schema. Cannot normalize
334+
return None
335+
336+
bound_args = matched_schemas[0].bind(*args, **kwargs)
337+
bound_args.apply_defaults()
338+
339+
return bound_args.args, bound_args.kwargs

backends/openvino/scripts/openvino_build.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,11 @@ main() {
4848
# Set parameters to configure the project with CMake
4949
# Note: Add any additional configuration options you need here
5050
export CMAKE_ARGS="-DEXECUTORCH_BUILD_OPENVINO=ON \
51-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
52-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
53-
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
54-
-DEXECUTORCH_ENABLE_LOGGING=ON \
55-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
56-
-DEXECUTORCH_BUILD_PYBIND=ON"
51+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON"
5752
export CMAKE_BUILD_ARGS="--target openvino_backend"
5853

5954
# Build the package
60-
pip install . --no-build-isolation
55+
./install_executorch.sh
6156

6257
else
6358
echo "Error: Argument is not valid: $build_type"

devtools/inspector/_inspector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ def find_total_for_module(self, module_name: str) -> float:
12401240
for block in self.event_blocks:
12411241
for event in block.events:
12421242
# Skip OPERATOR_CALL events to avoid double-counting and exclude framework tax
1243-
if event.event_name == "OPERATOR_CALL":
1243+
if event.name == "OPERATOR_CALL":
12441244
continue
12451245

12461246
module_hierarchy = event.module_hierarchy.values()
Loading
-256 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)