)]}'
{
  "commit": "2e6ee08eafc328b82a965e49d106d61828c1d623",
  "tree": "7021d38632a2ea2de076442a7b1f0d5b9a3c4d21",
  "parents": [
    "2345e6ea2665dcc681c78cdc2d2da650d87130c3"
  ],
  "author": {
    "name": "Soowon Jeong",
    "email": "soowon1106@gmail.com",
    "time": "Thu Apr 09 03:35:22 2026 +0900"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Wed Apr 08 14:35:22 2026 -0400"
  },
  "message": "[BugFix] Align `tir.round` to ties-to-even across all backends (#19368)\n\n## Problem\n\n`tir.round` constant-folds using `std::nearbyint` (IEEE 754\nties-to-even), but all backends lower it to platform `round()` which\nuses ties-away-from-zero. This means compiled code can produce different\nresults from constant-folded code for midpoint values:\n\n| Input | Constant-fold (ties-to-even) | Compiled (ties-away) |\n|-------|-----|------|\n| 0.5   | 0.0 | 1.0  |\n| 2.5   | 2.0 | 3.0  |\n| -0.5  | 0.0 | -1.0 |\n\nThis was identified as a follow-up to #19367 — see [this\ncomment](https://github.com/apache/tvm/pull/19367#issuecomment-4201800320).\n\n## Fix\n\nAlign all backends to use ties-to-even intrinsics, matching the\nconstant-folding behavior:\n\n| Backend | Before | After |\n|---------|--------|-------|\n| LLVM/ROCm/Hexagon | `llvm::Intrinsic::round` |\n`llvm::Intrinsic::nearbyint` |\n| NVPTX | `__nv_round[f]` | `__nv_nearbyint[f]` |\n| CUDA | `round`/`roundf` | `nearbyint`/`nearbyintf` (f16/bf16 already\nused `hrint`) |\n| Metal/OpenCL | `round` | `rint` |\n| Vulkan/SPIR-V | `GLSLstd450Round` | `GLSLstd450RoundEven` |\n\nAlso fixes OpenCL codegen where `tir.nearbyint` was incorrectly mapped\nto OpenCL `round()` instead of `rint()`.\n\nUpdates `op.h` documentation to explicitly state ties-to-even semantics\nfor both `round()` and `nearbyint()`.\n\n## Testing\n\n```\npython -m pytest tests/python/tirx-base/test_tir_intrin.py -xvs\n```\n\nNew `test_round_ties_to_even` verifies midpoint inputs `[0.5, 1.5, 2.5,\n3.5, -0.5, -1.5, -2.5, -3.5]` produce ties-to-even results on the LLVM\nbackend. All 12 tests pass (10 passed, 2 skipped for CUDA).\n\n---------\n\nCo-authored-by: Claude Opus 4.6 (1M context) \u003cnoreply@anthropic.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "66d9d932b3fa036369efe463997c9ec899b74105",
      "old_mode": 33188,
      "old_path": "include/tvm/tirx/op.h",
      "new_id": "c953f12e387065db1183b35821e5960fd85df9fd",
      "new_mode": 33188,
      "new_path": "include/tvm/tirx/op.h"
    },
    {
      "type": "modify",
      "old_id": "0f7120b466507cfad3f93b334d457854896d88bc",
      "old_mode": 33188,
      "old_path": "python/tvm/topi/testing/roi_pool_python.py",
      "new_id": "583800e9828bc1ba3df218feac1d8845b1576885",
      "new_mode": 33188,
      "new_path": "python/tvm/topi/testing/roi_pool_python.py"
    },
    {
      "type": "modify",
      "old_id": "54a4aeba50bea6645bcbe594806b8a7e3c71e18e",
      "old_mode": 33188,
      "old_path": "python/tvm/topi/vision/roi_pool.py",
      "new_id": "2e86066c5b23b8336b1c61d068a8f13d4b7566ee",
      "new_mode": 33188,
      "new_path": "python/tvm/topi/vision/roi_pool.py"
    },
    {
      "type": "modify",
      "old_id": "79e91c20a3b891a4a2aaa9366b7004e5d88ea35e",
      "old_mode": 33188,
      "old_path": "src/target/llvm/intrin_rule_hexagon.cc",
      "new_id": "e330dba4e1c7c7e6b3c951e8b6e34cb0f320bfbe",
      "new_mode": 33188,
      "new_path": "src/target/llvm/intrin_rule_hexagon.cc"
    },
    {
      "type": "modify",
      "old_id": "468f0fb7b59f4902bc0fbb2fa4c299af60a2d1c4",
      "old_mode": 33188,
      "old_path": "src/target/llvm/intrin_rule_llvm.cc",
      "new_id": "3244deab875ba6eccb3edc4475d291930440434b",
      "new_mode": 33188,
      "new_path": "src/target/llvm/intrin_rule_llvm.cc"
    },
    {
      "type": "modify",
      "old_id": "4560205a609456dfa911a10068c5e92f73413c10",
      "old_mode": 33188,
      "old_path": "src/target/llvm/intrin_rule_nvptx.cc",
      "new_id": "0707a9a78771ae48bb1a2af44a4d5a5e6d62c852",
      "new_mode": 33188,
      "new_path": "src/target/llvm/intrin_rule_nvptx.cc"
    },
    {
      "type": "modify",
      "old_id": "6d72c777834cd7aac0b70bfe3e662ce7388c7080",
      "old_mode": 33188,
      "old_path": "src/target/llvm/intrin_rule_rocm.cc",
      "new_id": "4d542c1299ec8dbbf69d4d9c034809a0a87fab8b",
      "new_mode": 33188,
      "new_path": "src/target/llvm/intrin_rule_rocm.cc"
    },
    {
      "type": "modify",
      "old_id": "5d9135ef223b84453ee45d0c182c5eccb56dc660",
      "old_mode": 33188,
      "old_path": "src/target/source/codegen_opencl.cc",
      "new_id": "b2f78c2dbd37b08ef02b294834ce7b8184186cf5",
      "new_mode": 33188,
      "new_path": "src/target/source/codegen_opencl.cc"
    },
    {
      "type": "modify",
      "old_id": "bcd158432bcd039434a1b08b7c5a001b78c3eae7",
      "old_mode": 33188,
      "old_path": "src/target/source/intrin_rule_cuda.cc",
      "new_id": "d38db9fe8372a44e9bd6acf07bfe3802503b50af",
      "new_mode": 33188,
      "new_path": "src/target/source/intrin_rule_cuda.cc"
    },
    {
      "type": "modify",
      "old_id": "d61bf1256f64781715f91a97545840dddf92878c",
      "old_mode": 33188,
      "old_path": "src/target/source/intrin_rule_metal.cc",
      "new_id": "cea19519ca7fdd675efb87df7f5068e9a22e83ab",
      "new_mode": 33188,
      "new_path": "src/target/source/intrin_rule_metal.cc"
    },
    {
      "type": "modify",
      "old_id": "85084b1a1649978b7da128e159cc8d3122839ce7",
      "old_mode": 33188,
      "old_path": "src/target/source/intrin_rule_opencl.cc",
      "new_id": "ba1873bde694df10335334c597887f82ff723866",
      "new_mode": 33188,
      "new_path": "src/target/source/intrin_rule_opencl.cc"
    },
    {
      "type": "modify",
      "old_id": "cde1e0165f824ed45deadabde1f83e4c2bfa80e5",
      "old_mode": 33188,
      "old_path": "src/target/spirv/intrin_rule_spirv.cc",
      "new_id": "4b1ffc4b6d7f8566582115eea767b0f43213d601",
      "new_mode": 33188,
      "new_path": "src/target/spirv/intrin_rule_spirv.cc"
    },
    {
      "type": "modify",
      "old_id": "0dd06dee934a371251620233d109a84f5077ba3e",
      "old_mode": 33188,
      "old_path": "tests/python/tirx-base/test_tir_intrin.py",
      "new_id": "30676715b8992ff36dd9e37c10b56b8258783e8d",
      "new_mode": 33188,
      "new_path": "tests/python/tirx-base/test_tir_intrin.py"
    }
  ]
}
