From e50c1695cca656390c7819e4f397941b54aa0842 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 20 Sep 2025 21:54:45 -0700 Subject: [PATCH] Add backend option setter to the dynamic shim (#13891) Summary: Add a new function to the dynamic shim interface to set runtime backend options with integer values. I've added this as a top-level function, intended to be loaded with dlsym, as opposed to on the DynamicShim class, as it needs to be set pre-model load. Long-term, the whole shim interface needs to be refactored and we should likely have some sort of runtime abstraction to include this. As such, I'm not worrying about providing a full set of methods to get/set all option types. I've also exposed XNNPACKBackend.h through a new buck target - xnnpack_interface. This is so that users don't have to hard-code keys. I might refactor this in the future, as it would be nice to have it be clearer what this header/target is intended for. Reviewed By: digantdesai Differential Revision: D79314050 --- backends/xnnpack/runtime/XNNPACKBackend.h | 2 -- backends/xnnpack/targets.bzl | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backends/xnnpack/runtime/XNNPACKBackend.h b/backends/xnnpack/runtime/XNNPACKBackend.h index e6930dfeb5c..aca72f8652b 100644 --- a/backends/xnnpack/runtime/XNNPACKBackend.h +++ b/backends/xnnpack/runtime/XNNPACKBackend.h @@ -1,7 +1,5 @@ #pragma once -#include - namespace executorch::backends::xnnpack { /// The key for the backend. This is used to register the backend, check /// availability, and get/set options. diff --git a/backends/xnnpack/targets.bzl b/backends/xnnpack/targets.bzl index 623ee278803..796fd887e33 100644 --- a/backends/xnnpack/targets.bzl +++ b/backends/xnnpack/targets.bzl @@ -73,3 +73,13 @@ def define_common_targets(): # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) link_whole = True, ) + + runtime.cxx_library( + name = "xnnpack_interface", + visibility = [ + "@EXECUTORCH_CLIENTS", + ], + exported_headers = [ + "runtime/XNNPACKBackend.h", + ], + )