Skip to content

Commit c464a71

Browse files
author
pytorchbot
committed
2024-10-30 nightly release (db38bcc)
1 parent 23327e9 commit c464a71

File tree

35 files changed

+1208
-262
lines changed

35 files changed

+1208
-262
lines changed

.github/workflows/pull.yml

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
name: test-setup-linux-gcc
3636
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
3737
strategy:
38-
matrix:
39-
include:
40-
- build-tool: cmake
4138
fail-fast: false
4239
with:
4340
runner: linux.2xlarge
@@ -50,7 +47,7 @@ jobs:
5047
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
5148
conda activate "${CONDA_ENV}"
5249
53-
BUILD_TOOL=${{ matrix.build-tool }}
50+
BUILD_TOOL="cmake"
5451
5552
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
5653
# Build and test ExecuTorch with the add model on portable backend.
@@ -89,20 +86,11 @@ jobs:
8986
strategy:
9087
matrix:
9188
dtype: [fp32]
92-
build-tool: [buck2, cmake]
9389
mode: [portable, xnnpack+custom, xnnpack+custom+qe]
9490
include:
9591
- dtype: bf16
96-
build-tool: cmake
97-
mode: portable
98-
- dtype: bf16
99-
build-tool: buck2
10092
mode: portable
10193
- dtype: bf16
102-
build-tool: cmake
103-
mode: custom
104-
- dtype: bf16
105-
build-tool: buck2
10694
mode: custom
10795
fail-fast: false
10896
with:
@@ -117,11 +105,11 @@ jobs:
117105
conda activate "${CONDA_ENV}"
118106
119107
DTYPE=${{ matrix.dtype }}
120-
BUILD_TOOL=${{ matrix.build-tool }}
108+
BUILD_TOOL="cmake"
121109
MODE=${{ matrix.mode }}
122110
123111
# Setup executorch
124-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
112+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
125113
# Install requirements for export_llama
126114
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
127115
# Test llama2
@@ -131,9 +119,6 @@ jobs:
131119
name: test-llama-runner-linux-android
132120
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
133121
strategy:
134-
matrix:
135-
include:
136-
- build-tool: cmake
137122
fail-fast: false
138123
with:
139124
runner: linux.2xlarge
@@ -146,18 +131,14 @@ jobs:
146131
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
147132
conda activate "${CONDA_ENV}"
148133
149-
BUILD_TOOL=${{ matrix.build-tool }}
134+
BUILD_TOOL="cmake"
150135
PYTHON_EXECUTABLE=python \
151136
bash .ci/scripts/build_llama_android.sh "${BUILD_TOOL}"
152137
153138
test-custom-ops-linux:
154139
name: test-custom-ops-linux
155140
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
156141
strategy:
157-
matrix:
158-
include:
159-
- build-tool: buck2
160-
- build-tool: cmake
161142
fail-fast: false
162143
with:
163144
runner: linux.2xlarge
@@ -170,7 +151,7 @@ jobs:
170151
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
171152
conda activate "${CONDA_ENV}"
172153
173-
BUILD_TOOL=${{ matrix.build-tool }}
154+
BUILD_TOOL="cmake"
174155
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
175156
# Test custom ops
176157
PYTHON_EXECUTABLE=python bash examples/portable/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
@@ -179,10 +160,6 @@ jobs:
179160
name: test-selective-build-linux
180161
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
181162
strategy:
182-
matrix:
183-
include:
184-
- build-tool: buck2
185-
- build-tool: cmake
186163
fail-fast: false
187164
with:
188165
runner: linux.2xlarge
@@ -195,7 +172,7 @@ jobs:
195172
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
196173
conda activate "${CONDA_ENV}"
197174
198-
BUILD_TOOL=${{ matrix.build-tool }}
175+
BUILD_TOOL="cmake"
199176
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
200177
# Test selective build
201178
PYTHON_EXECUTABLE=python bash examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
@@ -235,9 +212,6 @@ jobs:
235212
name: test-quantized-aot-lib-linux
236213
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
237214
strategy:
238-
matrix:
239-
include:
240-
- build-tool: cmake
241215
fail-fast: false
242216
with:
243217
runner: linux.2xlarge
@@ -250,17 +224,14 @@ jobs:
250224
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
251225
conda activate "${CONDA_ENV}"
252226
253-
BUILD_TOOL=${{ matrix.build-tool }}
227+
BUILD_TOOL="cmake"
254228
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
255229
PYTHON_EXECUTABLE=python bash examples/xnnpack/quantization/test_quantize.sh "${BUILD_TOOL}" mv2
256230
257231
test-pybind-build-linux:
258232
name: test-pybind-build-linux
259233
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
260234
strategy:
261-
matrix:
262-
include:
263-
- build-tool: cmake
264235
fail-fast: false
265236
with:
266237
runner: linux.2xlarge
@@ -274,7 +245,7 @@ jobs:
274245
conda activate "${CONDA_ENV}"
275246
276247
# build module for executorch.extension.pybindings.portable_lib
277-
BUILD_TOOL=${{ matrix.build-tool }}
248+
BUILD_TOOL="cmake"
278249
PYTHON_EXECUTABLE=python \
279250
EXECUTORCH_BUILD_XNNPACK=ON \
280251
EXECUTORCH_BUILD_PYBIND=ON \
@@ -357,10 +328,6 @@ jobs:
357328

