minuet.utils.helpers#
Functions
|
Make a given value as a tuple of size |
|
Autotune a given |
|
Dump tunable configurations of a |
|
Generate the kernel weight offsets for |
|
Load tunable configurations for a |
|
Set kernel map cache for a given |
- as_tuple(value: T | Tuple[T, ...], *, size: int = 3, name: str | None = None)#
Make a given value as a tuple of size
size- Parameters:
value – The value for making a tuple
size – The size of the tuple
name – The name of the tuple. Useful for showing exceptions.
- Returns:
A tuple of size
size.
- autotune(model: Module, model_cache: KernelMapCache, data: SparseTensor | Iterable[SparseTensor], cache_path: str | None = None)#
Autotune a given
torch.nn.Modulerecursively.- Parameters:
model – a given
torch.nn.Moduleinstancemodel_cache – a
KernelMapCacheinstancedata – an iterable instance that generates :py:class:’~minuet.tensors.SparseTensor’
cache_path – the path to which the autotuned configurations will be stored
- Returns:
the original
torch.nn.Moduleinstance
- dump_tunable_config(module: Module) dict#
Dump tunable configurations of a
torch.nn.Modulerecursively to a dict- Parameters:
module – a given
torch.nn.Moduleinstance- Returns:
the configuration dict
- generate_kernel_offsets(ndim: int, kernel_size: int | Tuple[int, ...], source_stride: int | Tuple[int, ...], dilation: int | Tuple[int, ...], layout: str = 'minuet')#
Generate the kernel weight offsets for
SparseConv- Parameters:
ndim – the dimension of each weight offset
kernel_size – the kernel size of
SparseConvsource_stride – the tensor stride of the input
dilation – the dilation of
SparseConvlayout – the layout of the sparse convolution, only
minuet,minkowski, andtorchsparseare supported
- Returns:
a numpy array consists of the generated sparse convolution
- load_tunable_config(module: Module, config: dict)#
Load tunable configurations for a
torch.nn.Modulerecursively from a dict- Parameters:
module – a given
torch.nn.Moduleinstanceconfig – the configuration dict
- Returns:
the original
torch.nn.Moduleinstance
- set_kernel_map_cache(module: Module, cache: KernelMapCache)#
Set kernel map cache for a given
torch.nn.Modulerecursively.- Parameters:
module – a given
torch.nn.Moduleinstancecache – a
KernelMapCacheinstance
- Returns:
the original
torch.nn.Moduleinstance