Skip to content

vllm.model_executor.kernels.linear.mixed_precision.MPLinearKernel

_shallow_copy(param)

A new object of param's class sharing its data, with its own copy of the attributes (e.g. dim tags) for a transform to retag.

Source code in vllm/model_executor/kernels/linear/mixed_precision/MPLinearKernel.py
def _shallow_copy(param: torch.Tensor) -> torch.Tensor:
    """A new object of ``param``'s class sharing its data, with its own copy of
    the attributes (e.g. dim tags) for a transform to retag."""
    copy = torch.Tensor._make_subclass(type(param), param.data, param.requires_grad)
    copy.__dict__.update(param.__dict__)
    return copy