Skip to content
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

Add TVM application extension with WASM runtime #5892

Merged
merged 6 commits into from
Jul 28, 2020

Conversation

leonwanghui
Copy link
Contributor

Background

As demonstrated in TVM runtime tutorials, TVM already supports WASM as the optional hardware backend, so we can leverage the features of WebAssembly (portability, security) and TVM runtime (domain-specific, optimization) to build a flexible and auto-optimized operator backend for all deep learning frameworks.

Proposal Summary

This PR is mainly proposed to add new TVM application extension that provides WASM operator backend for deep learning frameworks with TVM runtime. We believe it would bring some new ideas by combining WASM runtime with TVM compiler stack.

Thanks for reviewing this proposal, considering it's at the experimental stage to incubation, so any suggestions or questions are welcomed. And we wish more contributors can join in to make it grow up.

@tqchen @jroesch @kazum PTAL, thanks!

@tqchen
Copy link
Member

tqchen commented Jun 23, 2020

Thanks @leonwanghui Given that TVM is a compilation stack, directly generating generic ops may not give the best performance for deployment, as the compilation approach takes a lot of shape specialization and fusions.

A better approach for integration might be creating a relay or TIR-level integration from the framework to the TVM's unified IR, then let the compilation produces a standalone module.

@leonwanghui
Copy link
Contributor Author

@tqchen Thanks for your suggestion, if we target relay or TIR-level integration, does that mean we need to create Rust FFI for them at first?

@tqchen
Copy link
Member

tqchen commented Jun 23, 2020

@jroesch is already working on some of the RUST FFI access. We can also do that through python or other language binding and only use the rust runtime to execute in wasm.

@leonwanghui
Copy link
Contributor Author

Thanks @tqchen, it seems promising to me. I will finish the PoC and update this PR later.

@leonwanghui
Copy link
Contributor Author

@tqchen @jroesch @kazum Now this PR is updated, please take a review, thanks!

@leonwanghui leonwanghui force-pushed the wasm-dlbackend-tvm branch 4 times, most recently from 0e858d8 to 6187bd8 Compare July 9, 2020 03:03
@leonwanghui
Copy link
Contributor Author

cc @tqchen @jroesch

Copy link
Member

@tqchen tqchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the csv file as we cannot checkin binary to the codebase

apps/wasm-graphcompiler-tvm/README.md Outdated Show resolved Hide resolved
@leonwanghui leonwanghui force-pushed the wasm-dlbackend-tvm branch 2 times, most recently from 5a0e4de to 7d5be42 Compare July 10, 2020 07:48
@leonwanghui
Copy link
Contributor Author

please remove the csv file as we cannot checkin binary to the codebase

@tqchen Done

Copy link
Member

@tqchen tqchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @leonwanghui some high level comments, please also check the CI error and add the license header to the related files

apps/wasm-graphcompiler-tvm/README.md Outdated Show resolved Hide resolved
apps/wasm-graphcompiler-tvm/README.md Outdated Show resolved Hide resolved
apps/wasm-graphcompiler-tvm/README.md Outdated Show resolved Hide resolved
apps/wasm-graphcompiler-tvm/wasm-graphcompiler/Cargo.toml Outdated Show resolved Hide resolved
apps/wasm-graphcompiler-tvm/wasm-graphcompiler/Cargo.toml Outdated Show resolved Hide resolved
apps/wasm-graphcompiler-tvm/README.md Outdated Show resolved Hide resolved
@leonwanghui leonwanghui force-pushed the wasm-dlbackend-tvm branch 4 times, most recently from 65b22df to 17bc8ec Compare July 14, 2020 00:50
@leonwanghui
Copy link
Contributor Author

cc @tqchen Please review it again, thanks!

@leonwanghui
Copy link
Contributor Author

@tqchen It seems that the ./cargo/config file is not allowed to be included into the repo, the ci error is as follows:

+ docker/bash.sh tvmai/ci-lint:v0.61 ./tests/scripts/task_lint.sh

WORKSPACE: /scratch/jenkins-tvm/cudabuild/workspace/exec_3/tvm/sanity

DOCKER CONTAINER NAME: tvmai/ci-lint:v0.61



Running './tests/scripts/task_lint.sh' inside tvmai/ci-lint:v0.61...

mesg: ttyname failed: Inappropriate ioctl for device

Adding group `tvm' (GID 1000) ...

Done.

Check file types...

------File type check report----

apps/wasm-standalone/wasm-graph/.cargo/config

Found 1 files that are now allowed

We do not check in binary files into the repo.

If necessary, please discuss with committers andmodify tests/lint/check_file_type.py to enable the file you need.

script returned exit code 255

@tqchen
Copy link
Member

tqchen commented Jul 14, 2020

@leonwanghui it seems that we might want to include .cargo/config, can you modify https://github.com/apache/incubator-tvm/blob/master/tests/lint/check_file_type.py#L110 to enable that?

@tqchen
Copy link
Member

tqchen commented Jul 14, 2020

cc @kazum

apps/wasm-standalone/README.md Outdated Show resolved Hide resolved
apps/wasm-standalone/wasm-graph/Cargo.toml Outdated Show resolved Hide resolved
apps/wasm-standalone/wasm-graphruntime/src/main.rs Outdated Show resolved Hide resolved
@leonwanghui
Copy link
Contributor Author

leonwanghui commented Jul 16, 2020

cc @kazum I have resolved your comments, PTAL

Copy link
Contributor

@kazum kazum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@leonwanghui
Copy link
Contributor Author

cc @tqchen

@leonwanghui leonwanghui force-pushed the wasm-dlbackend-tvm branch 2 times, most recently from 41e6556 to 69d4eaa Compare July 21, 2020 03:39
Copy link
Member

@nhynes nhynes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the style fixes. Please remember to also run cargo clippy!

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>
@leonwanghui
Copy link
Contributor Author

leonwanghui commented Jul 24, 2020

cc @tqchen @nhynes @jroesch, I think this PR is ready to go, please notice that some of clippy warnings in tvm-graph-rt module would not be addressed in this PR.

@tqchen
Copy link
Member

tqchen commented Jul 24, 2020

@leonwanghui please send another commit to trigger the CI, @jroesch @nhynes please followup and take another look

@nhynes
Copy link
Member

nhynes commented Jul 26, 2020

@tqchen This PR looks fine. I have a few style nits, but I don't think they'd be well received.

Thanks @leonwanghui for the contribution!

apps/wasm-standalone/README.md Outdated Show resolved Hide resolved
@leonwanghui
Copy link
Contributor Author

cc @tqchen Your comments have been addressed, PTAL

@tqchen tqchen merged commit 969a9d9 into apache:master Jul 28, 2020
@tqchen
Copy link
Member

tqchen commented Jul 28, 2020

Thanks @leonwanghui @jroesch @nhynes @kazum ! this PR is now merged

@leonwanghui leonwanghui deleted the wasm-dlbackend-tvm branch July 28, 2020 03:40
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
* Refactor wasm runtime module and resovle conflict errors

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>

* Fix some cargo clippy warnings

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
* Refactor wasm runtime module and resovle conflict errors

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>

* Fix some cargo clippy warnings

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
* Refactor wasm runtime module and resovle conflict errors

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>

* Fix some cargo clippy warnings

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Sep 2, 2020
* Refactor wasm runtime module and resovle conflict errors

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>

* Fix some cargo clippy warnings

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Sep 3, 2020
* Refactor wasm runtime module and resovle conflict errors

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>

* Fix some cargo clippy warnings

Signed-off-by: leonwanghui <wanghui71leon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants