Skip to content

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

Merged
Lunderberg merged 1 commit into
apache:mainfrom
Lunderberg:bugfix_remove_build_of_empty_tir_module
Feb 14, 2024
Merged

Lunderberg merged 1 commit into
apache:mainfrom
Lunderberg:bugfix_remove_build_of_empty_tir_module

Conversation

@Lunderberg

Copy link
Copy Markdown
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.

@yongwww yongwww left a comment

Copy link
Copy Markdown
Member

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

2 participants