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