Skip to content

Commit 9c74317

Browse files
authored
Merge branch 'main' into dev/issue_10761
2 parents c482cd7 + 9a7882e commit 9c74317

File tree

112 files changed

+3790
-2420
lines changed

Some content is hidden

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

112 files changed

+3790
-2420
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
556fc09a9f67f24ca5591ec049c5d0c347c5f62a
1+
b31bad1b8f1331bf43d47f46602cf6141db56844

.ci/docker/requirements-ci.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ sphinx-reredirects==0.1.4
3030
matplotlib>=3.9.4
3131
sphinx-copybutton==0.5.2
3232
# PyTorch Theme
33-
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@pytorch_sphinx_theme2#egg=pytorch_sphinx_theme2
34-
33+
pytorch_sphinx_theme2==0.2.0
3534
# script unit test requirements
3635
yaspin==3.1.0

.ci/scripts/test_qnn_static_llm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ elif [[ "${TASK_NAME}" == "stories_260k_bc" ]]; then
8181
fi
8282

8383
elif [[ "${TASK_NAME}" == "smollm2_135m" ]]; then
84-
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_static_smollm2 --model SM8650 --build_folder build-x86/ --executorch_root . --artifact_dir ./static_smollm2 --enable_x86_64
84+
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_static_llm_model --model_name smollm2_135m --model SM8650 --build_folder build-x86/ --executorch_root . --artifact_dir ./static_smollm2 --enable_x86_64
8585
exit_code1=$?
8686
if [ $exit_code1 -ne 0 ]; then
8787
exit 1

.github/workflows/doc-build.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ jobs:
4646
export CHANNEL=nightly
4747
fi
4848
49-
# Get the version of ExecuTorch from REF_NAME and save as ET_VERSION_DOCS
50-
# ET_VERSION_DOCS will be pulled during the doc build to add to the version dropdown
51-
# on the website. See docs/source/conf.py for details
52-
49+
# Set RELEASE environment variable for tagged releases
5350
GITHUB_REF=${{ github.ref }}
54-
echo "$GITHUB_REF"
55-
export ET_VERSION_DOCS="${GITHUB_REF}"
56-
echo "$ET_VERSION_DOCS"
51+
if [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9]+\.[0-9]+ ]]; then
52+
export RELEASE=true
53+
echo "Building release docs (RELEASE=true)"
54+
else
55+
export RELEASE=false
56+
echo "Building main docs (RELEASE=false)"
57+
fi
5758
5859
set -eux
5960

.lintrunner.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,24 @@ command = [
449449
"--",
450450
"@{{PATHSFILE}}",
451451
]
452+
453+
[[linter]]
454+
code = 'ETVKNODEBUG'
455+
include_patterns = [
456+
"backends/vulkan/**/*.glsl",
457+
]
458+
command = [
459+
'python',
460+
'-m',
461+
'lintrunner_adapters',
462+
'run',
463+
'grep_linter',
464+
'--pattern=((DEBUG_MODE)|(GL_EXT_debug_printf))',
465+
'--linter-name=ETVKNODEBUG',
466+
'--error-name=Using DEBUG_MODE or GL_EXT_debug_printf in Vulkan shader',
467+
"""--error-description=\
468+
#define DEBUG_MODE or #extension GL_EXT_debug_printf should only be used during development!
469+
""",
470+
'--',
471+
'@{{PATHSFILE}}',
472+
]

.mypy.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ ignore_missing_imports = True
7474
[mypy-pytorch_sphinx_theme]
7575
ignore_missing_imports = True
7676

77+
[mypy-pytorch_sphinx_theme2]
78+
ignore_missing_imports = True
79+
80+
[mypy-executorch.version]
81+
ignore_missing_imports = True
82+
7783
[mypy-ruamel]
7884
ignore_missing_imports = True
7985

backends/arm/_passes/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
from .convert_int64_output_ops_to_int32 import ConvertInt64OutputOpsToInt32Pass # noqa
2222
from .convert_int_pow_to_mul import ConvertIntPowToMuls # noqa
2323
from .convert_minmax_pass import ConvertMinMaxPass # noqa
24+
from .convert_permute_singleton_to_view_pass import ( # noqa
25+
ConvertPermuteSingletonToViewPass,
26+
)
2427
from .convert_split_to_slice import ConvertSplitToSlicePass # noqa
2528
from .convert_squeezes_to_view import ConvertSqueezesToViewPass # noqa
2629
from .convert_to_clamp import ConvertToClampPass # noqa

