Skip to content

Commit 5ebcec4

Browse files
authored
Merge branch 'main' into milestone2.1
2 parents 365de21 + 0012ffa commit 5ebcec4

File tree

77 files changed

+1279
-313
lines changed

Some content is hidden

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

77 files changed

+1279
-313
lines changed

.github/workflows/build-wheels-linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- examples/**/*
1010
- pyproject.toml
1111
- setup.py
12+
tags:
13+
- ciflow/binaries/*
1214
push:
1315
branches:
1416
- nightly

.github/workflows/build-wheels-macos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- examples/**/*
1010
- pyproject.toml
1111
- setup.py
12+
tags:
13+
- ciflow/binaries/*
1214
push:
1315
branches:
1416
- nightly

.github/workflows/pull.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,3 +762,66 @@ jobs:
762762
763763
# Test selective build
764764
PYTHON_EXECUTABLE=python bash examples/wasm/test_build_wasm.sh
765+
766+
unittest-nxp-neutron:
767+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
768+
permissions:
769+
id-token: write
770+
contents: read
771+
with:
772+
runner: linux.2xlarge
773+
docker-image: executorch-ubuntu-22.04-clang12
774+
submodules: 'recursive'
775+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
776+
timeout: 90
777+
script: |
778+
set -eux
779+
780+
# The generic Linux job chooses to use base env, not the one setup by the image
781+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
782+
conda activate "${CONDA_ENV}"
783+
784+
# Build and install Executorch
785+
PYTHON_EXECUTABLE=python \
786+
CMAKE_ARGS="-DEXECUTORCH_BUILD_NXP_NEUTRON=ON" \
787+
.ci/scripts/setup-linux.sh --build-tool "cmake"
788+
789+
# Install test requirements
790+
pip install -r backends/nxp/requirements-tests.txt
791+
792+
# Run pytest
793+
PYTHON_EXECUTABLE=python bash backends/nxp/run_unittests.sh
794+
795+
# Run aot example:
796+
PYTHON_EXECUTABLE=python bash examples/nxp/run_aot_example.sh
797+
798+
799+
nxp-build-test:
800+
name: nxp-build-test
801+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
802+
permissions:
803+
id-token: write
804+
contents: read
805+
with:
806+
runner: linux.2xlarge
807+
docker-image: executorch-ubuntu-22.04-arm-sdk
808+
submodules: 'recursive'
809+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
810+
timeout: 90
811+
script: |
812+
# The generic Linux job chooses to use base env, not the one setup by the image
813+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
814+
conda activate "${CONDA_ENV}"
815+
816+
# Build
817+
cmake -DEXECUTORCH_BUILD_NXP_NEUTRON=ON -Bcmake-out .
818+
cmake --build cmake-out --target executorch_delegate_neutron --config Release
819+
820+
# Build check for the neutron backend library
821+
lib_neutron="cmake-out/backends/nxp/libexecutorch_delegate_neutron.a"
822+
if [ -f $lib_neutron ]; then
823+
echo "Neutron backend library built."
824+
else
825+
echo "Neutron backend library not found!"
826+
exit 1
827+
fi

.github/workflows/trunk.yml

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -302,36 +302,6 @@ jobs:
302302
exit 1
303303
fi
304304
305-
nxp-build-test:
306-
name: nxp-build-test
307-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
308-
permissions:
309-
id-token: write
310-
contents: read
311-
with:
312-
runner: linux.2xlarge
313-
docker-image: executorch-ubuntu-22.04-arm-sdk
314-
submodules: 'recursive'
315-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
316-
timeout: 90
317-
script: |
318-
# The generic Linux job chooses to use base env, not the one setup by the image
319-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
320-
conda activate "${CONDA_ENV}"
321-
322-
# Build
323-
cmake -DEXECUTORCH_BUILD_NXP_NEUTRON=ON -Bcmake-out .
324-
cmake --build cmake-out --target executorch_delegate_neutron --config Release
325-
326-
# Build check for the neutron backend library
327-
lib_neutron="cmake-out/backends/nxp/libexecutorch_delegate_neutron.a"
328-
if [ -f $lib_neutron ]; then
329-
echo "Neutron backend library built."
330-
else
331-
echo "Neutron backend library not found!"
332-
exit 1
333-
fi
334-
335305
test-coreml-delegate:
336306
name: test-coreml-delegate
337307
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -771,35 +741,3 @@ jobs:
771741
build-mode: Release
772742
build-tool: cmake
773743
docker-image: executorch-ubuntu-22.04-clang12
774-
775-
unittest-nxp-neutron:
776-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
777-
permissions:
778-
id-token: write
779-
contents: read
780-
with:
781-
runner: linux.2xlarge
782-
docker-image: executorch-ubuntu-22.04-clang12
783-
submodules: 'recursive'
784-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
785-
timeout: 90
786-
script: |
787-
set -eux
788-
789-
# The generic Linux job chooses to use base env, not the one setup by the image
790-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
791-
conda activate "${CONDA_ENV}"
792-
793-
# Build and install Executorch
794-
PYTHON_EXECUTABLE=python \
795-
CMAKE_ARGS="-DEXECUTORCH_BUILD_NXP_NEUTRON=ON" \
796-
.ci/scripts/setup-linux.sh --build-tool "cmake"
797-
798-
# Install test requirements
799-
pip install -r backends/nxp/requirements-tests.txt
800-
801-
# Run pytest
802-
PYTHON_EXECUTABLE=python bash backends/nxp/run_unittests.sh
803-
804-
# Run aot example:
805-
PYTHON_EXECUTABLE=python bash examples/nxp/run_aot_example.sh

backends/arm/_passes/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .decompose_adaptive_avg_pool2d_pass import DecomposeAdaptiveAvgPool2dPass # noqa
2727
from .decompose_asin_pass import DecomposeAsinPass # noqa
2828
from .decompose_atan_pass import DecomposeAtanPass # noqa
29+
from .decompose_atanh_pass import DecomposeAtanhPass # noqa
2930
from .decompose_avg_pool2d import DecomposeAvgPool2d # noqa
3031
from .decompose_batch_norm_no_stats import DecomposeBatchNormNoStatsPass # noqa
3132
from .decompose_cosine_similarity_pass import DecomposeCosineSimilarityPass # noqa

backends/arm/_passes/arm_pass_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
DecomposeAcoshPass,
3131
DecomposeAdaptiveAvgPool2dPass,
3232
DecomposeAsinPass,
33+
DecomposeAtanhPass,
3334
DecomposeAtanPass,
3435
DecomposeAvgPool2d,
3536
DecomposeBatchNormNoStatsPass,
@@ -163,6 +164,7 @@ def _tosa_080_MI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
163164
self.add_pass(DecomposeAsinPass())
164165
self.add_pass(DecomposeSqrtPass())
165166
self.add_pass(DecomposeAtanPass())
167+
self.add_pass(DecomposeAtanhPass())
166168
self.add_pass(ConvertIntPowToMuls())
167169
self.add_pass(CastBoolToInt8Pass())
168170
self.add_pass(DecomposeSinhPass())

backends/arm/_passes/cast_int64_pass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _to_int32(self, graph_module: torch.fx.GraphModule):
4747
buffer_name = self.exported_program.graph_signature.inputs_to_buffers[
4848
node.name
4949
]
50-
buffer = self.exported_program.state_dict[node.name]
50+
buffer = self.exported_program.state_dict[buffer_name]
5151
self._assert_within_int32(buffer, node)
5252
logger.warning(
5353
f"Casting buffer {node.name} from torch.int64 to torch.int32"
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+
from executorch.backends.arm._passes import ArmPass
7+
from executorch.exir.dialects._ops import ops as exir_ops
8+
9+
10+
edge_atanh = exir_ops.edge.aten.atanh.default # MI case
11+
12+
13+
def _get_atanh_ops(op):
14+
"""Return the primitive ops required.."""
15+
if op is not edge_atanh:
16+
raise RuntimeError(f"Can't decompose atanh for op {op}")
17+
return (
18+
exir_ops.edge.aten.mul.Tensor,
19+
exir_ops.edge.aten.mul.Scalar,
20+
exir_ops.edge.aten.add.Scalar,
21+
exir_ops.edge.aten.reciprocal.default,
22+
exir_ops.edge.aten.log.default,
23+
exir_ops.edge.aten.neg.default,
24+
)
25+
26+
27+
class DecomposeAtanhPass(ArmPass):
28+
"""
29+
Decomposes the atanh operator into primitive ops.
30+
atanh(x) = 0.5 * log((1 + x) / (1 - x))
31+
"""
32+
33+
def call_operator(self, op, args, kwargs, meta):
34+
if op is not edge_atanh:
35+
return super().call_operator(op, args, kwargs, meta, updated=False)
36+
37+
ops = _get_atanh_ops(op)
38+
(
39+
op_mul_tensor,
40+
op_mul_scalar,
41+
op_add_scalar,
42+
op_reciprocal,
43+
op_log,
44+
op_neg,
45+
) = ops
46+
47+
x = args[0]
48+
49+
nom = super().call_operator(op_add_scalar, (x, 1.0), {}, meta, updated=True)
50+
51+
neg_x = super().call_operator(op_neg, (x,), {}, meta, updated=True)
52+
denom = super().call_operator(
53+
op_add_scalar, (neg_x, 1.0), {}, meta, updated=True
54+
)
55+
recip = super().call_operator(op_reciprocal, (denom,), {}, meta, updated=True)
56+
57+
log_input = super().call_operator(
58+
op_mul_tensor, (nom, recip), {}, meta, updated=True
59+
)
60+
log = super().call_operator(op_log, (log_input,), {}, meta, updated=True)
61+
62+
return super().call_operator(op_mul_scalar, (log, 0.5), {}, meta, updated=True)

backends/arm/_passes/insert_table_ops.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class TableOps:
5252
exir_ops.edge.aten.sin.default: torch.sin,
5353
exir_ops.edge.aten.tanh.default: torch.tanh,
5454
exir_ops.edge.aten.atan.default: torch.atan,
55+
exir_ops.edge.aten.atanh.default: torch.atanh,
5556
exir_ops.edge.aten.hardsigmoid.default: torch.nn.functional.hardsigmoid,
5657
exir_ops.edge.aten.hardswish.default: torch.nn.functional.hardswish,
5758
exir_ops.edge.aten.sinh.default: torch.sinh,

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ def is_node_supported(
252252
exir_ops.edge.aten._adaptive_avg_pool2d.default,
253253
exir_ops.edge.aten.sign.default,
254254
exir_ops.edge.aten.asin.default,
255+
exir_ops.edge.aten.atanh.default,
255256
]
256257

257258
return supported

0 commit comments

Comments
 (0)