Consider dropping negative indices support in gather*/scatter* operators
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- api
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Bikeshed
- Estrellas
- 566
- Forks
- 72
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de webmachinelearning/webnn
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
webmachinelearning/webnn#968 · 2 comentarios ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
webmachinelearning/webnn#967 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
webmachinelearning/webnn#966 · 5 comentarios ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
webmachinelearning/webnn#965 · 6 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
webmachinelearning/webnn#964 · 1 comentario · 1 reacción ·
Todos los issues de webmachinelearning/webnn
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
virtualmin/virtualmin-gpl#1322 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
kind/bug needs-priority needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
konveyor/tackle2-hub#1166 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
UKGovernmentBEIS/inspect_ai#6268 ·
Los mantenedores suelen responder en 1 día
-
enhancement needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
bherbruck/solvecraft#11246 · 1 comentario · 1 reacción ·