Skip to content

Commit ee30789

Browse files
authored
Merge branch 'pytorch:main' into Arm-backend-Make-memory-pool-sizes-configrable-from-cmake
2 parents ea80024 + 13408b9 commit ee30789

File tree

4 files changed

+78
-52
lines changed

4 files changed

+78
-52
lines changed

backends/arm/test/ops/test_sigmoid.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,32 @@ def test_sigmoid_tosa_MI(
152152
def test_sigmoid_tosa_BI(self, test_name: str, test_data: torch.Tensor):
153153
self._test_sigmoid_tosa_BI_pipeline(self.Sigmoid(), (test_data,))
154154

155+
def test_add_sigmoid_tosa_MI(self):
156+
self._test_sigmoid_tosa_MI_pipeline(self.AddSigmoid(), (test_data_suite[0][1],))
157+
158+
@unittest.skip(
159+
reason="Started to fails when PyTorch 2.5->2.6 https://github.com/pytorch/executorch/issues/5832"
160+
)
155161
def test_add_sigmoid_tosa_BI(self):
156162
self._test_sigmoid_tosa_BI_pipeline(self.AddSigmoid(), (test_data_suite[0][1],))
157163

164+
def test_sigmoid_add_tosa_MI(self):
165+
self._test_sigmoid_tosa_MI_pipeline(self.SigmoidAdd(), (test_data_suite[0][1],))
166+
167+
@unittest.skip(
168+
reason="Started to fails when PyTorch 2.5->2.6 https://github.com/pytorch/executorch/issues/5832"
169+
)
158170
def test_sigmoid_add_tosa_BI(self):
159171
self._test_sigmoid_tosa_BI_pipeline(self.SigmoidAdd(), (test_data_suite[0][1],))
160172

173+
def test_sigmoid_add_sigmoid_tosa_MI(self):
174+
self._test_sigmoid_tosa_MI_pipeline(
175+
self.SigmoidAddSigmoid(), (test_data_suite[4][1], test_data_suite[3][1])
176+
)
177+
178+
@unittest.skip(
179+
reason="Started to fails when PyTorch 2.5->2.6 https://github.com/pytorch/executorch/issues/5832"
180+
)
161181
def test_sigmoid_add_sigmoid_tosa_BI(self):
162182
self._test_sigmoid_tosa_BI_pipeline(
163183
self.SigmoidAddSigmoid(), (test_data_suite[4][1], test_data_suite[3][1])

build/Utils.cmake

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,14 @@ function(resolve_buck2)
247247
OUTPUT_VARIABLE resolve_buck2_output
248248
ERROR_VARIABLE resolve_buck2_error
249249
RESULT_VARIABLE resolve_buck2_exit_code
250-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
250+
WORKING_DIRECTORY ${executorch_root}
251251
OUTPUT_STRIP_TRAILING_WHITESPACE
252252
)
253253

254+
# $BUCK2 is a copy of the var from the parent scope. This block will set
255+
# $buck2 to the value we want to return.
254256
if(resolve_buck2_exit_code EQUAL 0)
255-
set(BUCK2
256-
${resolve_buck2_output}
257-
PARENT_SCOPE
258-
)
257+
set(buck2 ${resolve_buck2_output})
259258
message(STATUS "Resolved buck2 as ${resolve_buck2_output}.")
260259
elseif(resolve_buck2_exit_code EQUAL 2)
261260
# Wrong buck version used. Stop here to ensure that the user sees the error.
@@ -266,17 +265,22 @@ function(resolve_buck2)
266265
message(WARNING "${resolve_buck2_error}")
267266

268267
if("${BUCK2}" STREQUAL "")
269-
set(BUCK2
270-
"buck2"
271-
PARENT_SCOPE
272-
)
268+
set(buck2 "buck2")
273269
endif()
274270
endif()
275271

272+
# Update the var in the parent scope. Note that this does not modify our
273+
# local $BUCK2 value.
274+
set(BUCK2 "${buck2}" PARENT_SCOPE)
275+
276276
# The buck2 daemon can get stuck. Killing it can help.
277277
message(STATUS "Killing buck2 daemon")
278278
execute_process(
279-
COMMAND "${BUCK2} kill" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
279+
# Note that we need to use the local buck2 variable. BUCK2 is only set in
280+
# the parent scope, and can still be empty in this scope.
281+
COMMAND "${buck2} kill"
282+
WORKING_DIRECTORY ${executorch_root}
283+
COMMAND_ECHO STDOUT
280284
)
281285
endfunction()
282286

extension/apple/Benchmark/Tests/GenericTests.mm

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,62 +35,62 @@ @implementation GenericTests
3535
}
3636

3737
+ (NSDictionary<NSString *, BOOL (^)(NSString *)> *)predicates {
38-
return @{
39-
@"model" : ^BOOL(NSString *filename){
38+
return @{@"model" : ^BOOL(NSString *filename){
4039
return [filename hasSuffix:@".pte"];
41-
}
42-
};
40+
}
41+
}
42+
;
4343
}
4444

