RFC: add APIs for getting elements via a list of indices (i.e., `take`, `take_along_axis`, etc)
还没有人认领这个 Issue。
评估
调研方向
先从提案以及 sorting_functions.md 和 set_functions.md 中链接的规范部分开始,然后比较其中引用的 NumPy、CuPy、Dask、MXNet、Torch 和 TensorFlow API。当项目就 take/put 系列的范围和语义达成一致,并且相关的 Array API 规范得到更新时,这项工作就完成了。
由索引模型根据 Issue 内容生成。
描述
Proposal
Add APIs for getting and setting elements via a list of indices.
Motivation
Currently, the array API specification does not provide a direct means of extracting and setting a list of elements along an axis. Such operations are relatively common in NumPy usage either via "fancy indexing" or via explicit take and put APIs.
Two main arguments come to mind for supporting at least basic take and put APIs:
-
Indexing does not currently support providing a list of indices to index into an array. The principal reason for not supporting fancy indexing stems from dynamic shapes and compatibility with accelerator libraries. However, use of fancy indexing is relatively common in NumPy and similar libraries where dynamically extracting rows/cols/values is possible and can be readily implemented.
-
Currently, the output of a subset of APIs currently included in the standard cannot be readily consumed without manual workarounds if a specification-conforming library implemented only the APIs in the standard. For example,
Background
The following table summarizes library implementations of such APIs:
| op | NumPy | CuPy | Dask | MXNet | Torch | TensorFlow |
|---|---|---|---|---|---|---|
| extracting elements along axis | take |
take |
take |
take |
take/gather |
gather/numpy.take |
| setting elements along axis | put |
put |
-- | -- | scatter |
scatter_nd/tensor_scatter_nd_update |
| extracting elements over matching 1d slices | take_along_axis |
take_along_axis |
-- | -- | -- | gather_nd/numpy.take_alongaxis |
| setting elements over matching 1d slices | put_along_axis |
-- | -- | -- | -- | -- |
While most libraries implement some form of take, fewer implement other complementary APIs.
- 主要语言
- Python
- 星标
- 281
- 派生
- 52
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
data-apis/array-api 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 5/5 一周以上 新手友好度 35/100
-
Maintenance
-
难度 5/5 一周以上 新手友好度 25/100
查看 data-apis/array-api 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100