pisarev opened a new pull request, #646:
URL: https://github.com/apache/tvm-ffi/pull/646

   Fixes #645.
   
   The `StructuralEqual` functor calls `Equal(lhs, rhs, false, 
/*skip_tensor_content=*/true)`, while the `StructuralHash` functor hashes 
content (`skip_tensor_content = false`). The two are used together as the hash 
and key-equal of the constant de-duplication map in Relax VM codegen 
(`const_dedup_map_` in apache/tvm `src/relax/backend/vm/exec_builder.cc`). When 
hash and equal disagree, the map invariant `equal(a, b) => hash(a) == hash(b)` 
does not hold, so two distinct constants of equal shape and dtype get merged on 
a bucket collision and a later op reads the wrong constant.
   
   Which pair collides depends on the STL bucket count, so the same model 
produces wrong output under MSVC and correct output under libstdc++. The defect 
is latent on every platform.
   
   This change makes the functor compare content, so it agrees with the hash. 
Constants that are genuinely equal are still de-duplicated.
   
   Verified on a Windows build (MSVC 19.44, LLVM 18.1.8): after the change, 
YOLO11n det, YOLO11s cls, PP-OCRv5 det and PP-OCRv5 rec all match onnxruntime 
to within floating point; before, det and the PP-OCR models were off by 6 to 61 
percent relative error.
   
   Full analysis in #645.


-- 
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]

Reply via email to