358329
unittest-arm:
359330
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
360-
strategy:
361-
matrix:
362-
include:
363-
- build-tool: buck2
364331
with:
365332
runner: linux.2xlarge
366333
docker-image: executorch-ubuntu-22.04-arm-sdk
@@ -374,7 +341,7 @@ jobs:
374341
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
375342
conda activate "${CONDA_ENV}"
376343
377-
BUILD_TOOL=${{ matrix.build-tool }}
344+
BUILD_TOOL="cmake"
378345
379346
# Setup MacOS dependencies as there is no Docker support on MacOS atm
380347
PYTHON_EXECUTABLE=python \
@@ -396,7 +363,6 @@ jobs:
396363
strategy:
397364
matrix:
398365
dtype: [fp32]
399-
build-tool: [cmake]
400366
mode: [qnn]
401367
fail-fast: false
402368
with:
@@ -411,14 +377,14 @@ jobs:
411377
conda activate "${CONDA_ENV}"
412378
413379
DTYPE=${{ matrix.dtype }}
414-
BUILD_TOOL=${{ matrix.build-tool }}
380+
BUILD_TOOL="cmake"
415381
MODE=${{ matrix.mode }}
416382
417383
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
418384
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
419385
420386
# Setup executorch
421-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
387+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
422388
# Install requirements for export_llama
423389
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
424390
# Test llama2

backends/arm/arm_partitioner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def is_node_supported(self, submodules, node: torch.fx.Node) -> bool:
6262
exir_ops.edge.aten.relu.default,
6363
exir_ops.edge.aten.rsqrt.default,
6464
exir_ops.edge.aten._softmax.default,
65+
exir_ops.edge.aten.select_copy.int,
6566
exir_ops.edge.aten._log_softmax.default,
6667
exir_ops.edge.aten.slice_copy.Tensor,
6768
exir_ops.edge.aten.sub.Tensor,

backends/arm/operators/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
op_relu,
2929
op_repeat,
3030
op_rsqrt,
31+
op_select,
3132
op_sigmoid,
3233
op_slice,
3334
op_squeeze,
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Copyright 2024 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 typing import List
7+
8+
import serializer.tosa_serializer as ts
9+
from executorch.backends.arm.operators.node_visitor import (
10+
NodeVisitor,
11+
register_node_visitor,
12+
)
13+
14+
from executorch.backends.arm.tosa_mapping import TosaArg
15+
16+
from executorch.backends.arm.tosa_utils import build_reshape, tosa_shape
17+
from serializer.tosa_serializer import TosaOp
18+
from torch.fx import Node
19+
20+
21+
@register_node_visitor
22+
class SelectVisitor(NodeVisitor):
23+
target = "aten.select_copy.int"
24+
25+
def __init__(self, *args):
26+
super().__init__(*args)
27+
28+
def define_node(
29+
self,
30+
node: Node,
31+
tosa_graph: ts.TosaSerializer,
32+
inputs: List[TosaArg],
33+
output: TosaArg,
34+
is_quant_node: bool,
35+
) -> None:
36+
37+
assert len(inputs) == 3
38+
input_node, dim, index = inputs
39+
shape = input_node.shape
40+
rank = len(shape)
41+
42+
dim = dim.number % rank if dim.number < 0 else dim.number
43+
index = index.number % rank if index.number < 0 else index.number
44+
45+
# For aten.select_copy, the output will be rank[input_shape - 1]
46+
# For TOSA rank(in) == rank(out).
47+
# Add an intermediate with the same rank
48+
expanded_shape = tuple(1 if i == dim else shape[i] for i in range(rank))
49+
expanded_shape = tosa_shape(expanded_shape, input_node.dim_order)
50+
51+
output_reshaped = tosa_graph.addIntermediate(
52+
expanded_shape, ts.DType.INT8 if is_quant_node else output.dtype
53+
)
54+
55+
attr_slice = ts.TosaSerializerAttribute()
56+
57+
start_attr = [index if i == dim else 0 for i in input_node.dim_order]
58+
size_attr = [
59+
1 if i == dim else input_node.shape[i] for i in input_node.dim_order
60+
]
61+
62+
attr_slice.SliceAttribute(start_attr, size_attr)
63+
64+
tosa_graph.addOperator(
65+
TosaOp.Op().SLICE, [input_node.name], [output_reshaped.name], attr_slice
66+
)
67+
68+
# Reshape back to original rank of output.
69+
build_reshape(tosa_graph, output_reshaped.name, output.shape, output.name)

backends/arm/quantizer/quantization_annotation/generic_annotator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
# torch.ops.aten.view_as_real.default,
3535
# torch.ops.aten.view_as_real_copy.default,
3636
torch.ops.aten.view_copy.default,
37+
torch.ops.aten.select.int,
38+
torch.ops.aten.select_copy.int,
3739
torch.ops.aten.slice.Tensor,
3840
torch.ops.aten.slice_copy.Tensor,
3941
# 'concat' should be handled separately as it has a sequence of inputs and

0 commit comments

Comments
 (0)