Spell out where views are allowed
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python, pytorch
調査の方向性
コピー、ビュー、ミューテーションに関するリンク先のセクションから始め、特に sum の例に注目して array_api_compat PR 298 を確認してください。ビューを生成する一覧中の関数を、issue で取り上げられている他の操作と比較し、ビューをいつ許可するかについて、明示的で合意された範囲を文書化してください。標準がこれらのケースを明確に解決していれば完了です。
索引モデルが issue の本文から書いたものです。
説明
In https://data-apis.org/array-api/latest/design_topics/copies_views_and_mutation.html, the Standard says
Array API consumers are strongly advised to avoid any mutating operations when an array object may [...] be a “view” [...] It is not always clear, however, when a library will return a view and when it will return a copy. This standard does not attempt to specify this—libraries may do either.
The above is fine after __getitem__ , asarray(..., copy=None), astype(..., copy=False), and similar functions that are explicitly explained by the standard to potentially return views.
However, there are a few corner cases where views could be possible but a normal user is very unlikely to think about them.
I just stumbled on one in https://github.com/data-apis/array-api-compat/pull/298, where array_api_compat.torch.sum(x, dtype=x.dtype, axis=()) was accidentally returning x instead of a copy of it.
There are a few more cases where a library could try to be smart; for example
- search functions (
min,max, other?) could return a view to the minimum/maximum point - replacement functions (
minimum,maximum,clip,where) could return one of the input arrays when there is nothing to do - same for arithmetic functions (
__add__/__sub__vs. 0,__mul__/__div__vs. 1, etc.) - same for sort functions when they realise the input is already sorted
- possibly more
In real life, I expect end users to assume that the above functions will always return a copy.
I think the standard should spell this out, limiting the possibily of views to an explicit list of allowed functions:
__getitem__asarrayastype__dlpack__from_dlpackreshapebroacast_tobroadcast_arrays- ...more?
- 主要言語
- Python
- スター
- 131
- フォーク
- 49
- 平均マージ
- 2日 8時間
- マージ済み PR(30日)
- 6
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
data-apis/array-api-compat のほかの issue
-
blocked by upstream
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
data-apis/array-api-compat#439 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
data-apis/array-api-compat#395 · コメント 2 件 ·
-
Release 1.16 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
data-apis/array-api-compat#476 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
data-apis/array-api-compat#473 · コメント 4 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
data-apis/array-api-compat#465 · コメント 3 件 ·
data-apis/array-api-compat の issue をすべて見る
似ている issue
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
simonw/sqlite-utils#872 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100