Skip to content

Commit c480e1e

Browse files
authored
Merge branch 'main' into gh/jackzhxng/12/orig
2 parents c638c09 + 77f16dc commit c480e1e

File tree

157 files changed

+7334
-1612
lines changed

Some content is hidden

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

157 files changed

+7334
-1612
lines changed

.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

.lintrunner.toml

Lines changed: 4 additions & 0 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.

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,6 @@ endif()
430430

431431
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations)
432432

433-
#
434-
# gflags: Commandline flag host library.
435-
#
436-
437-
if(EXECUTORCH_BUILD_GFLAGS)
438-
add_subdirectory(third-party/gflags)
439-
endif()
440-
441433
# Install `executorch` library as well as `executorch-config.cmake` under
442434
# ${CMAKE_INSTALL_PREFIX}/
443435
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/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/quantizer/quantization_annotator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,12 @@ def _match_pattern(
221221
torch.ops.aten.squeeze_copy.dim,
222222
torch.ops.aten.squeeze.dim,
223223
torch.ops.aten.squeeze.dims,
224+
torch.ops.aten.unbind.int,
224225
torch.ops.aten.unsqueeze.default,
225226
torch.ops.aten.unsqueeze_copy.default,
226227
torch.ops.aten.reshape.default,
227228
torch.ops.aten.repeat.default,
229+
torch.ops.aten.repeat_interleave.self_int,
228230
torch.ops.aten.expand_copy.default,
229231
torch.ops.aten.expand.default,
230232
# Disabling these as there seems to be an issue with support for complex
@@ -256,6 +258,7 @@ def _match_pattern(
256258
torch.ops.aten.amin.default,
257259
torch.ops.aten.clamp.default,
258260
torch.ops.aten.clamp.Tensor,
261+
torch.ops.aten.unflatten.int,
259262
]
260263

261264
_one_to_one_shared_input_or_input_act_qspec = [
@@ -271,6 +274,7 @@ def _match_pattern(
271274
torch.ops.aten.avg_pool2d.default,
272275
torch.ops.aten.max_pool2d.default,
273276
torch.ops.aten.full.default,
277+
torch.ops.aten.full,
274278
torch.ops.aten.flatten.using_ints,
275279
torch.ops.aten.dropout.default,
276280
torch.ops.aten.dropout_.default,
@@ -539,6 +543,7 @@ def annotate_graph( # type: ignore[return]
539543
if node.target in [
540544
torch.ops.aten.full_like.default,
541545
torch.ops.aten.full.default,
546+
torch.ops.aten.full,
542547
torch.ops.aten.scalar_tensor.default,
543548
]:
544549
node.kwargs = {}

backends/arm/runtime/EthosUBackend.cpp

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,24 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
261261
event_tracer,
262262
"+EthosUBackend::execute()handles.input.permute_CHW_to_HWC()");
263263
// permuted byte copy CHW to HWC
264+
int c, h, w;
265+
if (tensor_in.dim() == 4) {
266+
c = tensor_in.size(1);
267+
h = tensor_in.size(2);
268+
w = tensor_in.size(3);
269+
} else if (tensor_in.dim() == 5) {
270+
c = tensor_in.size(2);
271+
h = tensor_in.size(3);
272+
w = tensor_in.size(4);
273+
} else {
274+
ET_LOG(
275+
Error,
276+
"Unsupported input tensor dimension %d, expected 4 or 5",
277+
tensor_in.dim());
278+
return Error::InvalidProgram;
279+
}
264280
permute_CHW_to_HWC(
265-
tensor_in.mutable_data_ptr<char>(),
266-
scratch_addr,
267-
tensor_in.size(1),
268-
tensor_in.size(2),
269-
tensor_in.size(3));
281+
tensor_in.mutable_data_ptr<char>(), scratch_addr, c, h, w);
270282
} else if (both_char or both_int or both_short) {
271283
EXECUTORCH_PROF_SCOPE(
272284
event_tracer, "+EthosUBackend::execute()handles.input.memcpy()");
@@ -364,12 +376,24 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
364376
"+EthosUBackend::execute()handles.output.permute_HWC_to_CHW()");
365377

366378
char* output_address = (char*)output_addr;
379+
int c, h, w;
380+
if (tensor_out.dim() == 4) {
381+
c = tensor_out.size(1);
382+
h = tensor_out.size(2);
383+
w = tensor_out.size(3);
384+
} else if (tensor_out.dim() == 5) {
385+
c = tensor_out.size(2);
386+
h = tensor_out.size(3);
387+
w = tensor_out.size(4);
388+
} else {
389+
ET_LOG(
390+
Error,
391+
"Unsupported output tensor dimension %d, expected 4 or 5",
392+
tensor_out.dim());
393+
return Error::InvalidProgram;
394+
}
367395
permute_HWC_to_CHW(
368-
output_address,
369-
tensor_out.mutable_data_ptr<char>(),
370-
tensor_out.size(1),
371-
tensor_out.size(2),
372-
tensor_out.size(3));
396+
output_address, tensor_out.mutable_data_ptr<char>(), c, h, w);
373397
} else {
374398
EXECUTORCH_PROF_SCOPE(
375399
event_tracer, "+EthosUBackend::execute()handles.output.move()");
@@ -430,6 +454,14 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
430454
if (permuted_shape) {
431455
ET_LOG(Debug, "Tensor input/output %d will be permuted", index);
432456
}
457+
} else if (tensor.dim() == 5) {
458+
// Same as above, but for 5D tensors.
459+
permuted_shape = tensor.size(0) == io->shape[0] &&
460+
tensor.size(1) == io->shape[1] && tensor.size(2) == io->shape[4] &&
461+
tensor.size(3) == io->shape[2] && tensor.size(4) == io->shape[3];
462+
if (permuted_shape) {
463+
ET_LOG(Debug, "Tensor input/output %d will be permuted", index);
464+
}
433465
}
434466
*is_permuted = permuted_shape;
435467
return Error::Ok;

backends/arm/scripts/parse_test_names.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"bitwise_right_shift.Tensor",
1818
"bitwise_left_shift.Tensor",
1919
"native_group_norm.default",
20+
"unbind.int",
21+
"unflatten.int",
2022
"_native_batch_norm_legit_no_training.default",
2123
"_native_batch_norm_legit.no_stats",
2224
]

backends/arm/test/models/test_deit_tiny_arm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_deit_tiny_tosa_BI():
5252
aten_op=[],
5353
exir_op=[],
5454
use_to_edge_transform_and_lower=True,
55-
atol=2.5, # This needs to go down: MLETORCH-956
55+
atol=1,
5656
qtol=1,
5757
)
5858
pipeline.run()

backends/arm/test/models/test_llama.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,4 @@ def test_llama_tosa_BI():
126126
exir_op=[],
127127
use_to_edge_transform_and_lower=True,
128128
)
129-
pipeline.change_args(
130-
"run_method_and_compare_outputs",
131-
atol=9.9,
132-
rtol=1.5, # TODO: Tolerance needs to be updated after MLETORCH-907
133-
inputs=llama_inputs,
134-
)
135129
pipeline.run()

0 commit comments

Comments
 (0)