From c7be8c6d1d158a12915f54b0ee5649bb5ae702b0 Mon Sep 17 00:00:00 2001 From: Shen Xu Date: Fri, 23 Jan 2026 08:16:20 -0800 Subject: [PATCH] Buckify MediaTek backend (#16717) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/16717 Reviewed By: mohankumarkumar Differential Revision: D91066696 --- .ci/scripts/unittest-buck2.sh | 3 ++- backends/mediatek/TARGETS | 26 ++++++++++++++++++++++++++ backends/mediatek/_passes/TARGETS | 14 ++++++++++++++ backends/mediatek/quantizer/TARGETS | 16 ++++++++++++++++ backends/mediatek/runtime/BUCK | 8 ++++++++ backends/mediatek/runtime/targets.bzl | 24 ++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 backends/mediatek/TARGETS create mode 100644 backends/mediatek/_passes/TARGETS create mode 100644 backends/mediatek/quantizer/TARGETS create mode 100644 backends/mediatek/runtime/BUCK create mode 100644 backends/mediatek/runtime/targets.bzl diff --git a/.ci/scripts/unittest-buck2.sh b/.ci/scripts/unittest-buck2.sh index e78e682faac..9360b65427a 100755 --- a/.ci/scripts/unittest-buck2.sh +++ b/.ci/scripts/unittest-buck2.sh @@ -44,7 +44,8 @@ for op in "build" "test"; do done # Build only without testing -buck2 build //codegen/tools/... \ +buck2 build //backends/mediatek/... \ + //codegen/tools/... \ //extension/llm/runner/io_manager:io_manager \ //extension/llm/modules/... \ //extension/llm/runner:multimodal_runner_lib \ diff --git a/backends/mediatek/TARGETS b/backends/mediatek/TARGETS new file mode 100644 index 00000000000..9d3cd9459a4 --- /dev/null +++ b/backends/mediatek/TARGETS @@ -0,0 +1,26 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +runtime.python_library( + name = "preprocess", + srcs = [ + "preprocess.py" + ], + visibility = ["PUBLIC"], + deps = [ + "//executorch/exir/_serialize:lib", + "//executorch/exir/backend:backend_api", + "//executorch/exir/passes:lib", + "fbsource//third-party/mediatek/neuropilot-express-sdk:sdk", + ], +) + +runtime.python_library( + name = "partitioner", + srcs = [ + "partitioner.py" + ], + visibility = ["PUBLIC"], + deps = [ + ":preprocess", + ], +) diff --git a/backends/mediatek/_passes/TARGETS b/backends/mediatek/_passes/TARGETS new file mode 100644 index 00000000000..def649d8857 --- /dev/null +++ b/backends/mediatek/_passes/TARGETS @@ -0,0 +1,14 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +runtime.python_library( + name = "passes", + srcs = [ + "__init__.py", + "decompose_scaled_dot_product_attention.py", + ], + visibility = ["PUBLIC"], + deps = [ + "//caffe2:torch", + "//executorch/exir:pass_base", + ], +) diff --git a/backends/mediatek/quantizer/TARGETS b/backends/mediatek/quantizer/TARGETS new file mode 100644 index 00000000000..09be73cd172 --- /dev/null +++ b/backends/mediatek/quantizer/TARGETS @@ -0,0 +1,16 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +runtime.python_library( + name = "quantizer", + srcs = [ + "__init__.py", + "annotator.py", + "qconfig.py", + "quantizer.py", + ], + visibility = ["PUBLIC"], + deps = [ + "//pytorch/ao:torchao", + "//executorch/backends/mediatek/_passes:passes", + ], +) diff --git a/backends/mediatek/runtime/BUCK b/backends/mediatek/runtime/BUCK new file mode 100644 index 00000000000..1e8cc179228 --- /dev/null +++ b/backends/mediatek/runtime/BUCK @@ -0,0 +1,8 @@ +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. This file can contain xplat-only targets. + +load(":targets.bzl", "define_common_targets") + +oncall("executorch") + +define_common_targets() diff --git a/backends/mediatek/runtime/targets.bzl b/backends/mediatek/runtime/targets.bzl new file mode 100644 index 00000000000..ed0d50cf43c --- /dev/null +++ b/backends/mediatek/runtime/targets.bzl @@ -0,0 +1,24 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +def define_common_targets(): + runtime.cxx_library( + name = "neuron_backend", + srcs = [ + "NeuronBackend.cpp", + "NeuronBufferAllocator.cpp", + "NeuronExecutor.cpp", + ], + headers = glob([ + "include/**/*.h", + ]), + public_include_directories = ["include"], + deps = [ + "fbsource//third-party/mediatek/neuropilot-express-sdk:runtime_api", + "//executorch/runtime/backend:interface", + "//executorch/runtime/core:memory_allocator", + "//executorch/runtime/executor:pte_data_map", + ], + define_static_target = True, + link_whole = True, + visibility = ["PUBLIC"], + )