[BugFix][TIRx] Fix VerifyMemory crash for PrimFuncs without target attribute#19382
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies the VerifyMemory_ function in src/tirx/analysis/verify_memory.cc to skip verification for functions without a target attribute, preventing a crash. A review comment suggests refining the documentation within the code to focus on the current logic rather than the previous error state.
…tribute
VerifyMemory_ called TVM_FFI_ICHECK(target.defined()) unconditionally.
When Relax lowers a model it generates host-side helper PrimFuncs
(e.g. for reshape, mean) that carry no kTarget attribute.
These functions hit the ICHECK and abort.
Return {} (no errors) when target is absent. This is semantically
correct: MemoryAccessVerifier::Run() is already gated on
IsGPUDevice(dev_type_), so host-only functions carry no GPU memory
access constraints and require no verification.
bb1b582 to
5f22cd7
Compare
tlopex
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
VerifyMemory_calledTVM_FFI_ICHECK(target.defined())unconditionally. When Relax lowers a model it generates host-side helper PrimFuncs (e.g. forreshape,mean) that carry nokTargetattribute. These functions hit the ICHECK and abort:This surfaces whenever
tvm.compileis called on a Relax module targeting CUDA, because the Relax lowering pipeline produces target-less CPU helper functions alongside the GPU kernels.Fix
Return
{}(no errors) whentargetis absent. This is semantically correct:MemoryAccessVerifier::Run()is already gated onIsGPUDevice(dev_type_), so host-only functions carry no GPU memory access constraints and require no verification. The same early-exit pattern is already used for non-default calling conventions (line 184–186).