The GitHub Actions job "Lint" on tvm.git/fix/relax-torch-round has failed.
Run started by GitHub user siyiweigeHEW (triggered by siyiweigeHEW).

Head commit for run:
b5f0e3c99511435361fb2151c3fbbfade37a5562 / HuEnwei <[email protected]>
[Relax][Frontend][Torch] Support torch.round(x, decimals) via 
from_exported_program and fix negative-decimals rounding

torch.export lowers torch.round(x, decimals) (any explicit decimals,
including decimals=0) to aten.round.decimals, but the exported-program
convert map only registered round.default. Any explicit decimals made
from_exported_program fail with "Unsupported function types
['round.decimals']".

Additionally, BaseFXGraphImporter._round scaled every non-zero decimals
by round(x * 10**decimals) / 10**decimals. For negative decimals this
multiplies by 0.1 / 0.01 / ..., which is inexact in floating point: in
float64, torch.round(torch.tensor(25.0), decimals=-1) computed
25 * 0.1 == 2.5000000000000004 and rounded up to 30 instead of 20.

Register "round.decimals" in ExportedProgramImporter.create_convert_map
and branch the decimals != 0 scale in _round to use an exact integer
power of 10: multiply for positive decimals, divide for negative ones
(round(x / 10**|d|) * 10**|d|).

The ties-to-even inner rounding is already provided by upstream #19367 /
#19368 (tir.round -> nearbyint across backends) and is not changed here.

Validated by the verify_patch.py differential harness on the locked
build: Part B (fix + ties-to-even inner round, = latest semantics)
matches PyTorch for all 28 combinations (from_exported_program / from_fx
x decimals {0,1,2,3,-1,-2,-3} x float32/float64), including the
previously-failing round(25, -1) == 20 and round(2.25, 1) == 2.2.

Co-Authored-By: Claude <[email protected]>

Report URL: https://github.com/apache/tvm/actions/runs/33320139869

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to