cupy.RawKernel

class cupy.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.

Parameters:

Methods

__call__(self, grid, block, args, *, shared_mem=0)

Compiles and invokes the kernel.

The compilation runs only if the kernel is not cached.

Parameters:
  • grid (tuple) – Size of grid in blocks.
  • block (tuple) – Dimensions of each thread block.
  • args (tuple) – Arguments of the kernel.
  • shared_mem (int) – Dynamic shared-memory size per thread block in bytes.

Attributes

code
name
options