Skip to content

Commit a6e5e32

Browse files
authored
Merge branch 'main' into gh/trivedivivek/34/orig
2 parents 1366dbd + 2db8c69 commit a6e5e32

Some content is hidden

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

62 files changed

+1925
-701
lines changed

.github/workflows/lint.yml

+6
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ jobs:
2020
with:
2121
runner: linux.2xlarge
2222
docker-image: executorch-ubuntu-22.04-linter
23+
submodules: 'true'
2324
fetch-depth: 0
2425
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
2526
timeout: 90
2627
script: |
2728
# The generic Linux job chooses to use base env, not the one setup by the image
2829
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2930
conda activate "${CONDA_ENV}"
31+
32+
# For mypy linting, we need to first install executorch first so that
33+
# it builds the python package information.
34+
BUILD_TOOL="cmake"
35+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
3036
3137
CACHE_DIRECTORY="/tmp/.lintbin"
3238
# Try to recover the cached binaries

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.hypothesis
22
buck-out/
3+
.mypy_cache/
34
buck2-bin/
45
cmake-out*
56
.DS_Store

.lintrunner.toml

+46
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,49 @@ command = [
285285
'--',
286286
'@{{PATHSFILE}}',
287287
]
288+
289+
[[linter]]
290+
code = 'MYPY'
291+
include_patterns = [
292+
# TODO(https://github.com/pytorch/executorch/issues/7441): Gradually start enabling all folders.
293+
# 'backends/**/*.py',
294+
'build/**/*.py',
295+
'codegen/**/*.py',
296+
# 'devtools/**/*.py',
297+
'docs/**/*.py',
298+
# 'examples/**/*.py',
299+
# 'exir/**/*.py',
300+
# 'extension/**/*.py',
301+
'kernels/**/*.py',
302+
# 'profiler/**/*.py',
303+
'runtime/**/*.py',
304+
'scripts/**/*.py',
305+
# 'test/**/*.py',
306+
# 'util/**/*.py',
307+
'*.py',
308+
]
309+
exclude_patterns = [
310+
'third-party/**',
311+
'**/third-party/**',
312+
'scripts/check_binary_dependencies.py',
313+
]
314+
command = [
315+
'python',
316+
'-m',
317+
'lintrunner_adapters',
318+
'run',
319+
'mypy_linter',
320+
'--config=.mypy.ini',
321+
'--show-disable',
322+
'--',
323+
'@{{PATHSFILE}}'
324+
]
325+
init_command = [
326+
'python',
327+
'-m',
328+
'lintrunner_adapters',
329+
'run',
330+
'pip_init',
331+
'--dry-run={{DRYRUN}}',
332+
'--requirement=requirements-lintrunner.txt',
333+
]

.mypy.ini

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[mypy]
2+
allow_redefinition = True
3+
warn_unused_configs = True
4+
warn_redundant_casts = True
5+
show_error_codes = True
6+
show_column_numbers = True
7+
disallow_untyped_decorators = True
8+
follow_imports = normal
9+
local_partial_types = True
10+
enable_error_code = possibly-undefined
11+
warn_unused_ignores = False
12+
13+
files =
14+
backends,
15+
codegen,
16+
devtools
17+
examples,
18+
exir,
19+
extension,
20+
kernels,
21+
profiler,
22+
runtime,
23+
scripts,
24+
util
25+
26+
mypy_path = executorch
27+
28+
[mypy-executorch.codegen.*]
29+
follow_untyped_imports = True
30+
31+
[mypy-executorch.devtools.*]
32+
follow_untyped_imports = True
33+
34+
[mypy-executorch.exir.*]
35+
follow_untyped_imports = True
36+
37+
[mypy-executorch.extension.*]
38+
follow_untyped_imports = True
39+
40+
[mypy-executorch.kernels.*]
41+
follow_untyped_imports = True
42+
43+
[mypy-executorch.runtime.*]
44+
follow_untyped_imports = True
45+
46+
[mypy-requests.*]
47+
follow_untyped_imports = True
48+
49+
[mypy-torchgen.*]
50+
follow_untyped_imports = True
51+
52+
[mypy-buck_util]
53+
ignore_missing_imports = True
54+
55+
[mypy-docutils.*]
56+
ignore_missing_imports = True
57+
58+
[mypy-pandas]
59+
ignore_missing_imports = True
60+
61+
[mypy-pytorch_sphinx_theme]
62+
ignore_missing_imports = True
63+
64+
[mypy-ruamel]
65+
ignore_missing_imports = True
66+
67+
[mypy-setuptools.*]
68+
ignore_missing_imports = True
69+
70+
[mypy-sphinx.*]
71+
ignore_missing_imports = True
72+
73+
[mypy-tomllib]
74+
ignore_missing_imports = True
75+
76+
[mypy-yaml]
77+
ignore_missing_imports = True
78+
79+
[mypy-zstd]
80+
ignore_missing_imports = True

