Skip to content

Commit eaf22c9

Browse files
Add Macro for Android api level
Keep original name of dump_context_from_pte
1 parent 997bd3d commit eaf22c9

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

backends/qualcomm/runtime/backends/irbackend/aarch64/QnnDlcManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ Error QnnDlcManager::RegisterGraphsFromDLC(
7373
cache->GetQnnContextBlob();
7474

7575
// memfd_create on android api level 30 and above
76-
int fd = memfd_create("tmp.dlc", 0);
76+
int fd = -1;
77+
#ifdef __ANDROID__
78+
#if __ANDROID_API__ >= 30
79+
fd = memfd_create("tmp.dlc", 0);
80+
#endif
81+
#endif
7782
if (fd == -1) {
7883
QNN_EXECUTORCH_LOG_ERROR("memfd_create fail");
7984
return Error::Internal;

backends/qualcomm/runtime/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def define_common_targets():
4646
"backends/irbackend/*.cpp",
4747
"backends/htpbackend/*.cpp",
4848
] + (["backends/htpbackend/x86_64/*.cpp"] if include_aot_qnn_lib else ["backends/htpbackend/aarch64/*.cpp"]) + (
49-
+ ["backends/irbackend/x86_64/*.cpp"] if include_aot_qnn_lib else ["backends/irbackend/aarch64/*.cpp"]
50-
+ ),
49+
["backends/irbackend/x86_64/*.cpp"] if include_aot_qnn_lib else ["backends/irbackend/aarch64/*.cpp"]
50+
),
5151
exclude = ["Logging.cpp"],
5252
),
5353
exported_headers = glob(

backends/qualcomm/tests/test_qnn_delegate.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
)
4242
from executorch.backends.qualcomm.utils.utils import (
4343
capture_program,
44-
dump_qnn_binary_from_pte,
44+
dump_context_from_pte,
4545
from_context_binary,
4646
generate_htp_compiler_spec,
4747
generate_multi_graph_program,
@@ -2577,7 +2577,7 @@ def test_qnn_backend_context_extraction(self):
25772577
pte_path = f"{tmp_dir}/model.pte"
25782578
with open(pte_path, "wb") as f:
25792579
edge_prog_mgr.write_to_file(f)
2580-
dump_qnn_binary_from_pte(pte_path)
2580+
dump_context_from_pte(pte_path)
25812581

25822582
qnn_tool = QnnTool(tmp_dir, pte_path, sample_input)
25832583
qnn_tool.qnn_context_binary_generator()
@@ -2620,7 +2620,7 @@ def test_qnn_backend_dump_context_from_pte(self):
26202620
pte_path = f"{tmp_dir}/model.pte"
26212621
with open(pte_path, "wb") as f:
26222622
edge_prog_mgr.write_to_file(f)
2623-
dump_qnn_binary_from_pte(pte_path)
2623+
dump_context_from_pte(pte_path)
26242624

26252625
qnn_tool = QnnTool(tmp_dir, pte_path, sample_input)
26262626
qnn_tool.qnn_context_binary_generator()
@@ -2641,7 +2641,7 @@ def test_qnn_backend_dump_context_from_pte(self):
26412641
with open(pte_path, "wb") as f:
26422642
edge_prog_mgr.write_to_file(f)
26432643

2644-
dump_qnn_binary_from_pte(pte_path)
2644+
dump_context_from_pte(pte_path)
26452645
binary_name = f"{tmp_dir}/forward_0.bin"
26462646
self.assertTrue(os.path.isfile(binary_name))
26472647
with open(binary_name, "rb") as f:
@@ -3225,7 +3225,7 @@ def test_qnn_backend_context_extraction(self):
32253225
pte_path = f"{tmp_dir}/model.pte"
32263226
with open(pte_path, "wb") as f:
32273227
edge_prog_mgr.write_to_file(f)
3228-
dump_qnn_binary_from_pte(pte_path)
3228+
dump_context_from_pte(pte_path)
32293229

32303230
qnn_tool = QnnTool(tmp_dir, pte_path, sample_input)
32313231
qnn_tool.qnn_context_binary_generator()
@@ -3269,7 +3269,7 @@ def test_qnn_backend_dump_context_from_pte(self):
32693269
pte_path = f"{tmp_dir}/model.pte"
32703270
with open(pte_path, "wb") as f:
32713271
edge_prog_mgr.write_to_file(f)
3272-
dump_qnn_binary_from_pte(pte_path)
3272+
dump_context_from_pte(pte_path)
32733273

32743274
qnn_tool = QnnTool(tmp_dir, pte_path, sample_input)
32753275
qnn_tool.qnn_context_binary_generator()
@@ -3290,7 +3290,7 @@ def test_qnn_backend_dump_context_from_pte(self):
32903290
with open(pte_path, "wb") as f:
32913291
edge_prog_mgr.write_to_file(f)
32923292

3293-
dump_qnn_binary_from_pte(pte_path)
3293+
dump_context_from_pte(pte_path)
32943294
binary_name = f"{tmp_dir}/forward_0.bin"
32953295
self.assertTrue(os.path.isfile(binary_name))
32963296
with open(binary_name, "rb") as f:

backends/qualcomm/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def replace_linear(module: torch.nn.Module):
187187
return replace_linear(module)
188188

189189

190-
def dump_qnn_binary_from_pte(pte_path):
190+
def dump_context_from_pte(pte_path):
191191
"""
192192
Dump compiled binaries under the same directory of pte_path.
193193
For partitioned graph, there will be multiple files with names f"{graph_name}_{index}".

0 commit comments

Comments
 (0)