Skip to content

Commit f793f79

Browse files
authored
Merge branch 'main' into tosa_tools_update_1
2 parents e3a5111 + 9b7a878 commit f793f79

File tree

65 files changed

+469
-2035
lines changed

Some content is hidden

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

65 files changed

+469
-2035
lines changed

.ci/scripts/build_android_instrumentation.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
1212
fi
1313
which "${PYTHON_EXECUTABLE}"
1414

15-
mkdir -p "${BUILD_AAR_DIR}"/executorch_android/src/androidTest/resources
16-
cp extension/module/test/resources/add.pte "${BUILD_AAR_DIR}"/executorch_android/src/androidTest/resources
15+
mkdir -p extension/android/executorch_android/src/androidTest/resources
16+
cp extension/module/test/resources/add.pte extension/android/executorch_android/src/androidTest/resources
1717

18-
pushd "${BUILD_AAR_DIR}"
18+
pushd extension/android
1919
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:testDebugUnitTest
2020
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:assembleAndroidTest
2121
popd

.ci/scripts/test_ios_ci.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
set -e
99

10-
APP_PATH="examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo"
10+
APP_PATH="executorch-examples/apple/ExecuTorchDemo/ExecuTorchDemo"
1111
MODEL_NAME="mv3"
1212
SIMULATOR_NAME="executorch"
1313

@@ -34,6 +34,10 @@ say() {
3434
echo -e "\033[1m\n\t** $1 **\n\033[0m"
3535
}
3636

37+
say "Cloning the Demo App"
38+
39+
git clone --depth 1 https://github.com/pytorch-labs/executorch-examples.git
40+
3741
say "Installing CoreML Backend Requirements"
3842

3943
./backends/apple/coreml/scripts/install_requirements.sh

.github/workflows/_android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
3838
mkdir -p ${ARTIFACTS_DIR_NAME}/library_test_dir
3939
bash .ci/scripts/build_android_instrumentation.sh
40-
cp ${BUILD_AAR_DIR}/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk "${ARTIFACTS_DIR_NAME}/library_test_dir"
40+
cp extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk "${ARTIFACTS_DIR_NAME}/library_test_dir"
4141
4242
mkdir -p ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
4343
bash examples/models/llama/install_requirements.sh

.github/workflows/android-release-artifacts.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: Version name to be uploaded for AAR release
88
required: false
99
type: string
10+
upload_to_maven:
11+
description: Upload the AAR to maven staging repository
12+
required: false
13+
type: boolean
1014

1115
concurrency:
1216
group: ${{ github.workflow }}-${{ github.ref }}
@@ -31,11 +35,14 @@ jobs:
3135
build-aar:
3236
name: build-aar
3337
needs: check-if-aar-exists
34-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
38+
if: ${{ !github.event.pull_request.head.repo.fork }}
39+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7
40+
secrets: inherit
3541
permissions:
3642
id-token: write
3743
contents: read
3844
with:
45+
secrets-env: EXECUTORCH_MAVEN_SIGNING_KEYID EXECUTORCH_MAVEN_SIGNING_PASSWORD EXECUTORCH_MAVEN_CENTRAL_PASSWORD EXECUTORCH_MAVEN_CENTRAL_USERNAME EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS
3946
runner: linux.2xlarge
4047
docker-image: executorch-ubuntu-22.04-clang12-android
4148
submodules: 'true'
@@ -52,6 +59,16 @@ jobs:
5259
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
5360
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
5461
62+
mkdir -p ~/.gradle
63+
touch ~/.gradle/gradle.properties
64+
echo "signing.keyId=${SECRET_EXECUTORCH_MAVEN_SIGNING_KEYID}" >> ~/.gradle/gradle.properties
65+
echo "signing.password=${SECRET_EXECUTORCH_MAVEN_SIGNING_PASSWORD}" >> ~/.gradle/gradle.properties
66+
echo "mavenCentralUsername=${SECRET_EXECUTORCH_MAVEN_CENTRAL_USERNAME}" >> ~/.gradle/gradle.properties
67+
echo "mavenCentralPassword=${SECRET_EXECUTORCH_MAVEN_CENTRAL_PASSWORD}" >> ~/.gradle/gradle.properties
68+
echo "signing.secretKeyRingFile=/tmp/secring.gpg" >> ~/.gradle/gradle.properties
69+
70+
echo -n "$SECRET_EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS" | base64 -d > /tmp/secring.gpg
71+
5572
# Build AAR Package
5673
mkdir aar-out
5774
export BUILD_AAR_DIR=aar-out
@@ -61,6 +78,12 @@ jobs:
6178
6279
shasum -a 256 "${ARTIFACTS_DIR_NAME}/executorch.aar"
6380
81+
# Publish to maven staging
82+
UPLOAD_TO_MAVEN="${{ inputs.upload_to_maven }}"
83+
if [[ "$UPLOAD_TO_MAVEN" == "true" ]]; then
84+
(cd aar-out; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:publishToMavenCentral)
85+
fi
86+
6487
upload-release-aar:
6588
name: upload-release-aar
6689
needs: build-aar

