Skip to content

Commit 213d8c4

Browse files
committed
shorten tested llava prefix due to output change due to slightly changed numerics on "Remove ExecuTorch copy of Vectorized"
All uses are outside ExecuTorch core, so we can just use ATen Vectorized. Differential Revision: [D66396016](https://our.internmc.facebook.com/intern/diff/D66396016/) [ghstack-poisoned]
2 parents b612e5b + 2ea3368 commit 213d8c4

File tree

247 files changed

+8606
-2061
lines changed

Some content is hidden

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

247 files changed

+8606
-2061
lines changed

.ci/scripts/build-qnn-sdk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ set_up_aot() {
3232
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
3333
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
3434
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
35+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
36+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3537
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3638
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
3739
-DPYTHON_EXECUTABLE=python3

.ci/scripts/test_llama_torchao_lowbit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cmake -DPYTHON_EXECUTABLE=python \
3030
-DCMAKE_BUILD_TYPE=Release \
3131
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
3232
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
33+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3334
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3435
-DEXECUTORCH_BUILD_XNNPACK=OFF \
3536
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \

.ci/scripts/test_llava.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ EXECUTORCH_COMMON_CMAKE_ARGS=" \
3737
-DEXECUTORCH_ENABLE_LOGGING=ON \
3838
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3939
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
40+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
4041
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
4142
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
4243
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
@@ -146,7 +147,7 @@ run_and_verify() {
146147

147148
# verify result.txt
148149
RESULT=$(cat result.txt)
149-
EXPECTED_PREFIX="ASSISTANT: image captures a basketball game in progress, with several players on the court. "
150+
EXPECTED_PREFIX="ASSISTANT: image captures a basketball game in progress, with"
150151

151152
if [[ "${RESULT}" == *"${EXPECTED_PREFIX}"* ]]; then
152153
echo "Expected result prefix: ${EXPECTED_PREFIX}"

.ci/scripts/test_phi_3_mini.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cmake_install_executorch_libraries() {
2727
-DEXECUTORCH_ENABLE_LOGGING=1 \
2828
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
2929
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
30+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3031
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3132
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3233
-DEXECUTORCH_BUILD_XNNPACK=ON \

.ci/scripts/unittest-buck2.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ buck2 query "//backends/apple/... + //backends/example/... + \
1515
//kernels/optimized/... + //kernels/portable/... + //kernels/quantized/... + \
1616
//kernels/test/... + //runtime/... + //schema/... + //test/... + //util/..."
1717

18-
UNBUILDABLE_OPTIMIZED_OPS_REGEX="gelu|fft_r2c|log_softmax"
18+
UNBUILDABLE_OPTIMIZED_OPS_REGEX="_elu|gelu|fft|log_softmax"
1919
BUILDABLE_OPTIMIZED_OPS=$(buck2 query //kernels/optimized/cpu/... | grep -E -v $UNBUILDABLE_OPTIMIZED_OPS_REGEX)
2020

2121
# TODO: build prim_ops_test_cpp again once supported_features works in
@@ -24,6 +24,8 @@ BUILDABLE_KERNELS_PRIM_OPS_TARGETS=$(buck2 query //kernels/prim_ops/... | grep -
2424
# TODO: expand the covered scope of Buck targets.
2525
# //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH.
2626
# //runtime/test/... requires Python torch, which we don't have in our OSS buck setup.
27-
buck2 test $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... \
28-
$BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \
29-
//runtime/executor: //runtime/kernel/... //runtime/platform/...
27+
for op in "build" "test"; do
28+
buck2 $op $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... \
29+
$BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \
30+
//runtime/executor: //runtime/kernel/... //runtime/platform/...
31+
done

.github/workflows/trunk.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ jobs:
552552
-DEXECUTORCH_ENABLE_LOGGING=1 \
553553
-DCMAKE_BUILD_TYPE=Release \
554554
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
555+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
555556
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
556557
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
557558
-DEXECUTORCH_BUILD_XNNPACK=ON \
@@ -686,3 +687,32 @@ jobs:
686687
build-mode: Release
687688
build-tool: cmake
688689
docker-image: executorch-ubuntu-22.04-clang12
690+
691+
unittest-nxp-neutron:
692+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
693+
permissions:
694+
id-token: write
695+
contents: read
696+
with:
697+
runner: linux.2xlarge
698+
docker-image: executorch-ubuntu-22.04-clang12
699+
submodules: 'recursive'
700+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
701+
timeout: 90
702+
script: |
703+
set -eux
704+
705+
# The generic Linux job chooses to use base env, not the one setup by the image
706+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
707+
conda activate "${CONDA_ENV}"
708+
709+
# Build and install Executorch
710+
PYTHON_EXECUTABLE=python \
711+
CMAKE_ARGS="-DEXECUTORCH_BUILD_NXP_NEUTRON=ON" \
712+
.ci/scripts/setup-linux.sh --build-tool "cmake"
713+
714+
# Install test requirements
715+
pip install -r backends/nxp/requirements-tests.txt
716+
717+
# Run pytest
718+
PYTHON_EXECUTABLE=python bash backends/nxp/run_unittests.sh

.lintrunner.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ exclude_patterns = [
271271
'examples/**',
272272
'exir/verification/bindings.cpp',
273273
'extension/**',
274+
# Uses properly-gated (ET_USE_PYTORCH_HEADERS) ATen include.
275+
'kernels/portable/cpu/util/elementwise_util.h',
276+
'kernels/portable/cpu/util/math_util.h',
277+
'kernels/portable/cpu/util/vectorized_math.h',
274278
'kernels/optimized/**',
275279
'runtime/core/exec_aten/**',
276280
# Want to be able to keep c10 in sync with PyTorch core.
@@ -386,15 +390,9 @@ exclude_patterns = [
386390
"third-party/**",
387391
# TODO: remove exceptions as we migrate
388392
# backends
389-
"backends/vulkan/quantizer/**",
390-
"backends/vulkan/test/**",
391-
"backends/xnnpack/quantizer/**",
392-
"backends/xnnpack/test/**",
393-
"exir/tests/test_passes.py",
394-
"extension/llm/export/builder.py",
395-
"extension/llm/export/quantizer_lib.py",
396393
"exir/tests/test_memory_planning.py",
397394
"exir/backend/test/demos/test_xnnpack_qnnpack.py",
395+
"backends/xnnpack/test/test_xnnpack_utils.py",
398396
]
399397

400398
command = [

CMakeLists.txt

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -152,37 +152,11 @@ else()
152152
endif()
153153

154154
if(EXECUTORCH_BUILD_TESTS)
155-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
156155
include(CTest)
157156
endif()
158157

159158
add_subdirectory(third-party)
160159

161-
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
162-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
163-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
164-
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
165-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
166-
endif()
167-
168-
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
169-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
170-
endif()
171-
172-
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
173-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
174-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
175-
endif()
176-
177-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
178-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
179-
set(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
180-
endif()
181-
182-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
183-
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
184-
endif()
185-
186160
if(NOT DEFINED FXDIV_SOURCE_DIR)
187161
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
188162
${CMAKE_POSITION_INDEPENDENT_CODE}
@@ -336,7 +310,7 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
336310
" -fprofile-instr-generate -fcoverage-mapping"
337311
)
338312
else()
339-
message(ERROR
313+
message(FATAL_ERROR
340314
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
341315
)
342316
endif()
@@ -456,14 +430,6 @@ endif()
456430

457431
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations)
458432

459-
#
460-
# gflags: Commandline flag host library.
461-
#
462-
463-
if(EXECUTORCH_BUILD_GFLAGS)
464-
add_subdirectory(third-party/gflags)
465-
endif()
466-
467433
# Install `executorch` library as well as `executorch-config.cmake` under
468434
# ${CMAKE_INSTALL_PREFIX}/
469435
install(

backends/apple/coreml/scripts/build_tests.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ cmake "$EXECUTORCH_ROOT_PATH" -B"$CMAKE_EXECUTORCH_BUILD_DIR_PATH" \
3333
-DPLATFORM=MAC_UNIVERSAL \
3434
-DDEPLOYMENT_TARGET=13.0 \
3535
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
36-
-DEXECUTORCH_BUILD_XNNPACK=OFF \
37-
-DEXECUTORCH_BUILD_GFLAGS=OFF
36+
-DEXECUTORCH_BUILD_XNNPACK=OFF
3837

3938
cmake --build "$CMAKE_EXECUTORCH_BUILD_DIR_PATH" -j9 -t executorch
4039

backends/arm/_passes/arm_pass_manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@
6262
UnsqueezeScalarPlaceholdersPass,
6363
)
6464

65-
from executorch.backends.arm.tosa_specification import TosaSpecification
65+
from executorch.backends.arm.tosa_specification import (
66+
TosaLoweringContext,
67+
TosaSpecification,
68+
)
6669
from executorch.backends.transforms.decompose_sdpa import (
6770
DecomposeScaledDotProductAttention,
6871
)
@@ -80,7 +83,8 @@ def __init__(self, tosa_spec: TosaSpecification) -> None:
8083
super().__init__()
8184

8285
def _transform(self, graph_module: GraphModule):
83-
return self(graph_module).graph_module
86+
with TosaLoweringContext(self.tosa_spec):
87+
return self(graph_module).graph_module
8488

8589
def _tosa_080_BI_pipeline(self, exported_program: ExportedProgram) -> GraphModule:
8690
self.add_pass(FuseQuantizedActivationPass())

backends/arm/_passes/scalars_to_attribute_pass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from executorch.backends.arm._passes.arm_pass_utils import get_first_fake_tensor
1313

1414
from executorch.exir.pass_base import ExportPass, PassResult
15-
from torch.ao.quantization.fx.utils import get_new_attr_name_with_prefix
1615
from torch.fx import GraphModule, Node
16+
from torchao.quantization.pt2e.utils import get_new_attr_name_with_prefix
1717

1818

1919
class ScalarsToAttributePass(ExportPass):

backends/arm/operators/op_abs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def define_node(
4444
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore
4545

4646
validate_num_inputs(self.target, inputs, 1)
47-
validate_same_dtype(self.target, [*inputs, output])
47+
validate_same_dtype(self.target, [*inputs, output], ts)
4848

4949
# Handle int8 (quantized) and int32
5050
if not (inputs[0].dtype in [ts.DType.INT8, ts.DType.INT32]):
@@ -106,7 +106,7 @@ def define_node(
106106
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore
107107

108108
validate_num_inputs(self.target, inputs, 1)
109-
validate_same_dtype(self.target, [*inputs, output])
109+
validate_same_dtype(self.target, [*inputs, output], ts)
110110

111111
if inputs[0].dtype in [ts.DType.INT8, ts.DType.INT32]:
112112
# Call the inherited define_node for handling integers
@@ -153,7 +153,7 @@ def define_node(
153153
import serializer.tosa_serializer as ts # type: ignore
154154

155155
validate_num_inputs(self.target, inputs, 1)
156-
validate_same_dtype(self.target, [*inputs, output])
156+
validate_same_dtype(self.target, [*inputs, output], ts)
157157

158158
# Handle int8 (quantized) and int32
159159
if not (inputs[0].dtype in [ts.DType.INT8, ts.DType.INT32]):
@@ -216,7 +216,7 @@ def define_node(
216216
import serializer.tosa_serializer as ts # type: ignore
217217

218218
validate_num_inputs(self.target, inputs, 1)
219-
validate_same_dtype(self.target, [*inputs, output])
219+
validate_same_dtype(self.target, [*inputs, output], ts)
220220

221221
if inputs[0].dtype in [ts.DType.INT8, ts.DType.INT32]:
222222
# Call the inherited define_node for handling integers

backends/arm/operators/op_add.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def define_node(
4545
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore
4646

4747
validate_num_inputs(self.target, inputs, 2)
48-
validate_same_dtype(self.target, [*inputs, output])
48+
validate_same_dtype(self.target, [*inputs, output], ts)
4949

5050
# Handle int8 (quantized) and int32
5151
supported_dtypes = [ts.DType.INT8, ts.DType.INT32]
@@ -118,7 +118,7 @@ def define_node(
118118
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore
119119

120120
validate_num_inputs(self.target, inputs, 2)
121-
validate_same_dtype(self.target, [*inputs, output])
121+
validate_same_dtype(self.target, [*inputs, output], ts)
122122

123123
if inputs[0].dtype in [ts.DType.INT8, ts.DType.INT32]:
124124
# Call the inherited define_node for handling integers
@@ -163,7 +163,7 @@ def define_node(
163163
import serializer.tosa_serializer as ts # type: ignore
164164

165165
validate_num_inputs(self.target, inputs, 2)
166-
validate_same_dtype(self.target, [*inputs, output])
166+
validate_same_dtype(self.target, [*inputs, output], ts)
167167

168168
# Handle int8 (quantized) and int32
169169
supported_dtypes = [ts.DType.INT8, ts.DType.INT32]
@@ -226,7 +226,7 @@ def define_node(
226226
import serializer.tosa_serializer as ts # type: ignore
227227

228228
validate_num_inputs(self.target, inputs, 2)
229-
validate_same_dtype(self.target, [*inputs, output])
229+
validate_same_dtype(self.target, [*inputs, output], ts)
230230

231231
if inputs[0].dtype in [ts.DType.INT8, ts.DType.INT32]:
232232
# Call the inherited define_node for handling integers

backends/arm/operators/op_amax.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def define_node(
3636
import tosa_tools.v0_80.serializer.tosa_serializer as ts
3737

3838
validate_num_inputs(self.target, inputs, 3)
39-
validate_same_dtype(self.target, [inputs[0], output])
39+
validate_same_dtype(self.target, [inputs[0], output], ts)
4040

4141
input = inputs[0]
4242
dim = inputs[1].number
@@ -79,7 +79,7 @@ def define_node(
7979
import serializer.tosa_serializer as ts
8080

8181
validate_num_inputs(self.target, inputs, 3)
82-
validate_same_dtype(self.target, [inputs[0], output])
82+
validate_same_dtype(self.target, [inputs[0], output], ts)
8383

8484
input = inputs[0]
8585
dim = inputs[1].number

backends/arm/operators/op_amin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def define_node(
3636
import tosa_tools.v0_80.serializer.tosa_serializer as ts
3737

3838
validate_num_inputs(self.target, inputs, 3)
39-
validate_same_dtype(self.target, [inputs[0], output])
39+
validate_same_dtype(self.target, [inputs[0], output], ts)
4040

4141
input = inputs[0]
4242
dim = inputs[1].number
@@ -79,7 +79,7 @@ def define_node(
7979
import serializer.tosa_serializer as ts
8080

8181
validate_num_inputs(self.target, inputs, 3)
82-
validate_same_dtype(self.target, [inputs[0], output])
82+
validate_same_dtype(self.target, [inputs[0], output], ts)
8383

8484
input = inputs[0]
8585
dim = inputs[1].number

backends/arm/operators/op_any.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def define_node(
3535
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore
3636

3737
validate_num_inputs(self.target, inputs, 3)
38-
validate_same_dtype(self.target, [inputs[0], output])
38+
validate_same_dtype(self.target, [inputs[0], output], ts)
3939

4040
if not (inputs[0].dtype == ts.DType.BOOL):
4141
raise ValueError("All inputs need to be BOOL." f"Got {inputs[0].dtype=}")
@@ -72,7 +72,7 @@ def define_node(
7272
import serializer.tosa_serializer as ts
7373

7474
validate_num_inputs(self.target, inputs, 3)
75-
validate_same_dtype(self.target, [inputs[0], output])
75+
validate_same_dtype(self.target, [inputs[0], output], ts)
7676

7777
if not (inputs[0].dtype == ts.DType.BOOL):
7878
raise ValueError("All inputs need to be BOOL." f"Got {inputs[0].dtype=}")

backends/arm/operators/op_avg_pool2d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def define_node(
105105
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore
106106

107107
validate_num_inputs(self.target, inputs, [3, 4, 6])
108-
validate_same_dtype(self.target, [inputs[0], output])
108+
validate_same_dtype(self.target, [inputs[0], output], ts)
109109

110110
supported_dtypes = [ts.DType.INT8]
111111
if inputs[0].dtype not in supported_dtypes:
@@ -145,7 +145,7 @@ def define_node(
145145
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore
146146

147147
validate_num_inputs(self.target, inputs, [3, 4, 6])
148-
validate_same_dtype(self.target, [inputs[0], output])
148+
validate_same_dtype(self.target, [inputs[0], output], ts)
149149

150150
supported_dtypes = [ts.DType.INT8, ts.DType.FP32]
151151
if inputs[0].dtype not in supported_dtypes:
@@ -252,7 +252,7 @@ def define_node(
252252
import serializer.tosa_serializer as ts # type: ignore
253253

254254
validate_num_inputs(self.target, inputs, [3, 4, 6])
255-
validate_same_dtype(self.target, [inputs[0], output])
255+
validate_same_dtype(self.target, [inputs[0], output], ts)
256256

257257
supported_dtypes = [ts.DType.INT8]
258258
if inputs[0].dtype not in supported_dtypes:
@@ -295,7 +295,7 @@ def define_node(
295295
import serializer.tosa_serializer as ts # type: ignore
296296

297297
validate_num_inputs(self.target, inputs, [3, 4, 6])
298-
validate_same_dtype(self.target, [inputs[0], output])
298+
validate_same_dtype(self.target, [inputs[0], output], ts)
299299

300300
supported_dtypes = [ts.DType.INT8, ts.DType.FP32]
301301
if inputs[0].dtype not in supported_dtypes:

0 commit comments

Comments
 (0)