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

[Transform] Refactor LegalizeOps #128

Merged

Conversation

SiriusNEO
Copy link
Contributor

@SiriusNEO SiriusNEO commented Feb 16, 2023

@MasterJH5574 brings the very first version of legalizer for relax high-level operators in this PR: #96. This PR refactors the LegalizeOps pass according to the suggestions mentioned in the comments of the PR. In details, it includes:

  • Change the default legalization map to the attribute of operators. By this way we can make better use of op attribute and move the main body of the Pass to C++, making LegalizeOps a more formal Pass and bringing opportunities that we can register legalization without Python in the future.
  • Use decorator to register legalization instead of writing it in the Pass. It is more elegant and brings extensibility. Also by this way we can have a clear code structure since now we separate the implementation in different files. As we will have more and more legalization for operators, putting them in a single file is not promising.
  • Preserve the customize map part. It looks good for now.

Ubospica pushed a commit to Ubospica/relax-develop that referenced this pull request Feb 16, 2023
python/tvm/relax/transform/legalize_ops/common.py Outdated Show resolved Hide resolved
python/tvm/relax/transform/legalize_ops/__init__.py Outdated Show resolved Hide resolved
include/tvm/relax/op_attr_types.h Outdated Show resolved Hide resolved
python/tvm/runtime/object_generic.py Outdated Show resolved Hide resolved
src/relax/transform/legalize_ops.cc Outdated Show resolved Hide resolved
src/relax/transform/legalize_ops.cc Outdated Show resolved Hide resolved
src/relax/transform/legalize_ops.cc Outdated Show resolved Hide resolved
src/relax/transform/utils.cc Outdated Show resolved Hide resolved
src/relax/transform/legalize_ops.cc Outdated Show resolved Hide resolved
src/relax/transform/legalize_ops.cc Outdated Show resolved Hide resolved
@SiriusNEO SiriusNEO force-pushed the mlc-dev/2023-02-16-legalizer-refactor branch from 9001753 to e9811cf Compare February 17, 2023 13:44
@MasterJH5574 MasterJH5574 merged commit 6bcd34d into mlc-ai:relax Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants