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

[Bugfix][Relax] Remove call to tvm.build for empty TIR module #16561

Merged

Conversation

Lunderberg
Copy link
Contributor

Prior to this commit, if a lowered IRModule does not contain any TIR functions, tvm.relax.build provided an empty tir_mod, which caused a segfault during TIR compilation. This could occur when tvm.relax.build is called without an explicit target argument, for a module that does not define any virtual devices.

This commit updates the _filter_tir utility function to return None if there are no TIR functions, rather than an empty IRModule. In addition, checks for an empty IRModule are added to tvm.build and TIRToRuntime, so that a similar failure mode would raise an exception rather than producing a segfault.

Prior to this commit, if a lowered `IRModule` does not contain any TIR
functions, `tvm.relax.build` provided an empty `tir_mod`, which caused
a segfault during TIR compilation.  This could occur when
`tvm.relax.build` is called without an explicit target argument, for a
module that does not define any virtual devices.

This commit updates the `_filter_tir` utility function to return
`None` if there are no TIR functions, rather than an empty
`IRModule`.  In addition, checks for an empty `IRModule` are added to
`tvm.build` and `TIRToRuntime`, so that a similar failure mode would
raise an exception rather than producing a segfault.
Copy link
Member

@yongwww yongwww 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

@Lunderberg Lunderberg merged commit 7336deb into apache:main Feb 14, 2024
19 checks passed
@Lunderberg Lunderberg deleted the bugfix_remove_build_of_empty_tir_module branch February 14, 2024 13:07
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.

None yet

2 participants