cupy.RawModule

class cupy.RawModule(code_or_path, options=())

User-defined custom module.

This class can be used to either compile raw CUDA sources or load CUDA modules (*.cubin). This class is useful when a number of CUDA kernels in the same source need to be retrieved.

For the former case, the CUDA source code is compiled when initializing a new instance of this class, and the kernels can be retrieved by calling get_function(), which will return an instance of RawKernel. (Same as in RawKernel, the generated binary is also cached.)

For the latter case, an existing CUDA binary (*.cubin) can be loaded by providing its path, and kernels therein can be retrieved similarly.

Parameters:

Note

Each kernel in RawModule possesses independent function attributes.

Methods

get_function(self, name)

Retrieve a CUDA kernel by its name from the module.

Parameters:name (str) – Name of the kernel function.
Returns:An RawKernel instance.
Return type:RawKernel
get_texref(self, name)

Retrieve a texture reference by its name from the module.

Parameters:name (str) – Name of the texture reference.
Returns:A CUtexref handle, to be passed to TextureReference.
Return type:size_t

Attributes

code
cubin_path
options