RawKernel(code, name, options=())¶
User-defined custom kernel.
This class can be used to define a custom kernel using raw CUDA source.
The kernel is compiled at an invocation of the
__call__()method, which is cached for each device. The compiled binary is also cached into a file under the
$HOME/.cupy/kernel_cache/directory with a hashed file name. The cached binary is reused by other processes.
- code (str) – CUDA source code.
- name (str) – Name of the kernel function.
- options (str) – Compile options passed to NVRTC. For details, see https://docs.nvidia.com/cuda/nvrtc/index.html#group__options.
__call__(self, grid, block, args, *, shared_mem=0)¶
Compiles and invokes the kernel.
The compilation runs only if the kernel is not cached.