I am trying to understand a basic example of signatures for @vectorize targetting cuda and a some doubts appeared.
From here Types and signatures — Numba 0.52.0.dev0+274.g626b40e-py3.7-linux-x86_64.egg documentation I understand that:
"float64(int32, int32)") which specifies a function taking two 32-bit integers and returning a double-precision float.
- Given the former information, I would expect the following signature in the code below (CUDA Ufuncs and Generalized Ufuncs — Numba 0.50.1 documentation)
@vectorize(['float64(float32, float32, float32)'](Output a float64 and input 3 arrays of float32)
So my questions are:
- Why isn´t it
@vectorize(['float64(float32, float32, float32)']?
- To understand how to pass my signatures, how could I for instance use the nb.typeof to create my signatures? For instance if I had TWO input array having the type array(float32, 2d, C) that outputs me TWO single float64 (not an array) would the signature in this case be
from numba import vectorize, cuda
import numpy as np
@vectorize(['float32(float32, float32, float32)', 'float64(float64, float64, float64)'], target='cuda') def cu_discriminant(a, b, c): return math.sqrt(b ** 2 - 4 * a * c) N = 10000 dtype = np.float32 # prepare the input A = np.array(np.random.sample(N), dtype=dtype) B = np.array(np.random.sample(N) + 10, dtype=dtype) C = np.array(np.random.sample(N), dtype=dtype) D = cu_discriminant(A, B, C) print(D) # print result