backends/arm/_passes/arm_pass_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
ConvertIntPowToMuls,
2828
ConvertMinMaxPass,
2929
ConvertMmToBmmPass,
30+
ConvertPermuteSingletonToViewPass,
3031
ConvertSplitToSlicePass,
3132
ConvertSqueezesToViewPass,
3233
ConvertToClampPass,
@@ -234,6 +235,7 @@ def _tosa_pipeline(
234235
self.add_pass(CastToInt32Pass())
235236
self.add_pass(BroadcastArgsPass())
236237

238+
self.add_pass(ConvertPermuteSingletonToViewPass())
237239
self.add_pass(FuseViewCopyTransform())
238240
self.add_pass(FuseConstantArgsPass(exported_program))
239241
self.add_pass(DecomposeConv2dWithInt16ActivationPass())

backends/arm/_passes/convert_expand_copy_to_repeat.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
def calculate_multiples(args):
23+
"""Returns expand args converted to repeat args, and whether the expand changes the rank"""
2324
input_node_or_tensor = args[0]
2425

2526
if isinstance(input_node_or_tensor, torch.fx.node.Node):
@@ -45,7 +46,7 @@ def calculate_multiples(args):
4546
multiples[i] if multiples[i] != -1 and extended_shape[i] == 1 else 1
4647
for i in range(expanded_rank)
4748
]
48-
return multiples
49+
return multiples, expanded_rank != len(input_shape)
4950

5051

5152
class ConvertExpandCopyToRepeatPass(ArmPass):
@@ -62,9 +63,9 @@ def call_operator(self, op, args, kwargs, meta):
6263
if op != self.expand_copy:
6364
return super().call_operator(op, args, kwargs, meta)
6465

65-
multiples = calculate_multiples(args)
66+
multiples, changes_rank = calculate_multiples(args)
6667

67-
if all((x == 1 for x in multiples)):
68+
if all((x == 1 for x in multiples)) and not changes_rank:
6869
# All dimensions/repetitions occur only once. Remove node
6970
# altogether since it's in practice just a copy.
7071
logger.warning("Found redundant expand node (no-op). Removing it.")
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
7+
from typing import Sequence, Set, Tuple, Type
8+
9+
from executorch.exir.dialects._ops import ops as exir_ops
10+
from executorch.exir.pass_base import ExportPass
11+
12+
from torch._ops import OpOverload
13+
14+
15+
_PERMUTE_TARGETS: Tuple[OpOverload, ...] = (
16+
exir_ops.edge.aten.permute.default,
17+
exir_ops.edge.aten.permute_copy.default,
18+
)
19+
20+
21+
class ConvertPermuteSingletonToViewPass(ExportPass):
22+
"""Replace permutations that only move singleton axes with a reshape.
23+
24+
Examples:
25+
x = rand(1,1,1,4)
26+
y = permute(x, (0,3,1,2))
27+
28+
becomes:
29+
x = rand(1,1,1,4)
30+
y = view_copy(x, (1,4,1,1))
31+
"""
32+
33+
_passes_required_after: Set[Type[ExportPass]] = set()
34+
35+
def call_operator(self, op, args, kwargs, meta):
36+
if op not in _PERMUTE_TARGETS:
37+
return super().call_operator(op, args, kwargs, meta)
38+
39+
input_tensor = args[0].data
40+
permutation = args[1]
41+
if not is_singleton_permutation(input_tensor.shape, permutation):
42+
return super().call_operator(op, args, kwargs, meta)
43+
44+
output_shape = meta["val"].shape
45+
view_args = (args[0], output_shape)
46+
return super().call_operator(
47+
exir_ops.edge.aten.view_copy.default, view_args, kwargs, meta
48+
)
49+
50+
51+
def is_singleton_permutation(shape: Sequence[int], permutation: Sequence[int]) -> bool:
52+
"""
53+
Treat as a view only when non-singleton axes keep their order; singleton
54+
axes may move freely since they carry no data volume.
55+
"""
56+
rank = len(shape)
57+
normalized_perm = [d % rank for d in permutation]
58+
59+
non_singleton_axes = [i for i, size in enumerate(shape) if size != 1]
60+
permuted_non_singleton_axes = [axis for axis in normalized_perm if shape[axis] != 1]
61+
62+
return permuted_non_singleton_axes == non_singleton_axes

0 commit comments

Comments
 (0)