May 2019
Intermediate to advanced
452 pages
12h 16m
English
To use the vectorize decorator, we can use the same syntax as we saw for the JIT decorator. The following code shows the multiple functions implemented with vectorize as a dynamic universal function (DUFunc):
@vectorizedef multiply(p, q): q = p * q
We call it a dynamic universal function because there are no signatures passed into the @vectorize decorator.
When passing signatures, the code would be modified as follows:
@vectorize(["float32(float32, float32)"])def multiply(p, q): q = p * q
Now, let's see how a GPU implementation for NVIDIA CUDA GPUs is followed:
@vectorize(["float32(float32, float32)"], target='cuda')def multiply(p, q): q = p * q
In the case of ROCm (experimental), the following syntax would use AMD ROCm GPUs ...
Read now
Unlock full access