Skip to content

Commit 5fad521

Browse files
committed
Update on "[et] generate debug handle before opeartor decomposition"
This diff update the debug handle generation, from each node in the edge program having a individual debug handle, to all nodes having a same ancestor in export graph sharing a same debug handle, which update the start point of tracing our node transformation from edge graph to exported graph. Differential Revision: [D76860368](https://our.internmc.facebook.com/intern/diff/D76860368/) [ghstack-poisoned]
2 parents 641e9b5 + 45a5938 commit 5fad521

File tree

95 files changed

+1963
-623
lines changed

Some content is hidden

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

95 files changed

+1963
-623
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5616fa4a68718ead203314a3467f7dd9547153ae
1+
9b498d3bb28b8e3411ce464dd2755c5b96d92c8f

.ci/docker/common/install_conda.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1313
install_miniconda() {
1414
BASE_URL="https://repo.anaconda.com/miniconda"
1515
CONDA_FILE="Miniconda3-py${PYTHON_VERSION//./}_${MINICONDA_VERSION}-Linux-x86_64.sh"
16-
if [[ $(uname -m) == "aarch64" ]]; then
16+
if [[ $(uname -m) == "aarch64" ]]; then
1717
CONDA_FILE="Miniconda3-py${PYTHON_VERSION//./}_${MINICONDA_VERSION}-Linux-aarch64.sh"
1818
fi
1919

@@ -71,4 +71,8 @@ fix_conda_ubuntu_libstdcxx() {
7171
install_miniconda
7272
install_python
7373
install_pip_dependencies
74-
fix_conda_ubuntu_libstdcxx
74+
# Hack breaks the job on aarch64 but is still necessary everywhere
75+
# else.
76+
if [ "$(uname -m)" != "aarch64" ]; then
77+
fix_conda_ubuntu_libstdcxx
78+
fi

.ci/docker/conda-env-ci.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake=3.26.4
1+
cmake=3.31.2
22
ninja=1.10.2
33
libuv
44
llvm-openmp

.ci/scripts/check_c10_sync.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pushd pytorch
1212
git checkout "$pytorch_pin"
1313
popd
1414
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/c10 pytorch/c10
15+
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/torch/standalone pytorch/torch/standalone

.lintrunner.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ exclude_patterns = [
7676
'examples/demo-apps/apple_ios/**',
7777
'examples/demo-apps/react-native/rnllama/ios/**',
7878
'extension/apple/**',
79+
'extension/llm/apple/**',
7980
# File contains @generated
8081
'extension/llm/custom_ops/spinquant/fast_hadamard_transform_special.h',
8182
'extension/llm/custom_ops/spinquant/test/fast_hadamard_transform_special_unstrided_cpu.h',

CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,8 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
705705
endif()
706706

707707
add_executable(executor_runner ${_executor_runner__srcs})
708-
if(CMAKE_BUILD_TYPE STREQUAL "Release")
709-
if(APPLE)
710-
target_link_options(executor_runner PRIVATE "LINKER:-dead_strip")
711-
else()
712-
target_link_options(executor_runner PRIVATE "LINKER:--gc-sections")
713-
endif()
708+
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
709+
target_link_options_gc_sections(executor_runner)
714710
endif()
715711
target_link_libraries(executor_runner ${_executor_runner_libs})
716712
target_compile_options(executor_runner PUBLIC ${_common_compile_options})

backends/arm/_passes/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .convert_split_to_slice import ConvertSplitToSlicePass # noqa
2323
from .convert_squeezes_to_view import ConvertSqueezesToViewPass # noqa
2424
from .convert_to_clamp import ConvertToClampPass # noqa
25+
from .decompose_acosh_pass import DecomposeAcoshPass # noqa
2526
from .decompose_atan_pass import DecomposeAtanPass # noqa
2627
from .decompose_avg_pool2d import DecomposeAvgPool2d # noqa
2728
from .decompose_batch_norm_no_stats import DecomposeBatchNormNoStatsPass # noqa

backends/arm/_passes/arm_pass_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
ConvertSplitToSlicePass,
2626
ConvertSqueezesToViewPass,
2727
ConvertToClampPass,
28+
DecomposeAcoshPass,
2829
DecomposeAtanPass,
2930
DecomposeAvgPool2d,
3031
DecomposeBatchNormNoStatsPass,
@@ -151,6 +152,7 @@ def _tosa_080_BI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
151152

152153
def _tosa_080_MI_pipeline(self, exported_program: ExportedProgram) -> GraphModule:
153154
self.add_pass(DecomposeRoundPass())
155+
self.add_pass(DecomposeAcoshPass())
154156
self.add_pass(DecomposeSqrtPass())
155157
self.add_pass(DecomposeAtanPass())
156158
self.add_pass(ConvertIntPowToMuls())
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
# pyre-unsafe
7+
8+
from executorch.backends.arm._passes import ArmPass
9+
from executorch.exir.dialects._ops import ops as exir_ops
10+
11+
# For MI case
12+
edge_acosh_op = exir_ops.edge.aten.acosh.default
13+
14+
15+
class DecomposeAcoshPass(ArmPass):
16+
"""
17+
Decomposes acosh to supported TOSA-operations.
18+
This decomposition is based on the mathematical identity:
19+
acosh(x) = log(x + sqrt((x-1)(x+1))
20+
"""
21+
22+
def call_operator(self, op, args, kwargs, meta, updated=False):
23+
24+
if op is not edge_acosh_op:
25+
return super().call_operator(op, args, kwargs, meta, updated)
26+
27+
log_op, sqrt_op, mul_op, sub_op, add_op, add_op_scalar = (
28+
exir_ops.edge.aten.log.default,
29+
exir_ops.edge.aten.sqrt.default,
30+
exir_ops.edge.aten.mul.Tensor,
31+
exir_ops.edge.aten.sub.Scalar,
32+
exir_ops.edge.aten.add.Tensor,
33+
exir_ops.edge.aten.add.Scalar,
34+
)
35+
36+
x = args[0]
37+
38+
# (x-1)(x+1)
39+
sub = super().call_operator(sub_op, (x, 1.0), {}, meta, True)
40+
add = super().call_operator(add_op_scalar, (x, 1.0), {}, meta, True)
41+
mul = super().call_operator(mul_op, (sub, add), {}, meta, True)
42+
43+
# sqrt((x-1)(x+1))
44+
sqrt = super().call_operator(sqrt_op, (mul,), {}, meta, True)
45+
46+
# x + sqrt((x-1)(x+1))
47+
add = super().call_operator(add_op, (x, sqrt), {}, meta, True)
48+
49+
# out = ln(x + sqrt((x-1)(x+1))
50+
out = super().call_operator(log_op, (add,), {}, meta, True)
51+
52+
return out

backends/arm/_passes/decompose_sqrt_pass.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# LICENSE file in the root directory of this source tree.
55

66
# pyre-unsafe
7+
from typing import Tuple, Union
8+
79
import torch
810
from executorch.exir.dialects._ops import ops as exir_ops
911
from executorch.exir.pass_base import ExportPass
@@ -15,7 +17,7 @@
1517
)
1618

1719

18-
def get_sqrt_decomposition(op) -> tuple:
20+
def get_sqrt_decomposition(op) -> Union[Tuple, torch._ops.OpOverload]:
1921
# TODO : "MLETORCH-863 : Replace current sqrt -> pow.Tensor_Scalar workaround with pow.Tensor_Tensor"
2022
if op in edge_sqrt_ops:
2123
return exir_ops.edge.aten.pow.Tensor_Scalar

0 commit comments

Comments
 (0)