Consider dropping negative indices support in gather*/scatter* operators
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- api
Hướng nghiên cứu
This issue is a proposal to change spec semantics, not a coded task. Locate the gather/scatter operator definitions in the WebNN spec source (e.g. index.bs) and review indexing rules. Align text to clamp out-of-range indices. The proposal is unresolved, so confirm with maintainers before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The spec currently allows negative indices (index < 0 means index + size) for gather, gatherElements, gatherND, scatterElements, and scatterND. Implementing this turns out to require a workaround in most backends, so I propose relaxing this to "out-of-range indices (including negative ones) are clamped into [0, size)" instead.
Backend workarounds for negative indices support
- TFLite: indices are clamped to [-N, N-1] and negative values are shifted to their non-negative equivalent, either computed in C++ at graph-build time for constant indices, or via a runtime subgraph (Less + Add + Select) for non-constant indices (gather, gatherND, scatterND). gatherElements/scatterElements currently only support constant indices.
- CoreML: gather/gatherElements/gatherND are implemented with clamp and where(index < 0, index + dim, index), mirroring the TFLite approach. scatterElements and scatterND currently pass indices straight through with TODOs to handle negative/out-of-bounds indices.
- ONNX Runtime: According to the ONNX spec ([1],[2],[3],[4],[5]) ORT should natively support negative indices, so we only insert a clamp before the indices. However, from the test results, we've observed that not all execution providers actually support this. For example, OV EP produces wrong results for scatterND/gatherND with negative indices, there is a CL under review to work around this.
Proposal
For gather, gatherElements, gatherND, scatterElements, and scatterND, an index outside [0, size), whether negative or too large, is simply clamped into range, rather than negative indices being interpreted as "offset from the end." This would let every backend only need to insert a clamp for out-of-range handling across implementations, removing both implementation complexity and some per-inference overhead.
@huningxin @reillyeon @RafaelCintron @fdwr @Honry
- Ngôn ngữ chính
- Bikeshed
- Star
- 566
- Fork
- 72
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 webmachinelearning/webnn
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
webmachinelearning/webnn#968 · 2 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
webmachinelearning/webnn#967 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
webmachinelearning/webnn#966 · 5 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
webmachinelearning/webnn#965 · 6 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
webmachinelearning/webnn#964 · 1 bình luận · 1 reaction ·
Tất cả issue của webmachinelearning/webnn
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
pingdotgg/t3code#30228 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
jejjohnson/gaussx#719 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
canonical/temporal-worker-k8s-operator#135 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
5.0.x backport enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
spring-cloud/spring-cloud-function#1507 ·
Maintainer thường phản hồi trong vòng 1 ngày