hamzaqureshi5 opened a new pull request, #20025:
URL: https://github.com/apache/tvm/pull/20025
relax.build(target="llvm") hard-crashed during LLVM codegen verification for
avg_pool2d with input shape [N, C=4, H(even>=6), W=3], e.g. [1,4,6,3]:
InternalError: LLVM module verification failed:
Instruction does not dominate all uses!
%314 = shufflevector <4 x float> %287, <4 x float> %311, <2 x i32>
<i32 2, i32 6>
%90 = shufflevector <2 x float> %314, <2 x float> %89, <4 x i32>
<i32 0, 1, 2, 3>
Root cause is an LLVM optimizer bug, not TVM codegen. The TIR TVM lowers is
scalar and the IR TVM emits verifies clean (both llvm::verifyModule and llvm-as
accept it); the crash only appears at opt-level >= 2. Running stock `opt
-passes='default<O2>'` on TVM's valid IR reproduces the identical "does not
dominate all uses" abort, so LLVM's own vectorizer turns valid IR into a
structurally-invalid module (C=4 fills a 4-wide vector and W=3 misaligns the
strided gather, steering the SLP/loop vectorizer into the bug).
Rather than hard-crash on a backend-optimizer bug, CodeGenLLVM::Finish() now
keeps a verified clone of the pre-optimization module and, if the optimized
module fails verification, warns and falls back to that known-good module. The
build then produces correct (unoptimized) code and never emits the broken
module. The pre-opt Verify() still throws, so genuine TVM codegen bugs remain
surfaced.
Adds a numerical regression test in test_vm_build.py covering the crashing
and neighbouring shapes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]