Skip to content

Commit d3cae81

Browse files
committed
Update base for Update on "[cortex-m] Add scalar c++ op for dequantize_per_tensor"
Only buck build for now, CMake is next. No MVE, scalar only. Strictly the dtypes we care about update arg_meta to reflect that. Differential Revision: [D73164576](https://our.internmc.facebook.com/intern/diff/D73164576/) [ghstack-poisoned]
2 parents 0716bc3 + 5b7f235 commit d3cae81

File tree

97 files changed

+1478
-411
lines changed

Some content is hidden

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

97 files changed

+1478
-411
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ jobs:
8080
8181
echo -n "$SECRET_EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS" | base64 -d > /tmp/secring.gpg
8282
83+
# Update the version name in build.gradle in case of maven publish
84+
VERSION="${{ inputs.version }}"
85+
if [ ! -z "$VERSION" ]; then
86+
sed -i "s/\(coordinates(\"org.pytorch\", \"executorch-android\", \"\)\([0-9]\+.[0-9]\+.[0-9]\+\)\(\")\)/\1$VERSION\3/" extension/android/executorch_android/build.gradle
87+
fi
88+
8389
# Build AAR Package
8490
mkdir aar-out
8591
export BUILD_AAR_DIR=aar-out
@@ -92,7 +98,7 @@ jobs:
9298
# Publish to maven staging
9399
UPLOAD_TO_MAVEN="${{ inputs.upload_to_maven }}"
94100
if [[ "$UPLOAD_TO_MAVEN" == "true" ]]; then
95-
(cd aar-out; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:publishToMavenCentral)
101+
(cd extension/android; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:publishToMavenCentral)
96102
fi
97103
98104
upload-release-aar:

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,16 @@ if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
761761
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/flat_tensor)
762762
endif()
763763

764+
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
765+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/module)
766+
endif()
767+
764768
if(EXECUTORCH_BUILD_EXTENSION_LLM)
765769
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/tokenizers)
766770
endif()
767771

768-
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
769-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/module)
772+
if(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER)
773+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/runner)
770774
endif()
771775

772776
if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ executorch
4545
│ └── <a href="devtools/visualization">visualization</a> - Visualization tools for representing model structure and performance metrics.
4646
├── <a href="docs">docs</a> - Static docs tooling and documentation source files.
4747
├── <a href="examples">examples</a> - Examples of various user flows, such as model export, delegates, and runtime execution.
48-
├── <a href="exir">exir</a> - Ahead-of-time library: model capture and lowering APIs. EXport Intermediate Representation (EXIR) is a format for representing the result of <a href="https://pytorch.org/docs/main/export.ir_spec.html">torch.export</a>. This directory contains utilities and passes for lowering the EXIR graphs into different <a href="/docs/source/ir-exir.md">dialects</a> and eventually suitable to run on target hardware.
48+
├── <a href="exir">exir</a> - Ahead-of-time library: model capture and lowering APIs. EXport Intermediate Representation (EXIR) is a format for representing the result of <a href="https://pytorch.org/docs/stable/export.html">torch.export</a>. This directory contains utilities and passes for lowering the EXIR graphs into different <a href="/docs/source/ir-exir.md">dialects</a> and eventually suitable to run on target hardware.
4949
│ ├── <a href="exir/_serialize">_serialize</a> - Serialize final export artifact.
5050
│ ├── <a href="exir/backend">backend</a> - Backend delegate ahead of time APIs.
5151
│ ├── <a href="exir/capture">capture</a> - Program capture.

backends/arm/test/ops/test_tanh.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
from typing import Tuple
1111

12+
import pytest
13+
1214
import torch
1315

