Will Cupy支持Cython(例如缓冲索引)



我已经实现了自己定义了链链链接,但是因为它太慢了。我已经实施了Cython CPU版本的代码。但是我想通过GPU进一步提高速度。因此,我测试了以下代码,但失败了:

%%cython
import numpy as np
cimport numpy as np
import cupy as cp
cimport cupy as cp
cdef class A:
    def __init__(self):
        pass
    cdef cp_test(self, cp.ndarray[cp.float_t, ndim=2] arr):
        return cp.sum(arr)
a = A()
arr = cp.arange(100).reshape(20,50)
print(a.cp_test(arr))

报告:

    cdef cp_test(self, cp.ndarray[cp.float_t, ndim=2] arr):
                      ^
------------------------------------------------------------
C:Users.ipythoncython_cython_magic_d4940a274af88f0257c368b8a5d0e3f5.pyx:13:23: 'ndarray' is not a type identifier

对不起,但是Cupy当前没有提供Cython界面(我是Cupy开发人员之一)。
该功能请求在https://github.com/cupy/cupy/issues/130。

打开

最新更新