Halide 22.0.0 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 {
33 Internal::IntrusivePtr<WasmModuleContents> contents;
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
Argument.h
Defines a type used for expressing the type signature of a generated halide pipeline.
Parameter.h
Defines the internal representation of parameters to halide piplines.
Type.h
Defines halide types.
Halide::Module
A halide module.
Definition: Module.h:142
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AbstractGenerator.h:19
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Internal::IntrusivePtr< WasmModuleContents >
Halide::Internal::WasmModule
Handle to compiled wasm code which can be called later.
Definition: WasmExecutor.h:32
Halide::Internal::WasmModule::compile
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.
Halide::Internal::WasmModule::can_jit_target
static bool can_jit_target(const Target &target)
If the given target can be executed via the wasm executor, return true.
Halide::Internal::WasmModule::contents
Internal::IntrusivePtr< WasmModuleContents > contents
Definition: WasmExecutor.h:33
Halide::Internal::WasmModule::run
int run(const void *const *args)
Run generated previously compiled wasm code with a set of arguments.
Halide::Target
A struct representing a target machine and os to generate code for.
Definition: Target.h:19