Portable div(rounding_mode="trunc") and fmod round int64 values through double
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
🐛 Describe the bug
The portable div with rounding_mode="trunc" and fmod give wrong results for int64 values above 2^53:
import torch
from executorch.exir import to_edge
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer
class M(torch.nn.Module):
def forward(self, a, b):
return torch.div(a, b, rounding_mode="trunc"), torch.fmod(a, b)
a = torch.tensor([(1 << 62) + 3, -((1 << 62) + 3), 9007199254740993])
b = torch.tensor([3, 10, 2])
prog = to_edge(torch.export.export(M(), (a, b))).to_executorch()
print([t.tolist() for t in _load_for_executorch_from_buffer(prog.buffer).forward((a, b))])
print([t.tolist() for t in M()(a, b)])
[[1537228672809129216, -461168601842738816, 4503599627370496], [1, -4, 0]]
[[1537228672809129302, -461168601842738790, 4503599627370496], [1, -7, 1]]
div.out_mode and div.Scalar_mode_out compute the integer quotient with /, then call std::trunc on it, which converts it to double and back. fmod.Tensor_out and fmod.Scalar_out switch every integer compute type to Double and use std::fmod. Integer division already truncates, and % gives the fmod result directly, so neither needs a double.
I'll open a PR that skips std::trunc for integer types and computes integer fmod with %.
Versions
executorch 1.5.1 (kernels/portable/cpu/op_div.cpp and op_fmod.cpp are the same on main at 5b14a2f), torch 2.14.1+cpu, Python 3.12, Linux x86_64 (WSL2).
cc @larryliu0820 @manuelcandales @JakeStevens
- 主要语言
- Python
- 星标
- 5.1k
- 派生
- 1.2k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 698
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/executorch 的其他 Issue
-
enhancement triaged
难度 2/5 半天 新手友好度 68/100
pytorch/executorch#21640 ·
维护者通常 1 天内回复
-
[Rpi5 setup] Make Raspberry Pi cross-compiled binaries run out of the box on supported OS versions可能已有人在做 @digantdesai 今天认领。 未关闭module: microcontrollers rfc
难度 5/5 一周以上 新手友好度 35/100
pytorch/executorch#24228 · 已指派 2 人 ·
维护者通常 1 天内回复
-
[ET-VK] fp16 linear on an RDNA3.5 iGPU: default (texture) export runs at ~1.1 TFLOP/s, coopmat unreachable without buffer storage, and the stock buffer path is ~20x less accurate可能已有人在做 @SS-JIA 今天认领。 未关闭module: vulkan rfc
难度 4/5 3-5 天 新手友好度 42/100
pytorch/executorch#24196 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[QNN] 16a8w: gathered tensor read wrong by a consumer that only feeds a graph output可能已有人在做 @psiddh 今天认领。 未关闭bug module: qnn partner: qualcomm
难度 4/5 3-5 天 新手友好度 48/100
pytorch/executorch#24125 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Elastic on-device inference - swap LLM mid-generation and carry KV cache (molt / kvine)可能已有人在做 @mergennachin 今天认领。 未关闭module: llm/evaluation rfc
难度 5/5 一周以上 新手友好度 20/100
pytorch/executorch#24106 · 已指派 2 人 ·
维护者通常 1 天内回复
查看 pytorch/executorch 的全部 Issue
相似的 Issue
-
changelog investigate
难度 2/5 1-3 小时 新手友好度 67/100
ramnes/notion-sdk-py#433 ·
-
docs pkg:core
难度 1/5 1 小时以内 新手友好度 84/100
pydantic/pydantic-ai#11929 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
intake/intake-esm#789 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
MemMachine/MemMachine#1877 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
openedx/openedx-authz#579 ·
维护者通常 1 天内回复