Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

VM compiler. #18

Merged
merged 8 commits into from
Oct 6, 2021
Merged

VM compiler. #18

merged 8 commits into from
Oct 6, 2021

Conversation

YuchenJin
Copy link
Collaborator

@YuchenJin YuchenJin commented Sep 29, 2021

M2d: relax --> VM compile --> run on VM.

Currently, the VM compiler only supports compiling a call-packed form Relax program with static shape. PrimFunc lowering and symbolic shape compilation will be in future PRs.

(Note: we relax the VM constant pool to contain TVMRetValue instead of ObjectRef to support emitting DataType to the pool.)

@YuchenJin YuchenJin marked this pull request as ready for review October 1, 2021 20:06
Copy link
Collaborator

@altanh altanh left a comment

Choose a reason for hiding this comment

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

not sure if ready to review yet but I left some initial comments & questions

include/tvm/relax/attrs/memory.h Show resolved Hide resolved
src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/compiler.cc Outdated Show resolved Hide resolved
this->VisitBindingBlock(block);
}
// find the function return value and emit the output
auto ret_reg = this->var_register_map_.find(Downcast<Var>(op->body));
Copy link
Collaborator

Choose a reason for hiding this comment

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

just noting that we need to validate/normalize IR to full SSA (currently the parser doesn't do this) in order to make sure this works (e.g. if someone writes return add(x, y) then this will fail)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we should write a pass to do the normalization.

src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/compiler.cc Outdated Show resolved Hide resolved
src/relax/vm/compiler.cc Outdated Show resolved Hide resolved
src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/executable.cc Outdated Show resolved Hide resolved
Copy link
Collaborator

@altanh altanh left a comment

Choose a reason for hiding this comment

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

a few more comments/nits, overall I would like if we had more TODO comments in the code to note what is missing/not supported yet since I think it's pretty easy to miss. Also could you double check running linter on all the files just in case? thx 🙏

src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/compiler.cc Outdated Show resolved Hide resolved
@YuchenJin
Copy link
Collaborator Author

a few more comments/nits, overall I would like if we had more TODO comments in the code to note what is missing/not supported yet since I think it's pretty easy to miss. Also could you double check running linter on all the files just in case? thx 🙏

Thanks @altanh for the great suggestion, we should always add TODOs to prevent us from forgetting something during the set of milestone landings!

I fixed linting issues for the files changed in this PR, but there are quite a few more in other files. I think we could submit a separate PR to fix those ones.

Copy link
Collaborator

@altanh altanh left a comment

Choose a reason for hiding this comment

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

LGTM with super minor nits, merge when ready 💪

python/tvm/relax/base.py Outdated Show resolved Hide resolved
src/relax/vm/compiler.cc Outdated Show resolved Hide resolved
src/relax/vm/compiler.cc Outdated Show resolved Hide resolved
src/relax/vm/compiler.cc Show resolved Hide resolved
src/relax/vm/compiler.cc Outdated Show resolved Hide resolved
tests/python/relax/test_vm.py Outdated Show resolved Hide resolved
@ZihengJiang
Copy link
Contributor

LGTM! Thanks @YuchenJin

@YuchenJin YuchenJin merged commit ae0287c into relax Oct 6, 2021
@YuchenJin
Copy link
Collaborator Author

Thank you so much @altanh @ZihengJiang for the review! :)

@YuchenJin YuchenJin deleted the vm-compiler branch October 6, 2021 22:34
tqchen pushed a commit that referenced this pull request Oct 30, 2021
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
YuchenJin added a commit that referenced this pull request Nov 10, 2021
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
YuchenJin added a commit that referenced this pull request Jan 27, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
YuchenJin added a commit that referenced this pull request Mar 2, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit to yongwww/relax that referenced this pull request Mar 14, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit to yongwww/relax that referenced this pull request Mar 22, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit to yongwww/relax that referenced this pull request Mar 23, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit to yongwww/relax that referenced this pull request Apr 6, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit to yongwww/relax that referenced this pull request Apr 12, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
MasterJH5574 pushed a commit to MasterJH5574/tlc-relax that referenced this pull request Apr 13, 2022
In this PR, I introduce a StmtFunctor `RenewDefs` for deep copy all definition nodes in PrimFunc (including Var, Buffer, and IterVar). This functor can create a new PrimFunc with the same behavior as the old one but contains different Nodes.

