Skip to content

vllm.model_executor.layers.quantization.utils.copy_numel_counter

copy_missing_attrs

copy_missing_attrs(old: Tensor, new: Tensor) -> None

Copies any attrs present in old but not in new to new

Source code in vllm/model_executor/layers/quantization/utils/copy_numel_counter.py
def copy_missing_attrs(old: torch.Tensor, new: torch.Tensor) -> None:
    """Copies any attrs present in `old` but not in `new` to `new`"""
    new_attrs = set(dir(new))
    attrs_to_set = {}
    for attr in dir(old):
        if attr not in new_attrs:
            attrs_to_set[attr] = getattr(old, attr)
    set_weight_attrs(new, attrs_to_set)