14-
from executorch.backends.arm.test import common
16+
from executorch.backends.arm.test import common, conftest
1517
from executorch.backends.arm.test.tester.arm_tester import ArmTester
1618
from executorch.exir.backend.compile_spec_schema import CompileSpec
1719
from parameterized import parameterized
@@ -40,7 +42,7 @@ def forward(self, x):
4042
def _test_tanh_tosa_MI_pipeline(
4143
self, module: torch.nn.Module, test_data: Tuple[torch.tensor]
4244
):
43-
(
45+
tester = (
4446
ArmTester(
4547
module,
4648
example_inputs=test_data,
@@ -54,11 +56,13 @@ def _test_tanh_tosa_MI_pipeline(
5456
.check_not(["executorch_exir_dialects_edge__ops_aten_tanh_default"])
5557
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
5658
.to_executorch()
57-
.run_method_and_compare_outputs(inputs=test_data)
5859
)
5960

61+
if conftest.is_option_enabled("tosa_ref_model"):
62+
tester.run_method_and_compare_outputs(inputs=test_data)
63+
6064
def _test_tanh_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tuple):
61-
(
65+
tester = (
6266
ArmTester(
6367
module,
6468
example_inputs=test_data,
@@ -73,9 +77,11 @@ def _test_tanh_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tuple)
7377
.check_not(["executorch_exir_dialects_edge__ops_aten_tanh_default"])
7478
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
7579
.to_executorch()
76-
.run_method_and_compare_outputs(inputs=test_data)
7780
)
7881

82+
if conftest.is_option_enabled("tosa_ref_model"):
83+
tester.run_method_and_compare_outputs(inputs=test_data)
84+
7985
def _test_tanh_tosa_ethos_BI_pipeline(
8086
self,
8187
compile_spec: list[CompileSpec],
@@ -114,6 +120,7 @@ def _test_tanh_tosa_u85_BI_pipeline(
114120
)
115121

116122
@parameterized.expand(test_data_suite)
123+
@pytest.mark.tosa_ref_model
117124
def test_tanh_tosa_MI(
118125
self,
119126
test_name: str,
@@ -122,6 +129,7 @@ def test_tanh_tosa_MI(
122129
self._test_tanh_tosa_MI_pipeline(self.Tanh(), (test_data,))
123130

124131
@parameterized.expand(test_data_suite)
132+
@pytest.mark.tosa_ref_model
125133
def test_tanh_tosa_BI(self, test_name: str, test_data: torch.Tensor):
126134
self._test_tanh_tosa_BI_pipeline(self.Tanh(), (test_data,))
127135

backends/arm/test/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def define_arm_tests():
1616
"ops/test_linear.py",
1717
"ops/test_slice.py",
1818
"ops/test_sigmoid.py",
19+
"ops/test_tanh.py",
1920
]
2021

2122
TESTS = {}

backends/cadence/aot/replace_ops.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,30 +1806,6 @@ def call_operator(self, op, args, kwargs, meta):
18061806
return super().call_operator(op, tuple(new_args), kwargs, meta)
18071807

18081808

1809-
@register_cadence_pass(CadencePassAttribute(opt_level=0))
1810-
class ReplaceAtenLinalgVectorNormWithCadenceLinalgVectorNormPass(ExportPass):
1811-
"""
1812-
Replace the aten.linalg_vector_norm op with a custom op.
1813-
aten.linalg_vector_norm is not supported by Jarvis, so we
1814-
need to replace it with native_batch_norm at all optimization levels.
1815-
"""
1816-
1817-
def call_operator(self, op, args, kwargs, meta):
1818-
if op != exir_ops.edge.aten.linalg_vector_norm.default:
1819-
return super().call_operator(op, args, kwargs, meta)
1820-
1821-
assert (
1822-
len(args) == 1
1823-
), "aten.linalg_vector_norm should have 1 argument (a tensor), we do not support any custom variants"
1824-
1825-
return super().call_operator(
1826-
exir_ops.edge.cadence.linalg_vector_norm.default,
1827-
args,
1828-
kwargs,
1829-
meta,
1830-
)
1831-
1832-
18331809
@register_cadence_pass(CadencePassAttribute(opt_level=1))
18341810
class ReplaceSingleElementTensorArgumentsFromFullOpWithScalarPass(ExportPass):
18351811
"""
@@ -2243,7 +2219,6 @@ class CadenceReplaceOpsInGraph:
22432219
ReplacePT2DequantWithCadenceDequantPass,
22442220
ReplaceSingleElementTensorArgumentsFromFullOpWithScalarPass,
22452221
ReplaceAtenAvgPoolWithJarvisAvgPoolPass,
2246-
ReplaceAtenLinalgVectorNormWithCadenceLinalgVectorNormPass,
22472222
ReplaceWhereWithFullArgsWithWhereScalar,
22482223
# ReplaceGeluWithApproximateGeluPass,
22492224
]

backends/cadence/aot/tests/test_replace_ops_passes.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
MakeSliceAndCatDimOutermostPass,
2424
ReplaceAddMMWithLinearPass,
2525
ReplaceAtenConvolutionWithJarvisConvolutionPass,
26-
ReplaceAtenLinalgVectorNormWithCadenceLinalgVectorNormPass,
2726
ReplaceConstantPadNdWithSlicePass,
2827
ReplaceConvolutionOptionalArgsWithConcreteArgsPass,
2928
ReplaceConvWithIm2RowAndLinear,
@@ -1189,36 +1188,6 @@ def forward(self, x):
11891188
count_node(graph_after_passes, exir_ops.edge.aten.transpose_copy.int), 0
11901189
)
11911190

1192-
def test_replace_aten_linalg_vector_norm_with_cadence_linalg_vector_norm(self):
1193-
class LinalgVectorNorm(torch.nn.Module):
1194-
def forward(self, x: torch.Tensor):
1195-
return torch.linalg.vector_norm(x)
1196-
1197-
x = torch.randn(32)
1198-
1199-
graph_module = (
1200-
export_to_edge(LinalgVectorNorm(), (x,)).exported_program().graph_module
1201-
)
1202-
1203-
p = ReplaceAtenLinalgVectorNormWithCadenceLinalgVectorNormPass()
1204-
graph_after_passes = cast(PassResult, p(graph_module)).graph_module
1205-
1206-
# Assert that aten.linalg_vector_norm op was replaced by a
1207-
# cadence.linalg_vector_norm op
1208-
self.assertEqual(
1209-
count_node(
1210-
graph_after_passes,
1211-
exir_ops.edge.aten.linalg_vector_norm.default,
1212-
),
1213-
0,
1214-
)
1215-
self.assertEqual(
1216-
count_node(
1217-
graph_after_passes, exir_ops.edge.cadence.linalg_vector_norm.default
1218-
),
1219-
1,
1220-
)
1221-
12221191
def test_replace_aten_where_with_cadence_where_Scalar(self):
12231192
class WhereScalarModel(torch.nn.Module):
12241193
def forward(self, cond: torch.Tensor):

backends/cadence/runtime/et_pal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
#if defined(XTENSA)
9+
#if defined(__XTENSA__)
1010

1111
#include <stdio.h>
1212
#include <sys/times.h>

backends/cortex_m/test/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def define_operator_test_target(op):
2121
"//executorch/kernels/test:test_util",
2222
"//executorch/backends/cortex_m/ops:op_{}".format(op),
2323
"//executorch/backends/cortex_m/ops:cortex_m_generated_lib",
24+
"//executorch/backends/cortex_m/ops:cortex_m_generated_lib_headers",
2425
]
2526
)
2627

backends/qualcomm/aot/ir/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load(
44
)
55
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
66
load("@fbsource//xplat/executorch/backends/qualcomm:targets.bzl", "generate_schema_header")
7-
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_verision")
7+
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
88

99
QCIR_NAME = "qcir"
1010
INPUT_QCIR = QCIR_NAME + ".fbs"
@@ -56,7 +56,7 @@ def define_common_targets():
5656
platforms = [ANDROID],
5757
visibility = ["@EXECUTORCH_CLIENTS"],
5858
deps = [
59-
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
59+
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
6060
"//executorch/runtime/backend:interface",
6161
"//executorch/runtime/core:core",
6262
"//executorch/backends/qualcomm/aot/wrappers:wrappers",

backends/qualcomm/aot/python/targets.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load(
33
"ANDROID",
44
)
55
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
6-
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_verision")
6+
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
77

88
PYTHON_MODULE_NAME = "PyQnnManagerAdaptor"
99

@@ -34,7 +34,7 @@ def define_common_targets():
3434
"//executorch/backends/qualcomm/aot/ir:qcir_utils",
3535
"//executorch/backends/qualcomm/runtime:runtime",
3636
"fbsource//third-party/pybind11:pybind11",
37-
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
37+
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
3838
],
3939
external_deps = [
4040
"libtorch_python",
@@ -67,7 +67,7 @@ def define_common_targets():
6767
"//executorch/backends/qualcomm/aot/ir:qcir_utils",
6868
"//executorch/backends/qualcomm/runtime:runtime",
6969
"fbsource//third-party/pybind11:pybind11",
70-
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
70+
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
7171
],
7272
external_deps = [
7373
"libtorch_python",
@@ -94,6 +94,6 @@ def define_common_targets():
9494
"//executorch/backends/qualcomm/aot/ir:qcir_utils",
9595
"//executorch/backends/qualcomm/runtime:runtime",
9696
"fbsource//third-party/pybind11:pybind11",
97-
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
97+
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
9898
],
9999
)

backends/qualcomm/aot/wrappers/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load(
33
"ANDROID",
44
)
55
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
6-
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_verision")
6+
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
77

88
def define_common_targets():
99
"""Defines targets that should be shared between fbcode and xplat.
@@ -23,7 +23,7 @@ def define_common_targets():
2323
platforms = [ANDROID],
2424
visibility = ["@EXECUTORCH_CLIENTS"],
2525
deps = [
26-
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
26+
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
2727
"//executorch/runtime/backend:interface",
2828
"//executorch/runtime/core:core",
2929
],

0 commit comments

Comments
 (0)