Skip to content

Commit 3bedd8b

Browse files
Abhi-hppfacebook-github-bot
authored andcommitted
Add buck targets for QNN AOT export (#5476)
Summary: Pull Request resolved: #5476 Added the necessary buck targets needed to compile qnn export. Next steps: Get llama model export to succeed without any errors. bypass-github-export-checks Reviewed By: derekxu, cccclai Differential Revision: D61808158 fbshipit-source-id: c6332c9b3432cc011ae415abd590287844099534
1 parent e57bbbb commit 3bedd8b

File tree

24 files changed

+586
-226
lines changed

24 files changed

+586
-226
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
load(
2+
"@fbsource//tools/build_defs:default_platform_defs.bzl",
3+
"ANDROID",
4+
)
5+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
6+
7+
PYTHON_MODULE_NAME = "PyQnnManagerAdaptor"
8+
9+
def define_common_targets():
10+
"""Defines targets that should be shared between fbcode and xplat.
11+
The directory containing this targets.bzl file should also contain both
12+
TARGETS and BUCK files that call this function.
13+
"""
14+
15+
runtime.cxx_python_extension(
16+
name = "PyQnnManagerAdaptor",
17+
srcs = [
18+
"PyQnnManagerAdaptor.cpp",
19+
],
20+
headers = [
21+
"PyQnnManagerAdaptor.h",
22+
],
23+
base_module = "executorch.backends.qualcomm.python",
24+
preprocessor_flags = [
25+
"-DEXECUTORCH_PYTHON_MODULE_NAME={}".format(PYTHON_MODULE_NAME),
26+
],
27+
deps = [
28+
"//executorch/runtime/core:core",
29+
"//executorch/backends/qualcomm/aot/python:python_lib",
30+
"//executorch/backends/qualcomm/aot/wrappers:wrappers",
31+
"//executorch/backends/qualcomm/runtime:logging",
32+
"//executorch/backends/qualcomm:schema",
33+
"//executorch/backends/qualcomm/aot/ir:qcir_utils",
34+
"//executorch/backends/qualcomm/runtime:runtime",
35+
"fbsource//third-party/qualcomm/qnn:api",
36+
],
37+
external_deps = [
38+
"pybind11",
39+
"libtorch_python",
40+
],
41+
use_static_deps = True,
42+
visibility = [
43+
"//executorch/backends/qualcomm/...",
44+
],
45+
)
46+
47+
48+
runtime.cxx_python_extension(
49+
name = "PyQnnWrapperAdaptor",
50+
srcs = [
51+
"PyQnnWrapperAdaptor.cpp",
52+
],
53+
headers = [
54+
"PyQnnWrapperAdaptor.h",
55+
],
56+
base_module = "executorch.backends.qualcomm.python",
57+
preprocessor_flags = [
58+
"-DEXECUTORCH_PYTHON_MODULE_NAME={}".format(PYTHON_MODULE_NAME),
59+
],
60+
deps = [
61+
"//executorch/runtime/core:core",
62+
"//executorch/backends/qualcomm/aot/python:python_lib",
63+
"//executorch/backends/qualcomm/aot/wrappers:wrappers",
64+
"//executorch/backends/qualcomm/runtime:logging",
65+
"//executorch/backends/qualcomm:schema",
66+
"//executorch/backends/qualcomm/aot/ir:qcir_utils",
67+
"//executorch/backends/qualcomm/runtime:runtime",
68+
"fbsource//third-party/qualcomm/qnn:api",
69+
],
70+
external_deps = [
71+
"pybind11",
72+
"libtorch_python",
73+
],
74+
use_static_deps = True,
75+
visibility = [
76+
"//executorch/backends/qualcomm/...",
77+
],
78+
)
79+
80+
runtime.cxx_library(
81+
name = "python_lib",
82+
srcs = glob([
83+
"*.cpp",
84+
]),
85+
exported_headers = glob([
86+
"*.h",
87+
]),
88+
visibility = ["@EXECUTORCH_CLIENTS"],
89+
deps = [
90+
"//executorch/backends/qualcomm/aot/wrappers:wrappers",
91+
"//executorch/backends/qualcomm/runtime:logging",
92+
"//executorch/backends/qualcomm:schema",
93+
"//executorch/backends/qualcomm/aot/ir:qcir_utils",
94+
"//executorch/backends/qualcomm/runtime:runtime",
95+
"fbsource//third-party/qualcomm/qnn:api",
96+
],
97+
external_deps = [
98+
"pybind11",
99+
],
100+
)

backends/qualcomm/builders/TARGETS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets():
4+
"""Defines targets that should be shared between fbcode and xplat.
5+
The directory containing this targets.bzl file should also contain both
6+
TARGETS and BUCK files that call this function.
7+
"""
8+
9+
runtime.python_library(
10+
name = "builders",
11+
srcs = glob([
12+
"*.py",
13+
]),
14+
visibility = [
15+
"@EXECUTORCH_CLIENTS",
16+
],
17+
deps = [
18+
"//executorch/exir/backend:backend_details",
19+
"//executorch/exir/backend:compile_spec_schema",
20+
"//executorch/backends/qualcomm/aot/python:PyQnnWrapperAdaptor",
21+
"//executorch/backends/qualcomm/aot/python:PyQnnManagerAdaptor",
22+
"//executorch/backends/qualcomm/utils:utils",
23+
"//executorch/exir:lib",
24+
],
25+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets():
4+
"""Defines targets that should be shared between fbcode and xplat.
5+
The directory containing this targets.bzl file should also contain both
6+
TARGETS and BUCK files that call this function.
7+
"""
8+
9+
runtime.python_library(
10+
name = "partition",
11+
srcs = glob([
12+
"*.py",
13+
]),
14+
visibility = [
15+
"@EXECUTORCH_CLIENTS",
16+
],
17+
deps = [
18+
"//executorch/exir/backend:backend_details",
19+
"//executorch/exir/backend:compile_spec_schema",
20+
"//executorch/backends/qualcomm/builders:builders",
21+
"//executorch/backends/qualcomm:preprocess",
22+
"//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib",
23+
],
24+
)

backends/qualcomm/passes/TARGETS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets():
4+
"""Defines targets that should be shared between fbcode and xplat.
5+
The directory containing this targets.bzl file should also contain both
6+
TARGETS and BUCK files that call this function.
7+
"""
8+
9+
runtime.python_library(
10+
name = "passes",
11+
srcs = glob([
12+
"*.py",
13+
]),
14+
visibility = [
15+
"@EXECUTORCH_CLIENTS",
16+
],
17+
deps = [
18+
"//executorch/exir/backend:backend_details",
19+
"//executorch/exir/backend:compile_spec_schema",
20+
"//executorch/backends/transforms:addmm_mm_to_linear",
21+
],
22+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets():
4+
"""Defines targets that should be shared between fbcode and xplat.
5+
6+
The directory containing this targets.bzl file should also contain both
7+
TARGETS and BUCK files that call this function.
8+
"""
9+
runtime.python_library(
10+
name = "quantizer",
11+
srcs = glob([
12+
"*.py",
13+
]),
14+
visibility = [
15+
"@EXECUTORCH_CLIENTS",
16+
],
17+
deps = [
18+
"//executorch/backends/transforms:decompose_sdpa",
19+
],
20+
)

0 commit comments

Comments
 (0)