backends/qualcomm/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ include_directories(
7676

7777
set(_qnn_schema__srcs
7878
backends/qualcomm/serialization/qc_compiler_spec.fbs
79-
backends/qualcomm/serialization/qc_binary_info.fbs
8079
)
8180
set(_qnn_schema__include_dir "${CMAKE_BINARY_DIR}/schema/include")
8281
# Paths to headers generated from the .fbs files.
@@ -116,6 +115,7 @@ add_library(qcir_utils STATIC)
116115
add_library(qnn_backend STATIC)
117116
add_library(qnn_backend_cache STATIC)
118117
add_library(qnn_context STATIC)
118+
add_library(qnn_custom_protocol STATIC)
119119
add_library(qnn_device STATIC)
120120
add_library(qnn_executorch_backend SHARED)
121121
add_library(qnn_executorch_header INTERFACE)
@@ -155,6 +155,7 @@ target_link_libraries(qnn_executorch_logging PRIVATE qnn_schema)
155155
target_link_libraries(qnn_profiler PRIVATE qnn_executorch_logging)
156156
target_link_libraries(qnn_logger PRIVATE qnn_implementation ${android_log})
157157
target_link_libraries(qnn_backend PRIVATE qnn_implementation qnn_logger)
158+
target_link_libraries(qnn_custom_protocol PRIVATE qcir_utils)
158159
target_link_libraries(
159160
qnn_device PRIVATE qnn_executorch_logging qnn_implementation qnn_logger
160161
)
@@ -177,7 +178,7 @@ target_link_libraries(
177178
qnn_factory
178179
PUBLIC qnn_header
179180
PRIVATE qnn_schema qnn_backend qnn_device qnn_context qnn_graph
180-
qnn_mem_manager
181+
qnn_mem_manager qnn_custom_protocol
181182
)
182183
target_link_libraries(
183184
qnn_manager PRIVATE qnn_factory wrappers qnn_schema utils shared_buffer

backends/qualcomm/aot/ir/qcir.fbs

+5-4
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,18 @@ table Tensor {
8080
type: TensorType;
8181
dtype: DataType;
8282
qparam: QuantizeParam;
83-
data: [ubyte];
83+
size: uint;
84+
offset: ulong;
8485
}
8586

8687
table Operator {
8788
name: string;
8889
package_name: string;
8990
type_name: string;
9091
// keep only tensor indexes
91-
inputs: [int];
92-
outputs: [int];
93-
params: [int];
92+
inputs: [uint];
93+
outputs: [uint];
94+
params: [uint];
9495
}
9596

9697
table Graph {

backends/qualcomm/aot/ir/qcir_utils.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,8 @@ Qnn_QuantizeParams_t ToQuantizeParam(const tensor_type& tensor) {
235235

236236
flatbuffers::Offset<qcir::Tensor> ToTensor(
237237
const Qnn_Tensor_t& tensor,
238+
const uint64_t data_offset,
238239
flatbuffers::FlatBufferBuilder* builder) {
239-
std::vector<uint8_t> buffer(
240-
static_cast<uint8_t*>(QNN_VER_PTR(tensor)->clientBuf.data),
241-
static_cast<uint8_t*>(QNN_VER_PTR(tensor)->clientBuf.data) +
242-
QNN_VER_PTR(tensor)->clientBuf.dataSize);
243240
std::vector<uint32_t> shape(
244241
QNN_VER_PTR(tensor)->dimensions,
245242
QNN_VER_PTR(tensor)->dimensions + QNN_VER_PTR(tensor)->rank);
@@ -251,10 +248,11 @@ flatbuffers::Offset<qcir::Tensor> ToTensor(
251248
ToTensorType(QNN_VER_PTR(tensor)->type),
252249
ToDataType(QNN_VER_PTR(tensor)->dataType),
253250
ToQuantizeParam(tensor, builder),
254-
&buffer);
251+
QNN_VER_PTR(tensor)->clientBuf.dataSize,
252+
data_offset);
255253
}
256254

257-
Qnn_Tensor_t ToTensor(const tensor_type& tensor) {
255+
Qnn_Tensor_t ToTensor(const tensor_type& tensor, const uint8_t* data_ptr) {
258256
auto is_io_tensor = [](Qnn_TensorType_t type) {
259257
return type < QNN_TENSOR_TYPE_STATIC;
260258
};
@@ -266,10 +264,10 @@ Qnn_Tensor_t ToTensor(const tensor_type& tensor) {
266264
QNN_VER_PTR(t)->quantizeParams = ToQuantizeParam(tensor);
267265
QNN_VER_PTR(t)->rank = tensor->shape()->size();
268266
QNN_VER_PTR(t)->dimensions = const_cast<uint32_t*>(tensor->shape()->data());
269-
QNN_VER_PTR(t)->clientBuf.dataSize = tensor->data()->size();
267+
QNN_VER_PTR(t)->clientBuf.dataSize = tensor->size();
270268
QNN_VER_PTR(t)->clientBuf.data = is_io_tensor(QNN_VER_PTR(t)->type)
271269
? nullptr
272-
: static_cast<void*>(const_cast<uint8_t*>(tensor->data()->Data()));
270+
: static_cast<void*>(const_cast<uint8_t*>(data_ptr));
273271
return t;
274272
}
275273

backends/qualcomm/aot/ir/qcir_utils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ Qnn_QuantizeParams_t ToQuantizeParam(const tensor_type& tensor);
3232

3333
flatbuffers::Offset<qcir::Tensor> ToTensor(
3434
const Qnn_Tensor_t& tensor,
35+
const uint64_t data_offset,
3536
flatbuffers::FlatBufferBuilder* builder);
36-
Qnn_Tensor_t ToTensor(const tensor_type& tensor);
37+
Qnn_Tensor_t ToTensor(const tensor_type& tensor, const uint8_t* data_ptr);
3738

3839
} // namespace qnn
3940
} // namespace backends

0 commit comments

Comments
 (0)