Skip to content

Commit 771dcba

Browse files
authored
Merge branch 'main' into export-D75032734
2 parents 8ff2267 + ebda84d commit 771dcba

File tree

18 files changed

+128
-50
lines changed

18 files changed

+128
-50
lines changed

.github/workflows/build-presets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
preset: [macos-arm64, pybind, llm]
23+
preset: [macos, ios, ios-simulator, pybind, llm]
2424
with:
2525
job-name: build
2626
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

CMakePresets.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"binaryDir": "${sourceDir}/cmake-out"
88
},
99
{
10-
"name": "macos-arm64",
11-
"displayName": "Build everything buildable on macOS arm64",
10+
"name": "macos",
11+
"displayName": "Build everything buildable on macOS",
1212
"inherits": ["common"],
1313
"generator": "Xcode",
1414
"cacheVariables": {
1515
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
16-
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake",
16+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos.cmake",
1717
"PLATFORM": "MAC_ARM64",
1818
"DEPLOYMENT_TARGET": "10.15"
1919
},
@@ -23,6 +23,40 @@
2323
"rhs": "Darwin"
2424
}
2525
},
26+
{
27+
"name": "ios",
28+
"displayName": "Build everything buildable on iOS",
29+
"inherits": ["common"],
30+
"generator": "Xcode",
31+
"cacheVariables": {
32+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
33+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake",
34+
"PLATFORM": "OS64",
35+
"DEPLOYMENT_TARGET": "17.0"
36+
},
37+
"condition": {
38+
"lhs": "${hostSystemName}",
39+
"type": "equals",
40+
"rhs": "Darwin"
41+
}
42+
},
43+
{
44+
"name": "ios-simulator",
45+
"displayName": "Build everything buildable on iOS simulator",
46+
"inherits": ["common"],
47+
"generator": "Xcode",
48+
"cacheVariables": {
49+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
50+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake",
51+
"PLATFORM": "SIMULATORARM64",
52+
"DEPLOYMENT_TARGET": "17.0"
53+
},
54+
"condition": {
55+
"lhs": "${hostSystemName}",
56+
"type": "equals",
57+
"rhs": "Darwin"
58+
}
59+
},
2660
{
2761
"name": "pybind",
2862
"displayName": "Build pybindings exported in the wheel",

backends/cadence/aot/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def prepare_and_convert_pt2(
123123
assert isinstance(model_gm, torch.fx.GraphModule)
124124

125125
# Prepare
126-
prepared_model = prepare_pt2e(model_gm, quantizer) # pyre-ignore[6]
126+
prepared_model = prepare_pt2e(model_gm, quantizer)
127127

128128
# Calibrate
129129
# If no calibration data is provided, use the inputs

backends/cadence/aot/remove_ops.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,7 @@ def call_operator(
235235
kwargs: dict[str, Argument],
236236
meta: NodeMetadata,
237237
) -> ProxyValue:
238-
if op not in {
239-
exir_ops.edge.aten.linalg_vector_norm.default,
240-
exir_ops.edge.cadence.linalg_vector_norm.default,
241-
}:
238+
if op is not exir_ops.edge.aten.linalg_vector_norm.default:
242239
return super().call_operator(op, args, kwargs, meta)
243240

244241
# If the op has three args or less, it can't be a nop

backends/cadence/aot/tests/test_remove_ops_passes.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,7 @@ def forward(self, x: torch.Tensor):
467467

468468
# Expect the linalg_vector_norm op to be removed by the pass
469469
self.assertEqual(
470-
count_node(graph_module, exir_ops.edge.aten.linalg_vector_norm.default)
471-
+ count_node(
472-
graph_module, exir_ops.edge.cadence.linalg_vector_norm.default
473-
),
470+
count_node(graph_module, exir_ops.edge.aten.linalg_vector_norm.default),
474471
0,
475472
)
476473

devtools/etdump/etdump_flatcc.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,12 @@ Result<bool> ETDumpGen::log_intermediate_output_delegate_helper(
394394

395395
// Check the type of `output` then call the corresponding logging functions
396396
if constexpr (std::is_same<T, Tensor>::value) {
397-
long offset = write_tensor_or_raise_error(output);
397+
Result<long> offset = write_tensor_or_return_error(output);
398+
ET_CHECK_MSG(
399+
offset.ok(),
400+
"write_tensor_or_return_error() failed to write tensor to debug buffer");
398401
Result<etdump_Tensor_ref_t> tensor_ref =
399-
add_tensor_entry(builder_, output, offset);
402+
add_tensor_entry(builder_, output, offset.get());
400403
if (!tensor_ref.ok()) {
401404
return tensor_ref.error();
402405
}
@@ -408,9 +411,12 @@ Result<bool> ETDumpGen::log_intermediate_output_delegate_helper(
408411
} else if constexpr (std::is_same<T, ArrayRef<Tensor>>::value) {
409412
etdump_Tensor_vec_start(builder_);
410413
for (size_t i = 0; i < output.size(); ++i) {
411-
long offset = write_tensor_or_raise_error(output[i]);
414+
Result<long> offset = write_tensor_or_return_error(output[i]);
415+
ET_CHECK_MSG(
416+
offset.ok(),
417+
"write_tensor_or_return_error() failed to write tensor to debug buffer");
412418
Result<etdump_Tensor_ref_t> tensor_ref =
413-
add_tensor_entry(builder_, output[i], offset);
419+
add_tensor_entry(builder_, output[i], offset.get());
414420
if (!tensor_ref.ok()) {
415421
return tensor_ref.error();
416422
}
@@ -566,9 +572,12 @@ Result<bool> ETDumpGen::log_evalue(
566572
switch (evalue.tag) {
567573
case Tag::Tensor: {
568574
executorch::aten::Tensor tensor = evalue.toTensor();
569-
long offset = write_tensor_or_raise_error(tensor);
575+
Result<long> offset = write_tensor_or_return_error(tensor);
576+
ET_CHECK_MSG(
577+
offset.ok(),
578+
"write_tensor_or_return_error() failed to write tensor to debug buffer");
570579
Result<etdump_Tensor_ref_t> tensor_ref =
571-
add_tensor_entry(builder_, tensor, offset);
580+
add_tensor_entry(builder_, tensor, offset.get());
572581
if (!tensor_ref.ok()) {
573582
return tensor_ref.error();
574583
}
@@ -591,9 +600,12 @@ Result<bool> ETDumpGen::log_evalue(
591600
evalue.toTensorList();
592601
etdump_Tensor_vec_start(builder_);
593602
for (size_t i = 0; i < tensors.size(); ++i) {
594-
long offset = write_tensor_or_raise_error(tensors[i]);
603+
Result<long> offset = write_tensor_or_return_error(tensors[i]);
604+
ET_CHECK_MSG(
605+
offset.ok(),
606+
"write_tensor_or_return_error() failed to write tensor to debug buffer");
595607
Result<etdump_Tensor_ref_t> tensor_ref =
596-
add_tensor_entry(builder_, tensors[i], offset);
608+
add_tensor_entry(builder_, tensors[i], offset.get());
597609
if (!tensor_ref.ok()) {
598610
return tensor_ref.error();
599611
}
@@ -689,7 +701,7 @@ void ETDumpGen::set_delegation_intermediate_output_filter(
689701
filter_ = filter;
690702
}
691703

692-
long ETDumpGen::write_tensor_or_raise_error(Tensor tensor) {
704+
Result<long> ETDumpGen::write_tensor_or_return_error(Tensor tensor) {
693705
// Previously, the function copy_tensor_to_debug_buffer returned 0xFF..F when
694706
// given an empty tensor, which is an invalid offset for most buffers. In our
695707
// data sink, we will return the current debug_buffer_offset for better
@@ -702,14 +714,14 @@ long ETDumpGen::write_tensor_or_raise_error(Tensor tensor) {
702714
return static_cast<size_t>(-1);
703715
}
704716

705-
ET_CHECK_MSG(
706-
data_sink_, "Must set data sink before writing tensor-like data");
717+
if (!data_sink_) {
718+
return Error::InvalidArgument;
719+
}
707720
Result<size_t> ret =
708721
data_sink_->write(tensor.const_data_ptr(), tensor.nbytes());
709-
ET_CHECK_MSG(
710-
ret.ok(),
711-
"Failed to write tensor with error 0x%" PRIx32,
712-
static_cast<uint32_t>(ret.error()));
722+
if (!ret.ok()) {
723+
return ret.error();
724+
}
713725
return static_cast<long>(ret.get());
714726
}
715727

devtools/etdump/etdump_flatcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class ETDumpGen : public ::executorch::runtime::EventTracer {
184184
DelegateDebugIntId delegate_debug_index,
185185
const T& output);
186186

187-
long write_tensor_or_raise_error(executorch::aten::Tensor tensor);
187+
Result<long> write_tensor_or_return_error(executorch::aten::Tensor tensor);
188188

189189
struct flatcc_builder* builder_;
190190
size_t num_blocks_ = 0;

devtools/etdump/tests/etdump_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ProfilerETDumpTest : public ::testing::Test {
7676
ET_EXPECT_DEATH(
7777
gen->log_intermediate_output_delegate(
7878
"test_event_tensor", kUnsetDelegateDebugIntId, tf.ones({3, 2})),
79-
"Must set data sink before writing tensor-like data");
79+
"failed to write tensor to debug buffer");
8080
}
8181

8282
void check_log_with_filter(
@@ -301,7 +301,7 @@ TEST_F(ProfilerETDumpTest, DebugEvent) {
301301
if (j == 0) {
302302
ET_EXPECT_DEATH(
303303
etdump_gen[i]->log_evalue(evalue_tensor),
304-
"Must set data sink before writing tensor-like data");
304+
"failed to write tensor to debug buffer");
305305

306306
// Set debug buffer with span
307307
etdump_gen[i]->set_debug_buffer(buffer);
@@ -315,7 +315,7 @@ TEST_F(ProfilerETDumpTest, DebugEvent) {
315315

316316
ET_EXPECT_DEATH(
317317
etdump_gen[i]->log_evalue(evalue_tensor),
318-
"Must set data sink before writing tensor-like data");
318+
"failed to write tensor to debug buffer");
319319

320320
if (j == 1) {
321321
// Set buffer data sink

examples/xnnpack/quantization/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def quantize(
3333
is_dynamic=is_dynamic,
3434
)
3535
quantizer.set_global(operator_config)
36-
m = prepare_pt2e(model, quantizer) # pyre-ignore[6]
36+
m = prepare_pt2e(model, quantizer)
3737
# calibration
3838
m(*example_inputs)
3939
m = convert_pt2e(m)

extension/llm/export/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def pt2e_quantize(self, quantizers: Optional[List[Quantizer]]) -> "LLMEdgeManage
373373
), "Please run export() first"
374374
m = prepare_pt2e(
375375
self.pre_autograd_graph_module, # pyre-ignore[6]
376-
composed_quantizer, # pyre-ignore[6]
376+
composed_quantizer,
377377
)
378378
logging.info(
379379
f"Calibrating with tasks: {self.calibration_tasks}, limit: {self.calibration_limit}, calibration_data: {self.calibration_data}, tokenizer_path: {self.tokenizer_path}, seq_length: {self.calibration_seq_length}"

kernels/optimized/lib_defs.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def get_vec_deps():
3737
# various ovr_configs are not available in oss
3838
deps = select({
3939
"ovr_config//os:iphoneos-arm64": [
40-
"fbsource//third-party/sleef:sleef_arm",
40+
"fbsource//third-party/sleef:sleef",
4141
] if not runtime.is_oss else [],
4242
"ovr_config//os:macos-arm64": [
43-
"fbsource//third-party/sleef:sleef_arm",
43+
"fbsource//third-party/sleef:sleef",
4444
] if not runtime.is_oss else [],
4545
"ovr_config//os:android-arm64": [
46-
"fbsource//third-party/sleef:sleef_arm",
46+
"fbsource//third-party/sleef:sleef",
4747
] if not runtime.is_oss else [],
4848
"DEFAULT": [],
4949
})
@@ -141,7 +141,7 @@ def define_libs(is_fbcode=False):
141141
(
142142
DEVSERVER_PLATFORM_REGEX,
143143
[
144-
"fbsource//third-party/sleef:sleef_arm",
144+
"fbsource//third-party/sleef:sleef",
145145
],
146146
),
147147
],
@@ -150,7 +150,7 @@ def define_libs(is_fbcode=False):
150150
(
151151
"^android-arm64.*$",
152152
[
153-
"fbsource//third-party/sleef:sleef_arm",
153+
"fbsource//third-party/sleef:sleef",
154154
],
155155
),
156156
],

runtime/core/portable_type/c10/c10/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def define_common_targets():
5757
exported_deps = select({
5858
"DEFAULT": [],
5959
"ovr_config//cpu:arm64": [
60-
"fbsource//third-party/sleef:sleef_arm",
60+
"fbsource//third-party/sleef:sleef",
6161
] if not runtime.is_oss else [],
6262
# fbsource//third-party/sleef:sleef currently fails to
6363
# link with missing symbols, hence the fbcode-specific dep below.

shim_et/xplat/executorch/codegen/codegen.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def build_optimized_lib(name, oplist_header_name, portable_header_lib, feature =
530530
(
531531
"^android-arm64.*$",
532532
[
533-
"fbsource//third-party/sleef:sleef_arm",
533+
"fbsource//third-party/sleef:sleef",
534534
],
535535
),
536536
],
@@ -646,12 +646,12 @@ def executorch_generated_lib(
646646
if not expose_operator_symbols and not is_xplat():
647647
# TODO(T225169282): make this a fail once internal cases move to xplat.
648648
warning("""
649-
Dtype selective build with expose_operator_symbols=False works only in xplat -
649+
Dtype selective build with expose_operator_symbols=False works only in xplat -
650650
there are undefined symbols otherwise. Please try to use xplat, or talk to the
651651
executorch team. Setting expose_operator_symbols=True is not recommended as the
652652
exposed symbols may clash (duplicate symbols errors) if multiple
653653
executorch_generated_libs are included by a parent library.
654-
654+
655655
Falling back to operator selective build.""")
656656

657657
if (not "//executorch/kernels/portable:operators" in kernel_deps) and (not "//executorch/kernels/optimized:optimized_operators" in kernel_deps):

shim_et/xplat/executorch/kernels/optimized/lib_defs.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def get_vec_deps():
4444
"fbsource//third-party/sleef:sleef",
4545
] if not runtime.is_oss else [],
4646
"ovr_config//os:iphoneos": [
47-
"fbsource//third-party/sleef:sleef_arm",
47+
"fbsource//third-party/sleef:sleef",
4848
] if not runtime.is_oss else [],
4949
"ovr_config//os:macos-arm64": [
50-
"fbsource//third-party/sleef:sleef_arm",
50+
"fbsource//third-party/sleef:sleef",
5151
] if not runtime.is_oss else [],
5252
"ovr_config//os:android-arm64": [
53-
"fbsource//third-party/sleef:sleef_arm",
53+
"fbsource//third-party/sleef:sleef",
5454
] if not runtime.is_oss else [],
5555
"DEFAULT": [],
5656
})
@@ -104,7 +104,7 @@ def define_libs():
104104
(
105105
DEVSERVER_PLATFORM_REGEX,
106106
[
107-
"fbsource//third-party/sleef:sleef_arm",
107+
"fbsource//third-party/sleef:sleef",
108108
],
109109
),
110110
],
@@ -113,7 +113,7 @@ def define_libs():
113113
(
114114
"^android-arm64.*$",
115115
[
116-
"fbsource//third-party/sleef:sleef_arm",
116+
"fbsource//third-party/sleef:sleef",
117117
],
118118
),
119119
],

shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def define_op_library(name, compiler_flags, deps):
118118
(
119119
"^android-arm64.*$",
120120
[
121-
"fbsource//third-party/sleef:sleef_arm",
121+
"fbsource//third-party/sleef:sleef",
122122
],
123123
),
124124
],

tools/cmake/preset/apple_common.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
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+
7+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++${CMAKE_CXX_STANDARD}")
8+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
9+
10+
set(
11+
_compiler_flags
12+
"-ffile-prefix-map=${PROJECT_SOURCE_DIR}=/executorch"
13+
"-fdebug-prefix-map=${PROJECT_SOURCE_DIR}=/executorch"
14+
)
15+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_compiler_flags}")
16+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_compiler_flags}")
17+
18+
set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON)
19+
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
20+
set_overridable_option(EXECUTORCH_BUILD_MPS ON)
21+
set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON)
22+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE ON)
23+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
24+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
25+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
26+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
27+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
28+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)

tools/cmake/preset/macos-arm64.cmake renamed to tools/cmake/preset/ios.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
7+
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/apple_common.cmake)

0 commit comments

Comments
 (0)