Halide  17.0.2
Halide compiler and libraries
WasmExecutor.h
Go to the documentation of this file.
1 #ifndef HALIDE_WASM_EXECUTOR_H
2 #define HALIDE_WASM_EXECUTOR_H
3 
4 /** \file
5  *
6  * Support for running Halide-compiled Wasm code in-process.
7  * Bindings for parameters, extern calls, etc. are established and the
8  * Wasm code is executed. Allows calls to realize to work
9  * exactly as if native code had been run, but via a JavaScript/Wasm VM.
10  * Currently, only the WABT interpreter is supported.
11  */
12 
13 #include "Argument.h"
14 #include "Parameter.h"
15 #include "Type.h"
16 
17 #include <map>
18 #include <string>
19 #include <vector>
20 
21 namespace Halide {
22 
23 struct JITExtern;
24 struct Target;
25 
26 namespace Internal {
27 
28 struct JITModule;
29 struct WasmModuleContents;
30 
31 /** Handle to compiled wasm code which can be called later. */
32 struct WasmModule {
34 
35  /** If the given target can be executed via the wasm executor, return true. */
36  static bool can_jit_target(const Target &target);
37 
38  /** Compile generated wasm code with a set of externs. */
39  static WasmModule compile(
40  const Module &module,
41  const std::vector<Argument> &arguments,
42  const std::string &fn_name,
43  const std::map<std::string, JITExtern> &externs,
44  const std::vector<JITModule> &extern_deps);
45 
46  /** Run generated previously compiled wasm code with a set of arguments. */
47  int run(const void *const *args);
48 };
49 
50 } // namespace Internal
51 } // namespace Halide
52 
53 #endif // HALIDE_WASM_EXECUTOR_H
Handle to compiled wasm code which can be called later.
Definition: WasmExecutor.h:32
A struct representing a target machine and os to generate code for.
Definition: Target.h:19
This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide&#39;s bounds tools to query properties of it.
Defines halide types.
A halide module.
Definition: Module.h:142
Not visible externally, similar to &#39;static&#39; linkage in C.
Defines the internal representation of parameters to halide piplines.
Internal::IntrusivePtr< WasmModuleContents > contents
Definition: WasmExecutor.h:33
Defines a type used for expressing the type signature of a generated halide pipeline.
static WasmModule compile(const Module &module, const std::vector< Argument > &arguments, const std::string &fn_name, const std::map< std::string, JITExtern > &externs, const std::vector< JITModule > &extern_deps)
Compile generated wasm code with a set of externs.
static bool can_jit_target(const Target &target)
If the given target can be executed via the wasm executor, return true.
int run(const void *const *args)
Run generated previously compiled wasm code with a set of arguments.