[BugFix][Relax] Add structural_equal verification to subroutine cache lookup by 3em0 · Pull Request #18930 · apache/tvm

@claude

… lookup

SubroutineMixin._get_subroutine() used structural_hash as the sole
cache key without structural_equal verification. If two different
arg_sinfo values produced the same 64-bit hash, the cache would
return a previously compiled function with mismatched parameter
shapes, leading to silently incorrect compiled output.

The fix changes the cache to store a list of (arg_sinfo, result)
pairs per hash bucket and verifies each candidate with
structural_equal before returning. This follows the same pattern
used in block_builder.cc (StructuralHash + StructuralEqual).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

gemini-code-assist[bot]

bot reviewed Mar 25, 2026

@claude

- Extract result tuple into variable and break down setdefault/append
- Use list comprehension for subroutine collection in test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>