RFC: add APIs for setting elements via an array of indices (i.e., put, put_along_axis, etc)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia con la discussione sull’indicizzazione di array API in gh-177 e con il commento all’issue array-api collegato, quindi confronta le API elencate di NumPy, CuPy, JAX, PyTorch, TensorFlow, Dask e Ndonnx. Il lavoro è completo quando la proposta definisce un’API e una semantica consolidate e interoperabili per impostare gli elementi tramite indici, incluso il comportamento per gli array immutabili.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Copied and adapted from @kgryte's proposal at gh-177 per https://github.com/data-apis/array-api/issues/177#issuecomment-2883011323
Proposal
Add APIs for setting elements via an array of indices.
Motivation
Currently, the array API specification does not provide a direct means of setting a list of elements along an axis. Such operations are relatively common in NumPy usage either via "fancy indexing" or put APIs.
The main argument is that Indexing does not currently support providing a array of indices to index into an array. The principal reason for not supporting fancy indexing is . However, use of fancy indexing is relatively common in NumPy and similar libraries where dynamically setting rows/cols/values is possible and can be readily implemented. Another reason for not support fancy indexing mutation is that some libraries feature immutable arrays. array_api_extra.at.set demonstrates that it is often sufficient to mutate where possible and create a copy with the specified updates otherwise.
Background
The following table summarizes library implementations of such APIs:
| op | NumPy | CuPy | JAX.numpy | Torch | Tensorflow | Dask.array | Ndonnx |
|---|---|---|---|---|---|---|---|
| setting elements along axis | put |
put |
put |
scatter_? |
scatter_nd? |
? | |
| setting elements over matching 1d slices | put_along_axis |
put_along_axis |
put_along_axis |
scatter_? See pytorch/pytorch#120209. |
scatter_nd? |
? |
Discussion about these function in gh-177 concluded with https://github.com/data-apis/array-api/issues/177#issuecomment-1514155595, especially:
The JAX issue is most difficult to resolve (can be done, but a lot of work still to deal with read-only views or similar), but the lack of API uniformity makes this a hard sell in general.
This seems to be resolved. jax.numpy.put and jax.numpy.put_along_axis are implemented; they just return modifyied copies rather than mutating the array in place.
- Lingua principale
- Python
- Stelle
- 281
- Fork
- 52
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri 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 data-apis/array-api
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Maintenance
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Tutte le issue di data-apis/array-api
Issue simili
-
sponsored
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
Diaoul/subliminal#1382 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
triage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
agentscope-ai/agentscope#2775 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100