[WEB] WebGPU support (#5545)
authorTianqi Chen <tqchen@users.noreply.github.com>
Sat, 9 May 2020 23:59:18 +0000 (16:59 -0700)
committerGitHub <noreply@github.com>
Sat, 9 May 2020 23:59:18 +0000 (16:59 -0700)
commitcdc7ae492e1ce30f6080d9567eecf89c97ed939f
tree27350ea5f5a65bfd2d21a4df18a26aa310700217
parent0c43fa056b29c84e36366494a807583a3e702868
[WEB] WebGPU support (#5545)

This PR introduces WebGPU support to tvm.
The WebGPU runtime is directly built in javascript(as WebGPU uses JS as the first class citizen API)
and exposes back to the tvm's runtime via PackedFuncs.

One important note is that `ctx.sync` is not async.
This is due to the fact that WebGPU is a purely async API and we cannot block in the web environment.

So the current best way to use the js api is to wrap things in an async function.
When copy a GPU array to CPU, `await ctx.sync()` need to be called to wait for copy completion.

We use a AsyncIO rpc server to serve the async functions to the clients.
35 files changed:
include/tvm/runtime/c_runtime_api.h
include/tvm/runtime/device_api.h
python/tvm/_ffi/libinfo.py
python/tvm/_ffi/runtime_ctypes.py
python/tvm/autotvm/tophub.py
python/tvm/contrib/emcc.py
python/tvm/exec/rpc_proxy.py
python/tvm/rpc/client.py
python/tvm/rpc/proxy.py
python/tvm/runtime/module.py
python/tvm/runtime/ndarray.py
src/runtime/cuda/cuda_common.h
src/runtime/vulkan/vulkan.cc
src/target/spirv/build_vulkan.cc
src/target/spirv/codegen_spirv.cc
src/target/spirv/codegen_spirv.h
src/target/spirv/intrin_rule_spirv.cc
src/target/spirv/ir_builder.cc
src/target/spirv/ir_builder.h
src/target/target.cc
web/Makefile
web/README.md
web/apps/browser/rpc_server.html
web/emcc/tvmjs_support.cc
web/emcc/webgpu_runtime.cc [new file with mode: 0644]
web/package.json
web/rollup.config.js
web/src/compact.ts [new file with mode: 0644]
web/src/index.ts
web/src/rpc_server.ts
web/src/runtime.ts
web/src/webgpu.ts [new file with mode: 0644]
web/tests/python/webgpu_rpc_test.py [new file with mode: 0644]
web/tests/python/websock_rpc_test.py
web/tsconfig.json