forked from huajsj/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JS][WEB][BACKEND] Javascript(webassembly) backend. (apache#239)
- Loading branch information
1 parent
619e529
commit 0a07411
Showing
31 changed files
with
1,551 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,3 +98,5 @@ Win32 | |
*.dir | ||
perf | ||
nnvm | ||
*.wasm | ||
.emscripten |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Links to API References | ||
======================= | ||
|
||
This page contains links to API references that are build with different doc build system. | ||
|
||
* `C++ doyxgen API <doxygen/index.html>`_ | ||
* `Javascript jsdoc API <jsdoc/index.html>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Util to invoke emscripten compilers in the system.""" | ||
# pylint: disable=invalid-name | ||
from __future__ import absolute_import as _abs | ||
import subprocess | ||
from .._ffi.libinfo import find_lib_path | ||
|
||
def create_js(output, | ||
objects, | ||
options=None, | ||
cc="emcc"): | ||
"""Create emscripten javascript library. | ||
Parameters | ||
---------- | ||
output : str | ||
The target shared library. | ||
objects : list | ||
List of object files. | ||
options : str | ||
The additional options. | ||
cc : str, optional | ||
The compile string. | ||
""" | ||
cmd = [cc] | ||
cmd += ["-s", "RESERVED_FUNCTION_POINTERS=2"] | ||
cmd += ["-s", "NO_EXIT_RUNTIME=1"] | ||
cmd += ["-Oz"] | ||
cmd += ["-o", output] | ||
|
||
objects = [objects] if isinstance(objects, str) else objects | ||
with_runtime = False | ||
for obj in objects: | ||
if obj.find("libtvm_web_runtime.bc") != -1: | ||
with_runtime = True | ||
|
||
if not with_runtime: | ||
objects += [find_lib_path("libtvm_web_runtime.bc")[0]] | ||
|
||
cmd += objects | ||
|
||
if options: | ||
cmd += options | ||
|
||
args = ' '.join(cmd) | ||
proc = subprocess.Popen( | ||
args, shell=True, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT) | ||
(out, _) = proc.communicate() | ||
|
||
if proc.returncode != 0: | ||
msg = "Compilation error:\n" | ||
msg += out | ||
raise RuntimeError(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.