This Functor may help TIR fusion or inline multiple PrimFuncs

(cherry picked from commit 445d36e63b4e10be7c4fa7f159c55c20bb1ad06e)
jinhongyii pushed a commit to jinhongyii/relax that referenced this pull request May 7, 2022
In this PR, I introduce a StmtFunctor `RenewDefs` for deep copy all definition nodes in PrimFunc (including Var, Buffer, and IterVar). This functor can create a new PrimFunc with the same behavior as the old one but contains different Nodes.

This Functor may help TIR fusion or inline multiple PrimFuncs

(cherry picked from commit 445d36e63b4e10be7c4fa7f159c55c20bb1ad06e)
yongwww pushed a commit that referenced this pull request May 10, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit that referenced this pull request May 11, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
YuchenJin added a commit that referenced this pull request Jun 1, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
jinhongyii pushed a commit to jinhongyii/relax that referenced this pull request Jun 5, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit to yongwww/relax that referenced this pull request Jun 12, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit to yongwww/relax that referenced this pull request Jul 15, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
yongwww pushed a commit that referenced this pull request Aug 14, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit that referenced this pull request Oct 14, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
MasterJH5574 added a commit to MasterJH5574/tlc-relax that referenced this pull request Nov 9, 2022
* relax.cumsum

* Legalizer for expand_dims

* relax.trilu

* relax.cast

* Legalizer for batch_norm and flatten

* relax.take

* relax.full

* relax.split

* relax.broadcast_to

* relax.strided_slice

* relax.image.resize2d

* relax.nn.max_pool2d

* relax.nn.adaptive_avg_pool2d
YuchenJin added a commit that referenced this pull request Nov 18, 2022
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
MasterJH5574 added a commit to MasterJH5574/tlc-relax that referenced this pull request Nov 20, 2022
* relax.cumsum

* Legalizer for expand_dims

* relax.trilu

* relax.cast

* Legalizer for batch_norm and flatten

* relax.take

* relax.full

* relax.split

* relax.broadcast_to

* relax.strided_slice

* relax.image.resize2d

* relax.nn.max_pool2d

* relax.nn.adaptive_avg_pool2d
jinhongyii pushed a commit to jinhongyii/relax that referenced this pull request Dec 10, 2022
* relax.cumsum

* Legalizer for expand_dims

* relax.trilu

* relax.cast

* Legalizer for batch_norm and flatten

* relax.take

* relax.full

* relax.split

* relax.broadcast_to

* relax.strided_slice

* relax.image.resize2d

* relax.nn.max_pool2d

* relax.nn.adaptive_avg_pool2d
vinx13 pushed a commit to vinx13/relax that referenced this pull request Dec 14, 2022
* relax.cumsum

* Legalizer for expand_dims

* relax.trilu

* relax.cast

* Legalizer for batch_norm and flatten

* relax.take

* relax.full

* relax.split

* relax.broadcast_to

* relax.strided_slice

* relax.image.resize2d

* relax.nn.max_pool2d

* relax.nn.adaptive_avg_pool2d
YuchenJin added a commit that referenced this pull request Jan 13, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
YuchenJin added a commit that referenced this pull request Jan 14, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit to junrushao/relax that referenced this pull request Jan 25, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit to junrushao/relax that referenced this pull request Jan 26, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit to junrushao/relax that referenced this pull request Jan 29, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit to junrushao/relax that referenced this pull request Feb 5, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit to junrushao/relax that referenced this pull request Feb 6, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit that referenced this pull request Feb 8, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit that referenced this pull request Feb 8, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit that referenced this pull request Feb 8, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit that referenced this pull request Feb 8, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit that referenced this pull request Feb 9, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
junrushao pushed a commit that referenced this pull request Feb 9, 2023
* VM compiler.

* Update.

* Compile IRmodule; expose Python api

* Add dtype contant serialization and type hint.

* Address comments.

* Add todos and fix lint.

* Update

* Update.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants