Skip to content

Commit c1e6a29

Browse files
authored
Merge branch 'main' into export-D85704977
2 parents f6c803f + 3dbc15b commit c1e6a29

File tree

176 files changed

+5449
-2506
lines changed

Some content is hidden

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

176 files changed

+5449
-2506
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4361747abfc55e40e929396ed986efe775d745f9
1+
d03e90c2cd9048e6d9a75285c0355f033cd016fc
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/CMakeLists.txt

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,44 @@ endif()
4848

4949
# VGF backend builds
5050
if(EXECUTORCH_BUILD_VGF)
51-
52-
# include libvgf
53-
set(LIBVGF_PATH
54-
"${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/"
55-
)
56-
5751
set(VULKAN_THIRD_PARTY_PATH ${EXECUTORCH_ROOT}/backends/vulkan/third-party)
5852
set(VULKAN_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/Vulkan-Headers/include)
5953
set(VOLK_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/volk)
6054

61-
set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a")
55+
if(APPLE
56+
OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$"
57+
OR EXISTS
58+
"${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/"
59+
)
60+
message(STATUS "libvgf sourced from local scratch tree")
61+
62+
# Legacy layout: libvgf sourced from local scratch tree
63+
set(LIBVGF_PATH
64+
"${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/"
65+
)
66+
set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a")
67+
else()
68+
message(STATUS "libvgf installed from pip package")
69+
70+
set(Python3_FIND_VIRTUALENV FIRST)
71+
if(EXECUTORCH_ROOT AND EXISTS "${EXECUTORCH_ROOT}/env")
72+
set(Python3_EXECUTABLE "${EXECUTORCH_ROOT}/env/bin/python3")
73+
endif()
74+
75+
find_package(Python3 REQUIRED COMPONENTS Interpreter)
76+
77+
# Prefer arch-specific site-packages if present, else pure
78+
set(_vgf_site_arch "${Python3_SITEARCH}/vgf_lib/binaries")
79+
set(_vgf_site_pure "${Python3_SITELIB}/vgf_lib/binaries")
80+
if(EXISTS "${_vgf_site_arch}")
81+
set(LIBVGF_PATH "${_vgf_site_arch}")
82+
else()
83+
set(LIBVGF_PATH "${_vgf_site_pure}")
84+
endif()
85+
86+
set(LIBVGF_STATIC "${LIBVGF_PATH}/lib/libvgf.a")
87+
endif()
88+
6289
set(LIBVGF_INCLUDE "${LIBVGF_PATH}/include/")
6390

