Portable div(rounding_mode="trunc") and fmod round int64 values through double
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
🐛 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
- Ngôn ngữ chính
- Python
- Star
- 5.1k
- Fork
- 1.2k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 698
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytorch/executorch
-
enhancement triaged
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 68/100
pytorch/executorch#21640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Rpi5 setup] Make Raspberry Pi cross-compiled binaries run out of the box on supported OS versionsCó thể đã có người làm @digantdesai đã nhận hôm nay. Đang mởmodule: microcontrollers rfc
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
pytorch/executorch#24228 · 2 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[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 accurateCó thể đã có người làm @SS-JIA đã nhận hôm nay. Đang mởmodule: vulkan rfc
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
pytorch/executorch#24196 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[QNN] 16a8w: gathered tensor read wrong by a consumer that only feeds a graph outputCó thể đã có người làm @psiddh đã nhận hôm nay. Đang mởbug module: qnn partner: qualcomm
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
pytorch/executorch#24125 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Elastic on-device inference - swap LLM mid-generation and carry KV cache (molt / kvine)Có thể đã có người làm @mergennachin đã nhận hôm nay. Đang mởmodule: llm/evaluation rfc
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
pytorch/executorch#24106 · 2 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pytorch/executorch
Issue tương tự
-
changelog investigate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
ramnes/notion-sdk-py#433 ·
-
docs pkg:core
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
pydantic/pydantic-ai#11929 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
intake/intake-esm#789 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
MemMachine/MemMachine#1877 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openedx/openedx-authz#579 ·
Maintainer thường phản hồi trong vòng 1 ngày