Consider dropping negative indices support in gather*/scatter* operators
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- api
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Bikeshed
- Stelle
- 566
- Fork
- 72
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di webmachinelearning/webnn
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
webmachinelearning/webnn#968 · 2 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
webmachinelearning/webnn#967 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
webmachinelearning/webnn#966 · 5 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
webmachinelearning/webnn#965 · 6 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
webmachinelearning/webnn#964 · 1 commento · 1 reazione ·
Tutte le issue di webmachinelearning/webnn
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nexu-io/open-design#9262 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: streamed Responses API flex_unavailable error maps to 500 InternalServerError instead of 429Apertallm translation
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 85/100
BerriAI/litellm#49736 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] LLM conflict check ignores MNEMOSYNE_LLM_MAX_TOKENS, so reasoning models return empty repliesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
mnemosyne-oss/mnemosyne#1325 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement meshtastic-2.8
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
pskillen/meshflow-api#459 ·