diff --git a/backends/xnnpack/runtime/operators/operator.cpp b/backends/xnnpack/runtime/operators/operator.cpp new file mode 100644 index 00000000000..ae44797651e --- /dev/null +++ b/backends/xnnpack/runtime/operators/operator.cpp @@ -0,0 +1,20 @@ +#include + +#include + +namespace executorch::backends::xnnpack::operators { + +std::unique_ptr create_operator(graph::Operator op) { + // No in-tree operators are available yet; the graph runtime currently + // supports only XNNPACK-delegated subgraphs. Reaching this point means a + // node was routed to an in-tree kernel that has not been added. Return null + // so the caller can fail cleanly rather than aborting. + ET_LOG( + Error, + "No in-tree kernel for operator %d; only XNNPACK-delegated nodes are " + "supported", + static_cast(op)); + return nullptr; +} + +} // namespace executorch::backends::xnnpack::operators diff --git a/backends/xnnpack/runtime/operators/operator.h b/backends/xnnpack/runtime/operators/operator.h new file mode 100644 index 00000000000..c63ba0c9a68 --- /dev/null +++ b/backends/xnnpack/runtime/operators/operator.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include + +namespace executorch::backends::xnnpack::operators { + +class Operator { + public: + virtual void setup(runtime::Span constant_args) {}; + virtual void prepare( + runtime::Span inputs, + runtime::Span outputs) {}; + virtual void reshape(runtime::Span input_specs) {}; + virtual void execute( + runtime::Span inputs, + runtime::Span outputs) = 0; + virtual ~Operator() = default; +}; + +std::unique_ptr create_operator(graph::Operator op); + +} // namespace executorch::backends::xnnpack::operators diff --git a/shim_et/xplat/executorch/build/build_variables.bzl b/shim_et/xplat/executorch/build/build_variables.bzl index 6ff7af998ba..909f3c21ecc 100644 --- a/shim_et/xplat/executorch/build/build_variables.bzl +++ b/shim_et/xplat/executorch/build/build_variables.bzl @@ -484,6 +484,7 @@ XNNPACK_BACKEND_BUCK_SRCS = [ "runtime/core/quant_params.cpp", "runtime/graph/graph.cpp", "runtime/graph/graph_builder.cpp", + "runtime/operators/operator.cpp", ] XNNPACK_BACKEND_SRCS = ["backends/xnnpack/" + x for x in XNNPACK_BACKEND_BUCK_SRCS]