xref: /aosp_15_r20/external/executorch/backends/xnnpack/runtime/XNNCompiler.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
11 #include <executorch/backends/xnnpack/runtime/XNNExecutor.h>
12 #include <executorch/runtime/platform/compiler.h>
13 
14 #include <xnnpack.h>
15 #include <memory>
16 #include <vector>
17 
18 namespace executorch {
19 namespace backends {
20 namespace xnnpack {
21 namespace delegate {
22 
23 class XNNCompiler {
24  public:
25   // Takes Flatbuffer Serialized XNNPACK Model and rebuilds the xnn-subgraph
26   // returns an executor object that holds the xnn runtime object which we
27   // can then use to set inputs and run inference using the xnn graph.
28   ET_NODISCARD static executorch::runtime::Error compileModel(
29       const void* buffer_pointer,
30       size_t num_bytes,
31       XNNExecutor* executor,
32       executorch::runtime::MemoryAllocator* runtime_allocator,
33       xnn_workspace_t workspace);
34 };
35 
36 } // namespace delegate
37 } // namespace xnnpack
38 } // namespace backends
39 } // namespace executorch
40