MCPcopy Create free account
hub / github.com/apache/tvm / create_tvmjs_wasm

Function create_tvmjs_wasm

python/tvm/support/emcc.py:65–142  ·  view source on GitHub ↗

Create wasm that is supposed to run with the tvmjs. Parameters ---------- output : str The target shared library. objects : list List of object files. options : str The additional options. cc : str, optional The compile string. libs :

(output, objects, options=None, cc="emcc", libs=None)

Source from the content-addressed store, hash-verified

63
64
65def create_tvmjs_wasm(output, objects, options=None, cc="emcc", libs=None):
66 """Create wasm that is supposed to run with the tvmjs.
67
68 Parameters
69 ----------
70 output : str
71 The target shared library.
72
73 objects : list
74 List of object files.
75
76 options : str
77 The additional options.
78
79 cc : str, optional
80 The compile string.
81
82 libs : list
83 List of user-defined library files (e.g. .bc files) to add into the wasm.
84 """
85 cmd = [cc]
86 cmd += ["-O3"]
87 cmd += ["-std=c++17"]
88 cmd += ["--no-entry"]
89 # NOTE: asynctify conflicts with wasm-exception
90 # so we temp disable exception handling for now
91 #
92 # We also expect user to explicitly pass in
93 # -s ASYNCIFY=1 as it can increase wasm size by 2xq
94 #
95 # cmd += ["-s", "ASYNCIFY=1"]
96 # cmd += ["-fwasm-exceptions"]
97 cmd += ["-s", "WASM_BIGINT=1"]
98 cmd += ["-s", "ERROR_ON_UNDEFINED_SYMBOLS=0"]
99 cmd += ["-s", "STANDALONE_WASM=1"]
100 cmd += ["-s", "ALLOW_MEMORY_GROWTH=1"]
101 cmd += ["-s", "TOTAL_MEMORY=160MB"]
102
103 objects = [objects] if isinstance(objects, str) else objects
104
105 with_runtime = False
106 for obj in objects:
107 if obj.find("wasm_runtime.bc") != -1:
108 with_runtime = True
109
110 all_libs = []
111 if not with_runtime:
112 all_libs += [find_wasm_lib("wasm_runtime.bc")[0]]
113
114 all_libs += [find_wasm_lib("tvmjs_support.bc")[0]]
115 all_libs += [find_wasm_lib("webgpu_runtime.bc")[0]]
116
117 if libs:
118 if not isinstance(libs, list):
119 raise ValueError("Expect `libs` to be a list of paths in string.")
120 for lib in libs:
121 if not Path(lib).exists():
122 raise RuntimeError(

Callers

nothing calls this directly

Calls 2

find_wasm_libFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…