[英]How to make numpy functions workable for cupy?
各位晚上好。 我有一些以下代碼片段如下。
我正在嘗試將 numpy 函數轉換為 cupy,因為處理 numpy 需要很長時間。
但是每當我運行這段代碼時,就會出現以下問題。
/usr/local/lib/python3.8/site-packages/cupy/_core/_kernel.pyx in cupy._core._kernel._preprocess_arg()
TypeError: Unsupported type <class 'numpy.ndarray'>
def ps_propagate(data, d, L, beam_c, out_schema = None):
#handle a list of reconstruction planes
if isinstance(d, cp.asarray(list)) or isinstance(d, np.ndarray):
# save time by getting portion of recontruction that doesn't change
# when z changes
old_Ip, npix_plane = ps_propagate_plane(
data, d[0], L, beam_c, out_schema, old_Ip=True)
# Loop through each value of d.
# This saves memory because only the cropped output image is stored.
result = [
ps_propagate_plane(data, z, L ,beam_c, out_schema, old_Ip = old_Ip)
for z in d]
result = concat(result, dim='z')
else: # if only reconstructing at one plane
result = ps_propagate_plane(
data, d, L ,beam_c, out_schema, old_Ip=False)
return result
我假設 numpy 可能沒有被正確翻譯為 cupy,所以將其更改為
cp.asarray(np.ndarray) 或將 'list' 參數更改為 cp.asarray(list) 但沒有解決問題。
任何幫助和建議都會非常有幫助!!!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.