Skip to content

Commit c28053b

Browse files
authored
Merge branch 'main' into fix_logging
2 parents 99fd467 + 4bd7798 commit c28053b

File tree

26 files changed

+205
-74
lines changed

26 files changed

+205
-74
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

.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

CONTRIBUTING.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Thank you for your interest in contributing to ExecuTorch! We want to make
22
it easy to contribute to this project.
33

4-
 
54

65
## Dev Install
76

@@ -91,7 +90,7 @@ executorch
9190
│ └── <a href="runtime/platform">platform</a> - Layer between architecture specific code and portable C++.
9291
├── <a href="schema">schema</a> - ExecuTorch PTE file format flatbuffer schemas.
9392
├── <a href="scripts">scripts</a> - Utility scripts for building libs, size management, dependency management, etc.
94-
├── <a href="shim">shim</a> - Compatibility layer between OSS and Internal builds.
93+
├── <a href="shim_et">shim_et</a> - Compatibility layer between OSS and Internal builds.
9594
├── <a href="test">test</a> - Broad scoped end-to-end tests.
9695
├── <a href="third-party">third-party</a> - Third-party dependencies.
9796
├── <a href="tools">tools</a> - Tools for building ExecuTorch from source, for different built tools (CMake, Buck).
@@ -192,9 +191,6 @@ in the Github repo.
192191

193192
## Coding Style
194193

195-
Goal: Encourage standards that make it easier to read, edit, maintain, and debug
196-
the ExecuTorch code.
197-
198194
### lintrunner
199195

200196
We use [`lintrunner`](https://pypi.org/project/lintrunner/) to help make sure the
@@ -259,7 +255,7 @@ toolchains, and having access to relatively modern C++ features.
259255

260256
#### C/C++ standard library usage
261257

262-
**Restricted usage of the C++ standard library.**
258+
**Restricted usage of the C++ standard library**
263259

264260
Rationale: ExecuTorch is intended to be portable to bare-metal systems that lack
265261
certain features, like dynamic memory, threading, and locking, required by parts
@@ -280,7 +276,7 @@ careful to also manually destroy objects initialized in this way.
280276

281277
#### C++ language features
282278

283-
**Exceptions: Do not use.**
279+
**Exceptions: Do not use**
284280
- Rationale: Exceptions are not widely supported on some classes of
285281
microcontrollers and DSPs, and they can significantly increase binary size.
286282

@@ -289,12 +285,12 @@ must work with threading**
289285
- Rationale: The core runtime must work on systems that do not have threading
290286
support.
291287

292-
**RTTI, dynamic_cast, and `<typeid>`: Do not use.**
288+
**RTTI, dynamic_cast, and `<typeid>`: Do not use**
293289
- Rationale: RTTI adds extra data to every virtual class. ExecuTorch doesn't
294290
have a strong need for `dynamic_cast` and friends, so it's better to reduce
295291
the binary size.
296292

297-
**Templates and template metaprogramming: Be careful and avoid if possible.**
293+
**Templates and template metaprogramming: Be careful and avoid if possible**
298294
- Rationale: Most templating results in code generation, and is one of the most
299295
common sources of binary bloat. Some use of templates is fine (e.g. an
300296
`ArrayRef<T>`, or code that handles multiple `ScalarType` types), but for the
@@ -359,7 +355,7 @@ docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/
359355
for basics.
360356

361357
1. Push your branch to your fork of `pytorch/executorch`. Most people do not
362-
have permission to push a branch directoy to the upstream repo.
358+
have permission to push a branch directory to the upstream repo.
363359
1. Create your PR
364360
- Use the `main` branch as the base.
365361
- Give the PR a clear and descriptive title. It will become the title of the

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ Key value propositions of ExecuTorch are:
4949
## Getting Started
5050
To get started you can:
5151

52-
- Visit the [Step by Step Tutorial](https://pytorch.org/executorch/main/index.html) on getting things running locally and deploy a model to a device
52+
- Visit the [Step by Step Tutorial](https://pytorch.org/executorch/main/index.html) to get things running locally and deploy a model to a device
5353
- Use this [Colab Notebook](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) to start playing around right away
54-
- Jump straight into LLMs use cases by following specific instructions for [Llama](./examples/models/llama/README.md) and [Llava](./examples/models/llava/README.md)
54+
- Jump straight into LLM use cases by following specific instructions for [Llama](./examples/models/llama/README.md) and [Llava](./examples/models/llava/README.md)
5555

5656
## Feedback and Engagement
5757

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)