I want to compile a numba function that takes in input as 3D numpy array of float64 and returns a 3D numpy array of float32.
Code:
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No conversion from array(float64, 1d, C) to array(float32, 3d, A) for '$0.18', defined at None
Error:
from numba import njit, types
@njit('types.float32[:,:,:](types.float64[:,:,:])', parallel=True)
def my_function(img):
img = img.transpose((2, 0, 1))
img = (2 / 255) * img.astype(np.float32) - 1.0 # returns float32
img = img.ravel()
return img
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…