LngelKyo opened a new pull request, #20131:
URL: https://github.com/apache/tvm/pull/20131

   #19368 aligned tir.round to ties-to-even "across all backends" and moved 
LLVM, CUDA, NVPTX, ROCm, Hexagon, Metal, OpenCL, SPIR-V and WebGPU. It did not 
touch src/target/intrin_rule.cc, so the default.FLowerIntrinsic rule — which 
the c target uses — still lowers through FloatSuffix and emits round/roundf, 
i.e. ties away from zero.
   
   This disagrees with:
   - constant folding, which uses std::nearbyint (src/tirx/op/op.cc);
   - the CUDA rule, whose own comment says "Use nearbyint (ties-to-even) for 
round to match constant-folding semantics";
   - every other backend after #19368.
   
   **Why CI did not catch it.** test_target_codegen_c_host.py::test_round 
compiles with target="c" and asserts against np.round, which is ties-to-even — 
so the intended semantics was already encoded. It passes only because its input 
is np.random.rand, which does not produce exact midpoints (0 occurrences in 
2,048,000 sampled values). The ties-to-even test added by #19368 
(test_tir_intrin.py::test_round_ties_to_even) only runs target="llvm", so no 
test covered the C path's tie behaviour.
   
   The first commit adds the midpoint vector — reused verbatim from 
test_round_ties_to_even — to the existing C-host test and it fails:
   
   ```
   E   Mismatch at indices:
   E    [0]: 1.0 (ACTUAL), 0.0 (DESIRED)
   E    [2]: 3.0 (ACTUAL), 2.0 (DESIRED)
   E    [4]: -1.0 (ACTUAL), -0.0 (DESIRED)
   E    [6]: -3.0 (ACTUAL), -2.0 (DESIRED)
   ```
   
   The second commit renames round→nearbyint before the float suffix, mirroring 
the existing CUDA rule, and it passes.
   
   One note for reviewers: nearbyint honours the current floating-point 
environment and is ties-to-even under the default FE_TONEAREST. That is the 
same guarantee LLVM, CUDA, Metal and OpenCL already rely on after #19368; this 
PR does not introduce a new assumption.
   


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