-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[JS][WEB][BACKEND] Javascript(webassembly) backend. #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Use TVM to Generate Javascript LibraryThe general idea is to use TVM as normally and set target to be The following code snippet from tests/web/prepare_test_libs.py demonstrate import tvm
from tvm.contrib import emscripten
import os
def prepare_test_libs(base_path):
target = "llvm -target=asmjs-unknown-emscripten -system-lib"
if not tvm.module.enabled(target):
raise RuntimeError("Target %s is not enbaled" % target)
n = tvm.var("n")
A = tvm.placeholder((n,), name='A')
B = tvm.compute(A.shape, lambda *i: A(*i) + 1.0, name='B')
s = tvm.create_schedule(B.op)
fadd1 = tvm.build(s, [A, B], target, name="add_one")
obj_path = os.path.join(base_path, "test_add_one.bc")
fadd1.save(obj_path)
emscripten.create_js(os.path.join(base_path, "test_module.js"), obj_path)
if __name__ == "__main__":
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
prepare_test_libs(os.path.join(curr_path, "../../lib"))In this workflow, we use TVM to generate a Run the Generated LibraryThe following code snippet from tests/web/test_module_load.js demonstrate // Load Emscripten Module, need to change path to root/lib
const path = require("path");
process.chdir(path.join(__dirname, "../../lib"));
var Module = require("../../lib/test_module.js");
// Bootstrap TVMruntime with emscripten module.
const tvm_runtime = require("../../web/tvm_runtime.js");
const tvm = tvm_runtime.create(Module);
// Load system library, the compiled functions is registered in sysLib.
var sysLib = tvm.systemLib();
function randomArray(length, max) {
return Array.apply(null, Array(length)).map(function() {
return Math.random() * max;
});
}
function testAddOne() {
// grab pre-loaded function
var faddOne = sysLib.getFunction("add_one");
tvm.assert(tvm.isPackedFunc(faddOne));
var n = 124;
var A = tvm.empty(n).copyFrom(randomArray(n, 1));
var B = tvm.empty(n);
// call the function.
faddOne(A, B);
// verify
for (var i = 0; i < B.length; ++i) {
tvm.assert(B[i] == A[i] + 1);
}
faddOne.release();
}
testAddOne();
sysLib.release(); |
* scheduler tweaked for super resolution perf * conv2d_transpose schedule error fixed * nnvm issue apache#239 fixed
|
I have a question about the I ran prepare_test_libs.py and got the following output: Traceback (most recent call last):
File "./tests/web/prepare_test_libs.py", line 21, in <module>
prepare_test_libs(os.path.join(curr_path, "../../lib"))
File "./tests/web/prepare_test_libs.py", line 9, in prepare_test_libs
raise RuntimeError("Target %s is not enbaled" % target)
RuntimeError: Target llvm -target=asmjs-unknown-emscripten -system-lib is not enbaledWhat can I do to fix this? I can make an issue out of this |
|
What is the llvm version ? try |
|
@srkreddy1238 this is what I get but only after I put in the following command: LLVM (http://llvm.org/):
LLVM version 6.0.1
Optimized build.
Default target: x86_64-apple-darwin17.7.0
Host CPU: haswell
Registered Targets:
js - JavaScript (asm.js, emscripten) backend
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64else I will get an error: EDIT:resolved the issue with bash |
* scheduler tweaked for super resolution perf * conv2d_transpose schedule error fixed * nnvm issue apache#239 fixed
* B2-4: TIR IRBuilder B2, B3 and B4 listed in apache#227. * bypass `Literal` for lower python versions
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
…he#239) * Refactor Simplify function to handle multiple functions in IRModule * Update submodule commit reference * Add CUDA_DEVICE_ORDER environment variable to bashrc * test fix * lint fix * Refactor test_general_matmul_bf16.py to use bitblas.testing.main() * Update submodule commit reference * Update Ubuntu version in install scripts based on LLVM version * Update Ubuntu version in install scripts based on LLVM version * Update submodule commit reference * Update submodule commit reference * Update submodule commit reference * Update submodule commit reference * Update submodule commit reference * [Dev] Update subproject commit for TVM * ignore profiler directories. * MFMA Support * lint fix * MFMA Fixed. * Disable Benchmark artifacts
* [kernel] finish the first version of batch attn-decode * [fix] adjust the parameters to get better performance
Upstream : https://github.com/apache/tvm-ffi.git Branch : main New HEAD : 82bc7b639530558e9f666043c7145696d6fa35ba Subject : [FIX] Fix missing static registration for DLTensor* (apache#239) Author : Tianqi Chen <[email protected]> Date : 2025-11-07T20:17:41-05:00 Delta : 1 commit(s) since 4bccb3eda0d5 Compare : apache/tvm-ffi@4bccb3e...82bc7b6 This commit updates the tvm-ffi submodule to the latest upstream HEAD.
Upstream : https://github.com/apache/tvm-ffi.git Branch : main New HEAD : 82bc7b639530558e9f666043c7145696d6fa35ba Subject : [FIX] Fix missing static registration for DLTensor* (apache#239) Author : Tianqi Chen <[email protected]> Date : 2025-11-07T20:17:41-05:00 Delta : 1 commit(s) since 4bccb3eda0d5 Compare : apache/tvm-ffi@4bccb3e...82bc7b6 This commit updates the tvm-ffi submodule to the latest upstream HEAD.
cc @Javelinjs maybe some good reference on setting up testcases