Skip to content

[TVMScript] Handle undefined functions when dumping IRModule#19583

Merged
tlopex merged 1 commit into
apache:mainfrom
ConvolutedDog:fix-dump-in-primfuncpass
May 19, 2026
Merged

[TVMScript] Handle undefined functions when dumping IRModule#19583
tlopex merged 1 commit into
apache:mainfrom
ConvolutedDog:fix-dump-in-primfuncpass

Conversation

@ConvolutedDog

Copy link
Copy Markdown
Contributor

PrimFuncPass temporarily clears the module slot for the function being transformed before calling pass_func. Dumping the IRModule mid-pass can therefore see undefined BaseFuncs and crash in SortableFunction when calling tvm::Dump(). Guard with func.defined(), assign a fallback sort priority, and log instead of dereferencing.

PrimFuncPass temporarily clears the module slot for the function being
transformed before calling pass_func. Dumping the IRModule mid-pass can
therefore see undefined BaseFuncs and crash in SortableFunction when
calling tvm::Dump(). Guard with func.defined(), assign a fallback sort
priority, and log instead of dereferencing.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the SortableFunction constructor in src/script/printer/ir/ir.cc to handle undefined functions, assigning them a specific priority and logging an info message to prevent crashes during debugging. The reviewer identified that the current implementation inconsistently handles the main function when it is undefined and noted that a crash could still occur later in the printing loop. A refactoring was suggested to check for undefined functions first and ensure consistent logging and priority assignment.

Comment thread src/script/printer/ir/ir.cc
@tlopex tlopex merged commit 7a81a45 into apache:main May 19, 2026
12 checks passed

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

LGTM

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