6491
add_library(vgf STATIC IMPORTED)

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: 44 additions & 16 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,
@@ -158,7 +159,12 @@ def _transform(self, graph_module: GraphModule):
158159
def _tosa_pipeline(
159160
self, exported_program: ExportedProgram, graph_module: GraphModule
160161
) -> GraphModule:
162+
# Preprocessing passes
163+
161164
self.add_pass(AnnotateOutputDimOrderPass())
165+
166+
# Node transformation passes (pre q/dq folding)
167+
162168
self.add_pass(FuseQuantizedActivationPass())
163169
self.add_pass(RemoveGetItemPass())
164170
self.add_pass(ConvertToClampPass())
@@ -173,8 +179,19 @@ def _tosa_pipeline(
173179
self.add_pass(ConvertELUParamsPass())
174180
self.add_pass(ConvertSplitToSlicePass())
175181
self.add_pass(QuantizeOperatorArguments())
182+
183+
# Fold Q/DQ nodes, insert INT8/INT32 rescales.
184+
176185
self.add_pass(FoldAndAnnotateQParamsPass(exported_program)) # type: ignore[call-arg]
177186
self.add_pass(FuseDuplicateUsersPass())
187+
# TODO: DecomposeLinearPass should run after InsertRescaleInt32Pass or
188+
# before FoldAndAnnotateQParamsPass but is unable to at the moment.
189+
# Ticket: MLETORCH-1539
190+
self.add_pass(DecomposeLinearPass())
191+
self.add_pass(InsertRescaleInt32Pass())
192+
193+
# Node transformation passes (post q/dq folding)
194+
178195
self.add_pass(DecomposeExpm1Pass())
179196
self.add_pass(DecomposeLogitPass())
180197
self.add_pass(DecomposeMaskedFill())
@@ -195,56 +212,67 @@ def _tosa_pipeline(
195212
self.add_pass(DecomposeSignPass())
196213
self.add_pass(DecomposeFloorDividePass())
197214
self.add_pass(DecomposeDivTensorModePass())
215+
self.add_pass(DecomposeGeluPass())
216+
self.add_pass(DecomposeAddSubAlphaPass())
217+
self.add_pass(DecomposeGroupedConv())
218+
self.add_pass(Conv1dUnsqueezePass())
219+
220+
# Scalars -> tensors, match tensor dtypes and ranks.
221+
198222
self.add_pass(ReplaceScalarWithTensorByProfilePass())
223+
self.add_pass(ConvertFullLikeToFullPass())
224+
self.add_pass(MatchArgDtypePass())
225+
self.add_pass(UnsqueezeScalarPlaceholdersPass(exported_program))
226+
# TODO: Move DecomposeNotEqualPass to before or after this block of
227+
# passes. Ticket: MLETORCH-1540
228+
self.add_pass(DecomposeNotEqualPass())
229+
self.add_pass(MatchArgRanksPass(exported_program))
230+
self.add_pass(FuseConstantArgsPass(exported_program))
231+
232+
# Node transformation passes (post scalar-removal)
233+
199234
self.add_pass(DecomposeRemainderPass())
200235
self.add_pass(DecomposeDivTensorModePass())
201236
self.add_pass(DecomposeEmbeddingPass())
202237
self.add_pass(FuseBatchnorm2DPass(exported_program))
203238
self.add_pass(ConvertMmToBmmPass())
204239
self.add_pass(DecomposeGluPass())
205-
self.add_pass(DecomposeLinearPass())
206240
self.add_pass(DecomposeLeakyReLUPass())
207-
self.add_pass(DecomposeNotEqualPass())
208241
self.add_pass(DecomposeDivPass())
209-
self.add_pass(DecomposeAddSubAlphaPass())
210242
self.add_pass(DecomposeSoftmaxPass())
211-
self.add_pass(DecomposeGeluPass())
212-
self.add_pass(ConvertFullLikeToFullPass())
213243
self.add_pass(ConvertMinMaxPass())
214244
self.add_pass(ConvertAnyDefaultDimDimsPass())
215-
self.add_pass(MatchArgDtypePass())
216-
self.add_pass(UnsqueezeScalarPlaceholdersPass(exported_program))
217-
self.add_pass(MatchArgRanksPass(exported_program))
218245
self.add_pass(DecomposeAdaptiveAvgPool2dPass())
219246
self.add_pass(DecomposeAvgPool2d())
220247
self.add_pass(
221248
DecorateFp32toInt32CastingPass()
222249
) # Require that no new fp32->int32 is introduced after this pass
223250
self.add_pass(ComputeConstantOpsAOT(exported_program))
224-
225-
self.add_pass(DecomposeGroupedConv())
226251
self.add_pass(ConvertExpandCopyToRepeatPass())
227252
self.add_pass(UnsqueezeBeforeRepeatPass())
228253
self.add_pass(DecomposeCumsumPass(exported_program))
229-
self.add_pass(Conv1dUnsqueezePass())
230254
self.add_pass(DecomposeMaxPool2DPass())
231255
self.add_pass(SizeAdjustInputPass())
232256
self.add_pass(DecomposeSelectPass())
233257
self.add_pass(ConvertSqueezesToViewPass())
234258
self.add_pass(CastToInt32Pass())
235259
self.add_pass(BroadcastArgsPass())
236-
260+
self.add_pass(ConvertPermuteSingletonToViewPass())
237261
self.add_pass(FuseViewCopyTransform())
238-
self.add_pass(FuseConstantArgsPass(exported_program))
239262
self.add_pass(DecomposeConv2dWithInt16ActivationPass())
240-
self.add_pass(CastInt64BuffersToInt32Pass(exported_program))
263+
self.add_pass(DecomposeSumPass())
241264
self.add_pass(InsertTableOpsPass(exported_program))
265+
266+
# Aten -> TOSA transformation passes
267+
242268
self.add_pass(RewriteUpsamplePass())
243269
self.add_pass(RewriteConv2dPass(exported_program))
244270
self.add_pass(RewriteMatmulPass())
271+
272+
# Postprocessing/cleanup passes
273+
274+
self.add_pass(CastInt64BuffersToInt32Pass(exported_program))
245275
self.add_pass(FuseEqualPlaceholdersPass(exported_program))
246-
self.add_pass(InsertRescaleInt32Pass())
247-
self.add_pass(DecomposeSumPass())
248276
self.add_pass(ToTosaMemoryFormatPass(exported_program))
249277
self.add_pass(RemoveNoopPass())
250278
self.add_pass(InsertRescalePass())

0 commit comments

Comments
 (0)