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.Module
recursively.- Parameters:
model – a given
torch.nn.Module
instancemodel_cache – a
KernelMapCache
instancedata – 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.Module
instance
- dump_tunable_config(module: Module) dict #
Dump tunable configurations of a
torch.nn.Module
recursively to a dict- Parameters:
module – a given
torch.nn.Module
instance- 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
SparseConv
source_stride – the tensor stride of the input
dilation – the dilation of
SparseConv
layout – the layout of the sparse convolution, only
minuet
,minkowski
, andtorchsparse
are 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.Module
recursively from a dict- Parameters:
module – a given
torch.nn.Module
instanceconfig – the configuration dict
- Returns:
the original
torch.nn.Module
instance
- set_kernel_map_cache(module: Module, cache: KernelMapCache)#
Set kernel map cache for a given
torch.nn.Module
recursively.- Parameters:
module – a given
torch.nn.Module
instancecache – a
KernelMapCache
instance
- Returns:
the original
torch.nn.Module
instance