Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions backends/xnnpack/runtime/operators/operator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <executorch/backends/xnnpack/runtime/operators/operator.h>

#include <executorch/runtime/platform/log.h>

namespace executorch::backends::xnnpack::operators {

std::unique_ptr<Operator> 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<int>(op));
return nullptr;
}

} // namespace executorch::backends::xnnpack::operators
28 changes: 28 additions & 0 deletions backends/xnnpack/runtime/operators/operator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include <executorch/backends/xnnpack/runtime/core/tensor.h>
#include <executorch/backends/xnnpack/runtime/graph/node.h>
#include <executorch/backends/xnnpack/runtime/graph/operator.h>
#include <executorch/backends/xnnpack/runtime/graph/tensor_spec.h>
#include <executorch/runtime/core/span.h>

#include <memory>

namespace executorch::backends::xnnpack::operators {

class Operator {
public:
virtual void setup(runtime::Span<const graph::ConstantArg> constant_args) {};
virtual void prepare(
runtime::Span<core::Tensor*> inputs,
runtime::Span<core::Tensor*> outputs) {};
virtual void reshape(runtime::Span<const graph::TensorSpec> input_specs) {};
virtual void execute(
runtime::Span<core::Tensor*> inputs,
runtime::Span<core::Tensor*> outputs) = 0;
virtual ~Operator() = default;
};

std::unique_ptr<Operator> create_operator(graph::Operator op);

} // namespace executorch::backends::xnnpack::operators
1 change: 1 addition & 0 deletions shim_et/xplat/executorch/build/build_variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading