Skip to content

Commit 1bf0d04

Browse files
Merge branch 'main' into dev/refactor_unittests
2 parents 9145769 + 4796da7 commit 1bf0d04

31 files changed

+1621
-723
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
23
# All rights reserved.
34
#
45
# This source code is licensed under the BSD-style license found in the
@@ -819,6 +820,14 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
819820
list(APPEND _executor_runner_libs quantized_ops_lib)
820821
endif()
821822

823+
if(EXECUTORCH_ENABLE_EVENT_TRACER)
824+
if(EXECUTORCH_BUILD_DEVTOOLS)
825+
list(APPEND _executor_runner_libs etdump flatccrt)
826+
else()
827+
message(SEND_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.")
828+
endif()
829+
endif()
830+
822831
add_executable(executor_runner ${_executor_runner__srcs})
823832
if(CMAKE_BUILD_TYPE STREQUAL "Release")
824833
if(APPLE)

backends/arm/_passes/fold_qdq_with_annotated_qparams_pass.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,6 @@ def fold_and_annotate_arg(
105105
for arg in arg_list:
106106
if not isinstance(arg, Node):
107107
return
108-
"""
109-
Make sure arg has requires_grad set to False
110-
For parameters that are not quantized, sometimes (i.e. convolution)
111-
the Parameter(FakeTensor(...)) has requires_grad set to True, which
112-
causes the retracing of the graph to fail with:
113-
114-
E RuntimeError: isDifferentiableType(variable.scalar_type()) INTERNAL ASSERT FAILED at "/Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/autograd/functions/utils.h":74, please report a bug to PyTorch.
115-
E
116-
E While executing %aten_convolution_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.convolution.default](args = (%quantized_decomposed_quantize_per_tensor_default, %b__frozen_param0, %p__param_constant1, [1, 1], [0, 0], [1, 1], False, [0, 0], 1), kwargs = {})
117-
E Original traceback:
118-
E File "/Users/perast01/src/executorch/backends/arm/test/ops/test_conv2d.py", line 110, in forward
119-
E x = conv(x)
120-
"""
121-
if arg.op == "placeholder":
122-
arg.meta["val"].requires_grad = False
123108

124109
arg_quant_params = None
125110
if arg.target == dq_op:

backends/arm/test/ops/test_cat.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2-
# Copyright 2024 Arm Limited and/or its affiliates.
2+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
33
# All rights reserved.
44
#
55
# This source code is licensed under the BSD-style license found in the
@@ -33,6 +33,8 @@ class Cat(torch.nn.Module):
3333
),
3434
-1,
3535
),
36+
((torch.randn(1, 2, 4, 4), torch.randn(1, 2, 4, 1)), 3),
37+
((torch.randn(1, 2, 4, 4), torch.randn(1, 2, 4, 4)), 0),
3638
((torch.randn(2, 2, 4, 4), torch.randn(2, 2, 4, 1)), 3),
3739
(
3840
(
@@ -47,8 +49,8 @@ class Cat(torch.nn.Module):
4749
def __init__(self):
4850
super().__init__()
4951

50-
def forward(self, tensors: tuple[torch.Tensor, ...], dim: int) -> torch.Tensor:
51-
return torch.cat(tensors, dim=dim)
52+
def forward(self, t: tuple[torch.Tensor, ...], dim: int) -> torch.Tensor:
53+
return torch.cat(t, dim=dim)
5254

5355
def _test_cat_tosa_MI_pipeline(
5456
self, module: torch.nn.Module, test_data: Tuple[tuple[torch.Tensor, ...], int]
@@ -134,22 +136,38 @@ def test_cat_tosa_BI(self, operands: tuple[torch.Tensor, ...], dim: int):
134136
test_data = (operands, dim)
135137
self._test_cat_tosa_BI_pipeline(self.Cat(), test_data)
136138

137-
# Mismatch in provided number of inputs and model signature, MLETORCH 519
138-
@parameterized.expand(Cat.test_parameters)
139+
@parameterized.expand(Cat.test_parameters[:-3])
139140
@pytest.mark.corstone_fvp
140-
@conftest.expectedFailureOnFVP
141141
def test_cat_u55_BI(self, operands: tuple[torch.Tensor, ...], dim: int):
142142
test_data = (operands, dim)
143143
self._test_cat_ethosu_BI_pipeline(
144144
self.Cat(), common.get_u55_compile_spec(), test_data
145145
)
146146

147-
# Mismatch in provided number of inputs and model signature, MLETORCH 519
148-
@parameterized.expand(Cat.test_parameters)
147+
# MLETORCH-630 Cat does not work on FVP with batch>1
148+
@parameterized.expand(Cat.test_parameters[-3:])
149149
@pytest.mark.corstone_fvp
150150
@conftest.expectedFailureOnFVP
151+
def test_cat_u55_BI_xfails(self, operands: tuple[torch.Tensor, ...], dim: int):
152+
test_data = (operands, dim)
153+
self._test_cat_ethosu_BI_pipeline(
154+
self.Cat(), common.get_u55_compile_spec(), test_data
155+
)
156+
157+
@parameterized.expand(Cat.test_parameters[:-3])
158+
@pytest.mark.corstone_fvp
151159
def test_cat_u85_BI(self, operands: tuple[torch.Tensor, ...], dim: int):
152160
test_data = (operands, dim)
153161
self._test_cat_ethosu_BI_pipeline(
154162
self.Cat(), common.get_u85_compile_spec(), test_data
155163
)
164+
165+
# MLETORCH-630 Cat does not work on FVP with batch>1
166+
@parameterized.expand(Cat.test_parameters[-3:])
167+
@pytest.mark.corstone_fvp
168+
@conftest.expectedFailureOnFVP
169+
def test_cat_u85_BI_xfails(self, operands: tuple[torch.Tensor, ...], dim: int):
170+
test_data = (operands, dim)
171+
self._test_cat_ethosu_BI_pipeline(
172+
self.Cat(), common.get_u85_compile_spec(), test_data
173+
)

backends/arm/test/ops/test_expand.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ class Expand(torch.nn.Module):
3737
test_parameters = [
3838
(torch.rand(1), (2,)),
3939
(torch.randn(1, 4), (1, -1)),
40-
(torch.rand(1, 1, 2, 2), (4, 3, -1, 2)),
4140
(torch.randn(1), (2, 2, 4)),
42-
(torch.rand(3, 2, 4, 1), (-1, -1, -1, 3)),
41+
(torch.randn(1, 1, 1, 5), (1, 4, -1, -1)),
4342
(torch.randn(1, 1, 192), (1, -1, -1)),
43+
(torch.randn(1, 1), (1, 2, 2, 4)),
44+
(torch.randn(1, 1), (2, 2, 2, 4)),
4445
(torch.randn(10, 1, 1, 97), (-1, 4, -1, -1)),
46+
(torch.rand(1, 1, 2, 2), (4, 3, -1, 2)),
4547
]
4648

47-
def forward(self, x: torch.Tensor, multiples: Sequence):
48-
return x.expand(multiples)
49+
def forward(self, x: torch.Tensor, m: Sequence):
50+
return x.expand(m)
4951

5052
def _test_expand_tosa_MI_pipeline(self, module: torch.nn.Module, test_data: Tuple):
5153
(
@@ -113,20 +115,34 @@ def test_expand_tosa_MI(self, test_input, multiples):
113115
def test_expand_tosa_BI(self, test_input, multiples):
114116
self._test_expand_tosa_BI_pipeline(self.Expand(), (test_input, multiples))
115117

116-
# Mismatch in provided number of inputs and model signature, MLETORCH 519
117-
@parameterized.expand(Expand.test_parameters)
118+
@parameterized.expand(Expand.test_parameters[:-3])
118119
@pytest.mark.corstone_fvp
119-
@conftest.expectedFailureOnFVP
120120
def test_expand_u55_BI(self, test_input, multiples):
121121
self._test_expand_ethosu_BI_pipeline(
122122
common.get_u55_compile_spec(), self.Expand(), (test_input, multiples)
123123
)
124124

125-
# Mismatch in provided number of inputs and model signature, MLETORCH 519
126-
@parameterized.expand(Expand.test_parameters)
125+
# MLETORCH-629: Expand does not work on FVP with batch>1
126+
@parameterized.expand(Expand.test_parameters[-3:])
127127
@pytest.mark.corstone_fvp
128128
@conftest.expectedFailureOnFVP
129+
def test_expand_u55_BI_xfails(self, test_input, multiples):
130+
self._test_expand_ethosu_BI_pipeline(
131+
common.get_u55_compile_spec(), self.Expand(), (test_input, multiples)
132+
)
133+
134+
@parameterized.expand(Expand.test_parameters[:-3])
135+
@pytest.mark.corstone_fvp
129136
def test_expand_u85_BI(self, test_input, multiples):
130137
self._test_expand_ethosu_BI_pipeline(
131138
common.get_u85_compile_spec(), self.Expand(), (test_input, multiples)
132139
)
140+
141+
# MLETORCH-629: Expand does not work on FVP with batch>1
142+
@parameterized.expand(Expand.test_parameters[-3:])
143+
@pytest.mark.corstone_fvp
144+
@conftest.expectedFailureOnFVP
145+
def test_expand_u85_BI_xfails(self, test_input, multiples):
146+
self._test_expand_ethosu_BI_pipeline(
147+
common.get_u85_compile_spec(), self.Expand(), (test_input, multiples)
148+
)

backends/arm/test/ops/test_full.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,16 @@ def test_full_tosa_MI(self, test_tensor: Tuple):
143143
def test_full_tosa_BI(self, test_tensor: Tuple):
144144
self._test_full_tosa_BI_pipeline(self.AddVariableFull(), test_tensor)
145145

146-
# Mismatch in provided number of inputs and model signature, MLETORCH 519
147146
@parameterized.expand(AddVariableFull.test_parameters)
148147
@pytest.mark.corstone_fvp
149-
@conftest.expectedFailureOnFVP
150148
def test_full_u55_BI(self, test_tensor: Tuple):
151149
self._test_full_tosa_u55_pipeline(
152150
self.AddVariableFull(),
153151
test_tensor,
154152
)
155153

156-
# Mismatch in provided number of inputs and model signature, MLETORCH 519
157154
@parameterized.expand(AddVariableFull.test_parameters)
158155
@pytest.mark.corstone_fvp
159-
@conftest.expectedFailureOnFVP
160156
def test_full_u85_BI(self, test_tensor: Tuple):
161157
self._test_full_tosa_u85_pipeline(
162158
self.AddVariableFull(),

backends/arm/test/runner_utils.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,7 @@ def get_input_names(program: ExportedProgram) -> list[str]:
6565
Returns:
6666
A list of strings with the names of the model input.
6767
"""
68-
input_names = []
69-
70-
# E.g. bias and weights are 'placeholders' as well. This is used to
71-
# get only the use inputs.
72-
usr_inputs = program.graph_signature.user_inputs
73-
for node in program.graph.nodes:
74-
if node.op == "placeholder" and node.name in usr_inputs:
75-
input_names.append(node.name)
76-
77-
return input_names
68+
return [spec.arg.name for spec in program.graph_signature.input_specs]
7869

7970

8071
def get_input_quantization_params(
@@ -334,13 +325,16 @@ def run_corstone(
334325

335326

336327
def prep_data_for_save(
337-
data: torch.Tensor,
328+
data,
338329
input_name: str,
339330
quant_param: Optional[QuantizationParams] = None,
340331
):
341-
data_np = np.array(data.detach(), order="C").astype(
342-
torch_to_numpy_dtype_dict[data.dtype]
343-
)
332+
if isinstance(data, torch.Tensor):
333+
data_np = np.array(data.detach(), order="C").astype(
334+
torch_to_numpy_dtype_dict[data.dtype]
335+
)
336+
else:
337+
data_np = np.array(data)
344338
if quant_param is not None:
345339
assert quant_param.node_name in input_name, (
346340
f"The quantization params name '{quant_param.node_name}' does not "

backends/qualcomm/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) Qualcomm Innovation Center, Inc.
2+
# Copyright 2025 Arm Limited and/or its affiliates.
23
# All rights reserved
34
#
45
# This source code is licensed under the BSD-style license found in the
@@ -199,11 +200,6 @@ target_link_libraries(
199200
#
200201
target_link_options_shared_lib(qnn_executorch_backend)
201202

202-
#
203-
# add compile option
204-
#
205-
target_compile_options(executorch PUBLIC -DET_EVENT_TRACER_ENABLED)
206-
207203
#
208204
# add sources
209205
#

backends/qualcomm/runtime/QnnManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ Error QnnManager::RegisterMem(
154154
const std::shared_ptr<TensorWrapper>& tensor_wrapper) {
155155
SharedBuffer& shared_buffer_manager = SharedBuffer::GetSharedBufferManager();
156156
// Not enable shared buffer
157-
if (!options_->shared_buffer())
157+
if (!options_->shared_buffer()) {
158158
return Error::Internal;
159+
}
159160

160161
if (backend_params_ptr_->qnn_mem_manager_ptr_ == nullptr) {
161162
QNN_EXECUTORCH_LOG_WARN(

backends/qualcomm/runtime/QnnManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class QnnManager {
145145
{Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_8,
146146
executorch::aten::ScalarType::Byte},
147147
{Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_16,
148-
executorch::aten::ScalarType::Bits16},
148+
executorch::aten::ScalarType::UInt16},
149149
};
150150
};
151151
} // namespace qnn

backends/qualcomm/runtime/backends/QnnMemManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class QnnMemManager {
7777
Qnn_DataType_t::QNN_DATATYPE_SFIXED_POINT_16},
7878
{executorch::aten::ScalarType::Byte,
7979
Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_8},
80-
{executorch::aten::ScalarType::Bits16,
80+
{executorch::aten::ScalarType::UInt16,
8181
Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_16},
8282
};
8383
};

0 commit comments

Comments
 (0)