Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
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
21namespace Halide {
22
23struct JITExtern;
24struct Target;
25
26namespace Internal {
27
28struct JITModule;
29struct WasmModuleContents;
30
31/** Handle to compiled wasm code which can be called later. */
32struct 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. */
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
Defines a type used for expressing the type signature of a generated halide pipeline.
Defines the internal representation of parameters to halide piplines.
Defines halide types.
A halide module.
Definition Module.h:142
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
Intrusive shared pointers have a reference count (a RefCount object) stored in the class itself.
Handle to compiled wasm code which can be called later.
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.
Internal::IntrusivePtr< WasmModuleContents > contents
int run(const void *const *args)
Run generated previously compiled wasm code with a set of arguments.
A struct representing a target machine and os to generate code for.
Definition Target.h:19