malib.utils.general module
- malib.utils.general.iter_dicts_recursively(d1, d2)[source]
Assuming dicts have the exact same structure.
- malib.utils.general.iter_many_dicts_recursively(*d, history=None)[source]
Assuming dicts have the exact same structure, or raise KeyError.
- malib.utils.general.tensor_cast(custom_caster: Optional[Callable] = None, callback: Optional[Callable] = None, dtype_mapping: Optional[Dict] = None, device='cpu')[source]
Casting the inputs of a method into tensors if needed.
- Note:
This function does not support recursive iteration.
- Args:
custom_caster (Callable, optional): Customized caster. Defaults to None. callback (Callable, optional): Callback function, accepts returns of wrapped function as inputs. Defaults to None. dtype_mapping (Dict, optional): Specify the data type for inputs which you wanna. Defaults to None.
- Returns:
Callable: A decorator.