4545
+ (NSDictionary<NSString *, void (^)(XCTestCase *)> *)dynamicTestsForResources:
4646
(NSDictionary<NSString *, NSString *> *)resources {
4747
NSString *modelPath = resources[@"model"];
48-
return @{
49-
@"load" : ^(XCTestCase *testCase){
48+
return @{@"load" : ^(XCTestCase *testCase){
5049
[testCase
5150
measureWithMetrics:@[ [XCTClockMetric new], [XCTMemoryMetric new] ]
5251
block:^{
5352
XCTAssertEqual(
5453
Module(modelPath.UTF8String).load_forward(),
5554
Error::Ok);
5655
}];
57-
},
58-
@"forward" : ^(XCTestCase *testCase) {
59-
auto __block module = std::make_unique<Module>(modelPath.UTF8String);
60-
61-
const auto method_meta = module->method_meta("forward");
62-
ASSERT_OK_OR_RETURN(method_meta);
63-
64-
const auto num_inputs = method_meta->num_inputs();
65-
XCTAssertGreaterThan(num_inputs, 0);
66-
67-
std::vector<TensorPtr> tensors;
68-
tensors.reserve(num_inputs);
69-
70-
for (auto index = 0; index < num_inputs; ++index) {
71-
const auto input_tag = method_meta->input_tag(index);
72-
ASSERT_OK_OR_RETURN(input_tag);
73-
74-
switch (*input_tag) {
75-
case Tag::Tensor: {
76-
const auto tensor_meta = method_meta->input_tensor_meta(index);
77-
ASSERT_OK_OR_RETURN(tensor_meta);
78-
79-
const auto sizes = tensor_meta->sizes();
80-
tensors.emplace_back(
81-
ones({sizes.begin(), sizes.end()}, tensor_meta->scalar_type()));
82-
XCTAssertEqual(module->set_input(tensors.back(), index), Error::Ok);
83-
} break;
84-
default:
85-
XCTFail("Unsupported tag %i at input %d", *input_tag, index);
86-
}
87-
}
88-
[testCase measureWithMetrics:@[ [XCTClockMetric new], [XCTMemoryMetric new] ]
89-
block:^{
90-
XCTAssertEqual(module->forward().error(), Error::Ok);
91-
}];
56+
}
57+
, @"forward" : ^(XCTestCase *testCase) {
58+
auto __block module = std::make_unique<Module>(modelPath.UTF8String);
59+
60+
const auto method_meta = module->method_meta("forward");
61+
ASSERT_OK_OR_RETURN(method_meta);
62+
63+
const auto num_inputs = method_meta->num_inputs();
64+
XCTAssertGreaterThan(num_inputs, 0);
65+
66+
std::vector<TensorPtr> tensors;
67+
tensors.reserve(num_inputs);
68+
69+
for (auto index = 0; index < num_inputs; ++index) {
70+
const auto input_tag = method_meta->input_tag(index);
71+
ASSERT_OK_OR_RETURN(input_tag);
72+
73+
switch (*input_tag) {
74+
case Tag::Tensor: {
75+
const auto tensor_meta = method_meta->input_tensor_meta(index);
76+
ASSERT_OK_OR_RETURN(tensor_meta);
77+
78+
const auto sizes = tensor_meta->sizes();
79+
tensors.emplace_back(
80+
ones({sizes.begin(), sizes.end()}, tensor_meta->scalar_type()));
81+
XCTAssertEqual(module->set_input(tensors.back(), index), Error::Ok);
82+
} break;
83+
default:
84+
XCTFail("Unsupported tag %i at input %d", *input_tag, index);
9285
}
93-
};
86+
}
87+
[testCase measureWithMetrics:@[ [XCTClockMetric new], [XCTMemoryMetric new] ]
88+
block:^{
89+
XCTAssertEqual(module->forward().error(), Error::Ok);
90+
}];
91+
}
92+
}
93+
;
9494
}
9595

9696
@end

runtime/core/exec_aten/exec_aten.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ using IntArrayRef = at::IntArrayRef;
8787

8888
template <typename T>
8989
using OptionalArrayRef = c10::OptionalArrayRef<T>;
90+
using OptionalIntArrayRef = OptionalArrayRef<int64_t>;
9091

9192
inline ssize_t compute_numel(const SizesType* sizes, ssize_t dim) {
9293
return static_cast<ssize_t>(
@@ -132,6 +133,7 @@ using IntArrayRef = torch::executor::IntArrayRef;
132133
template <typename T>
133134
using OptionalArrayRef =
134135
torch::executor::optional<torch::executor::ArrayRef<T>>;
136+
using OptionalIntArrayRef = OptionalArrayRef<int64_t>;
135137

136138
using torch::executor::compute_numel;
137139

0 commit comments

Comments
 (0)