utils ¶
Utilities for selecting and loading models.
Functions:¶
fastvideo.models.loader.utils.get_param_names_mapping ¶
Creates a mapping function that transforms parameter names using regex patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping_dict | Dict[str, str] | Dictionary mapping regex patterns to replacement patterns | required |
param_name | str | The parameter name to be transformed | required |
Returns:
| Type | Description |
|---|---|
Callable[[str], tuple[str, Any, Any]] | Callable[[str], str]: A function that maps parameter names from source to target format |
Source code in fastvideo/models/loader/utils.py
fastvideo.models.loader.utils.hf_to_custom_state_dict ¶
hf_to_custom_state_dict(hf_param_sd: dict[str, Tensor] | Iterator[tuple[str, Tensor]], param_names_mapping: Callable[[str], tuple[str, Any, Any]]) -> tuple[dict[str, Tensor], dict[str, tuple[str, Any, Any]]]
Converts a Hugging Face parameter state dictionary to a custom parameter state dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hf_param_sd | Dict[str, Tensor] | The Hugging Face parameter state dictionary | required |
param_names_mapping | Callable[[str], tuple[str, Any, Any]] | A function that maps parameter names from source to target format | required |
Returns:
| Name | Type | Description |
|---|---|---|
custom_param_sd | Dict[str, Tensor] | The custom formatted parameter state dict |
reverse_param_names_mapping | Dict[str, Tuple[str, Any, Any]] | Maps back from custom to hf |
Source code in fastvideo/models/loader/utils.py
fastvideo.models.loader.utils.set_default_torch_dtype ¶
Sets the default torch dtype to the given dtype.