warp.Module#

class warp.Module(name, loader=None)[source]#

Warp module containing kernels and functions to be compiled.

Parameters:

name (str | None)

__init__(name, loader=None)[source]#
Parameters:

name (str | None)

Methods

__init__(name[, loader])

get_kernel_hooks(kernel, device)

get_module_hash([block_dim])

Get the hash of the module for a block_dim variant.

get_module_identifier([block_dim])

Get an abbreviated module name to use for directories and files in the cache.

hash_module()

Get the hash of the module for the current block_dim.

increment_id()

load(device[, block_dim, binary_path, ...])

mark_modified()

register_function(func, scope_locals[, ...])

register_kernel(kernel)

register_struct(struct)

resolve_options(config[, block_dim])

Return a fully-resolved copy of the module options.

unload()

resolve_options(config, block_dim=None)[source]#

Return a fully-resolved copy of the module options.

Resolves None sentinels by falling back to config values and hardcoded defaults. Also includes global config flags that affect compilation, so downstream consumers never need to read config directly.

When block_dim is supplied, it overrides self.options["block_dim"] in the returned dict. This lets Module.load resolve a per-load block_dim variant without mutating the module-level default.

Parameters:

block_dim (int | None)

Return type:

dict

increment_id()[source]#
Return type:

int

register_struct(struct)[source]#
register_kernel(kernel)[source]#
register_function(
func,
scope_locals,
skip_adding_overload=False,
)[source]#
hash_module()[source]#

Get the hash of the module for the current block_dim.

This function always creates a new ModuleHasher and computes the hash.

Return type:

bytes

get_module_hash(block_dim=None)[source]#

Get the hash of the module for a block_dim variant.

If block_dim is None, use the module-level default. If the variant hash has not been computed yet, compute and cache it.

Parameters:

block_dim (int | None)

Return type:

bytes

get_module_identifier(block_dim=None)[source]#

Get an abbreviated module name to use for directories and files in the cache.

Depending on the setting of the "strip_hash" option for this module, the module identifier might include a content-dependent hash as a suffix.

Parameters:

block_dim (int | None)

Return type:

str

load(
device,
block_dim=None,
binary_path=None,
output_arch=None,
meta_path=None,
)[source]#
Parameters:
Return type:

ModuleExec | None

unload()[source]#
mark_modified()[source]#
get_kernel_hooks(kernel, device)[source]#
Parameters:

device (Device)

Return type:

KernelHooks