Typing necessary for static Python-Numpy compilers like Pythran and Cython
还没有人认领这个 Issue。
评估
调研方向
首先检查当前 array-api-typing 的能力,并将其与此 issue 中的 Transonic 示例进行比较,包括融合数据类型和数组维度。完成标准是确定这些签名目前是否可以表达;如果不能,则定义缺失的能力及其未来可能的发展方向。
由索引模型根据 Issue 内容生成。
描述
Static Python-Numpy compilers like Pythran and Cython (and others) need type information.
For Transonic (a tools to use Python-Numpy compilers, see https://transonic.readthedocs.io), I had to implement a simple system to be able to give enough information in Python about the types supported by functions.
I give here an example of what is possible (more complex things are sometimes needed but this is the minimum, fused data-types and "fused" number of dimensions of the array):
import numpy as np
from transonic import Array, NDim, Type, boost
T = Type(int, np.complex128)
N = NDim(1, 3)
A = Array[T, N]
A1 = Array[np.float32, N + 1]
@boost
def compute(a: A, b: A, c: T, d: A1, e: str):
...
It would be great if array-api-typing could be good enough to be able to express such things in a quite simple way.
Note that this leads to the following possible Pythran signatures:
export compute(complex128[:, :, :], complex128[:, :, :], complex128, float32[:, :, :, :], str)
export compute(complex128[:], complex128[:], complex128, float32[:, :], str)
export compute(int[:, :, :], int[:, :, :], int, float32[:, :, :, :], str)
export compute(int[:], int[:], int, float32[:, :], str)
and Cython "signatures":
import cython
import numpy as np
cimport numpy as np
ctypedef fused __compute__Array_TypeIint_complex128I_NDimI1_3I:
np.ndarray[np.complex128_t, ndim=1]
np.ndarray[np.complex128_t, ndim=3]
np.ndarray[np.int32_t, ndim=1]
np.ndarray[np.int32_t, ndim=3]
ctypedef fused __compute__Array_float32_NDimI1_3Ip1:
np.ndarray[np.float32_t, ndim=2]
np.ndarray[np.float32_t, ndim=4]
ctypedef fused __compute__TypeIint_complex128I:
cython.int
np.complex128_t
cpdef compute(__compute__Array_TypeIint_complex128I_NDimI1_3I a, __compute__Array_TypeIint_complex128I_NDimI1_3I b, __compute__TypeIint_complex128I c, __compute__Array_float32_NDimI1_3Ip1 d, cython.str e)
Is there already enough in array-api-typing to be able to express such things? If not, would it be possible in future?
- 主要语言
- Python
- 星标
- 27
- 派生
- 6
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
data-apis/array-api-typing 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 38/100
data-apis/array-api-typing#70 · 7 条评论 ·
-
CI + lefthook 未关闭👷 CI
难度 2/5 1-3 小时 新手友好度 45/100
data-apis/array-api-typing#40 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 25/100
data-apis/array-api-typing#30 · 3 个 reaction ·
-
✅ tests
data-apis/array-api-typing#25 · 1 条评论 · 1 个 reaction · 已指派 1 人 ·
-
难度 4/5 3-5 天 新手友好度 25/100
data-apis/array-api-typing#23 · 6 条评论 ·
查看 data-apis/array-api-typing 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
stephrobert/dsoxlab#238 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
sublimehq/package_control#1780 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 70/100
nwg-piotr/nwg-displays#145 ·