How should I apply defined function to cupy.array instead of np.vectorize? Has similar function implemented yet in cupy?
I'm writing simulation program in Python 3.6.9.
I'd like to do the simulation in GPU(GTX1060, NVIDIA) with CuPy(6.0.0 for CUDA10.1).
In original code, function numpy.vectorize has used for apply defined function to np.array. However, same function has not implemented yet in CuPy.
Original code (using numpy) is as below:
#For define function
def rate(tmean,x,y,z):
rate = 1/z/(1 + math.exp(-x*(tmean-y)))
#DVR<0
if rate < 0:
rate = 0
return rate
#tmean is temperature data(365,100,100) and loaded as np.array
#paras is parameter(3,100,100)
#vectorized
f = np.vectorize(rate)
#roop
for i in range(365):
#calc developing rate(by function "rate") and accumulate
dvi[i,:,:] = dvi[i-1,:,:] + f(tmean[i,:,:],paras[0],paras[1],paras[2])
I know almost functions of numpy has implemented in CuPy. so I changed
f = np.vectorized(rate)
to
f= cp.vectorized(rate)
but AttributeError occurred.