backends/qualcomm/_passes/layout_transform.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class LayoutTransform(ExportPass):
4747
layout_agnostic_ops = {
4848
exir_ops.edge.aten.abs.default,
4949
exir_ops.edge.aten.add.Tensor,
50+
exir_ops.edge.aten.amax.default,
5051
exir_ops.edge.aten.bitwise_or.Tensor,
5152
exir_ops.edge.aten.bmm.default,
5253
exir_ops.edge.aten.bitwise_and.Tensor,

backends/qualcomm/builders/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
op_abs,
1010
op_adaptive_avg_pool2d,
1111
op_add,
12+
op_amax,
1213
op_and,
1314
op_arange,
1415
op_argmin,
@@ -95,6 +96,7 @@
9596
op_abs,
9697
op_adaptive_avg_pool2d,
9798
op_add,
99+
op_amax,
98100
op_and,
99101
op_arange,
100102
op_argmin,

backends/qualcomm/builders/op_amax.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Copyright (c) Qualcomm Innovation Center, Inc.
2+
# All rights reserved
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
from typing import cast, Dict, List
7+
8+
import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper
9+
10+
import numpy as np
11+
12+
import torch
13+
from executorch.backends.qualcomm.utils.constants import QCOM_AXIS_ORDER, QCOM_DATA
14+
15+
from .node_visitor import NodeVisitor, register_node_visitor
16+
from .qnn_constants import OpAmax, QNN_OP_PACKAGE_NAME_QTI_AISW
17+
18+
19+
@register_node_visitor
20+
class AMax(NodeVisitor):
21+
target = ["aten.amax.default"]
22+
23+
def __init__(self, *args) -> None:
24+
super().__init__(*args)
25+
26+
def define_node(
27+
self,
28+
node: torch.fx.Node,
29+
nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper],
30+
) -> PyQnnWrapper.PyQnnOpWrapper:
31+
input_node = node.args[0]
32+
input_tensor = self.get_tensor(input_node, node)
33+
input_tensor_wrapper = self.define_tensor(
34+
input_node,
35+
node,
36+
input_tensor,
37+
PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE,
38+
nodes_to_wrappers,
39+
)
40+
41+
# mean dims and keep dims
42+
mean_dims = cast(List[int], node.args[1])
43+
mean_dims = [
44+
mean_dim % len(input_node.meta["val"].shape) for mean_dim in mean_dims
45+
]
46+
if QCOM_AXIS_ORDER in node.meta:
47+
mean_dims = [
48+
node.meta[QCOM_AXIS_ORDER].index(mean_dim) for mean_dim in mean_dims
49+
]
50+
mean_dims_shape = [len(mean_dims)]
51+
52+
output_tensor = self.get_tensor(node, node)
53+
output_tensor_wrapper = self.define_tensor(
54+
node,
55+
node,
56+
output_tensor,
57+
PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE,
58+
nodes_to_wrappers,
59+
)
60+
61+
reduce_max_op = PyQnnWrapper.PyQnnOpWrapper(
62+
node.name,
63+
QNN_OP_PACKAGE_NAME_QTI_AISW,
64+
OpAmax.op_name,
65+
)
66+
reduce_max_op.AddInputTensors([input_tensor_wrapper])
67+
reduce_max_op.AddOutputTensors([output_tensor_wrapper])
68+
reduce_max_op.AddTensorParam(
69+
OpAmax.param_axes,
70+
PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32,
71+
len(mean_dims_shape),
72+
mean_dims_shape,
73+
np.array(mean_dims, dtype=np.uint32),
74+
True,
75+
)
76+
if len(node.args) > 2:
77+
keep_dims = cast(bool, node.args[2])
78+
reduce_max_op.AddScalarParam(
79+
OpAmax.param_keep_dims,
80+
PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8,
81+
{QCOM_DATA: keep_dims},
82+
)
83+
84+
return reduce_max_op

backends/qualcomm/builders/qnn_constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
# instead of replicating them here.
1515

1616

17+
@dataclass(init=False, frozen=True)
18+
class OpAmax:
19+
op_name: str = "ReduceMax"
20+
param_axes: str = "axes"
21+
param_keep_dims: str = "keep_dims"
22+
23+
1724
@dataclass(init=False, frozen=True)
1825
class OpBatchnorm:
1926
op_name: str = "Batchnorm"

backends/qualcomm/quantizer/annotators.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ def annotate_add(node: Node, quantization_config: QuantizationConfig) -> None:
182182
annotate_binary(node, quantization_config)
183183

184184

185+
@register_annotator([torch.ops.aten.amax.default])
186+
def annotate_amax(node: Node, quantization_config: QuantizationConfig) -> None:
187+
annotate_binary(node, quantization_config)
188+
189+
185190
@register_annotator([torch.ops.aten.argmin.default])
186191
def annotate_argmin(node: Node, quantization_config: QuantizationConfig) -> None:
187192
if _is_annotated([node]):

backends/qualcomm/tests/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ def forward(self, x):
7272
return torch.any(x, dim=self.dim, keepdim=self.keepdim)
7373

7474

75+
class AMax(torch.nn.Module):
76+
def __init__(self, dim=None, keepdim=False):
77+
super().__init__()
78+
self.dim = dim
79+
self.keepdim = keepdim
80+
81+
def forward(self, x):
82+
return torch.amax(x, dim=self.dim, keepdim=self.keepdim)
83+
84+
7585
class Arange(torch.nn.Module):
7686
def __init__(self, start, end, step, dtype):
7787
super().__init__()

0 commit comments

Comments
 (0)