python/ray/util/collective/collective_group/gloo_util.py
def copy_tensor(dst_tensor, src_tensor):
    """Copy the content from src_tensor to dst_tensor.

    Args:
        dst_tensor: the tensor to copy from.
        src_tensor: the tensor to copy to.

    Returns:
        None
    """
    copied = True
    if isinstance(dst_tensor, numpy.ndarray) and isinstance(src_tensor, numpy.ndarray):
        numpy.copyto(dst_tensor, src_tensor)
    elif torch_available():
        if isinstance(dst_tensor, torch.Tensor) and isinstance(
            src_tensor, torch.Tensor
        ):
            dst_tensor.copy_(src_tensor)
        elif isinstance(dst_tensor, torch.Tensor) and isinstance(
            src_tensor, numpy.ndarray
        ):
            t = torch.Tensor(src_tensor)
            dst_tensor.copy_(t)
        elif isinstance(dst_tensor, numpy.ndarray) and isinstance(
            src_tensor, torch.Tensor
        ):
            t = src_tensor.numpy()
            numpy.copyto(dst_tensor, t)
        else:
            copied = False
    else:
        copied = False
    if not copied:
        raise ValueError(
            "Unsupported tensor type. Got: {} and {}. Supported "
            "CPU tensor types are: torch.Tensor, numpy.ndarray.".format(
                type(dst_tensor), type(src_tensor)
            )
        )
Copy the content from src_tensor to dst_tensor.

    Args:
        dst_tensor: the tensor to copy from.
        src_tensor: the tensor to copy to.

    Returns:
        None
    
Copy the content from src_tensor to dst_tensor.
Copy the content from src_tensor to dst_tensor .
def copy_tensor(dst_tensor, src_tensor):
    copied = True
    if isinstance(dst_tensor, numpy.ndarray) and isinstance(src_tensor, numpy.ndarray):
        numpy.copyto(dst_tensor, src_tensor)
    elif torch_available():
        if isinstance(dst_tensor, torch.Tensor) and isinstance(
            src_tensor, torch.Tensor
        ):
            dst_tensor.copy_(src_tensor)
        elif isinstance(dst_tensor, torch.Tensor) and isinstance(
            src_tensor, numpy.ndarray
        ):
            t = torch.Tensor(src_tensor)
            dst_tensor.copy_(t)
        elif isinstance(dst_tensor, numpy.ndarray) and isinstance(
            src_tensor, torch.Tensor
        ):
            t = src_tensor.numpy()
            numpy.copyto(dst_tensor, t)
        else:
            copied = False
    else:
        copied = False
    if not copied:
        raise ValueError(
            "Unsupported tensor type. Got: {} and {}. Supported "
            "CPU tensor types are: torch.Tensor, numpy.ndarray.".format(
                type(dst_tensor), type(src_tensor)
            )
        )
def copy_tensor ( dst_tensor , src_tensor ) : copied = True if isinstance ( dst_tensor , numpy . ndarray ) and isinstance ( src_tensor , numpy . ndarray ) : numpy . copyto ( dst_tensor , src_tensor ) elif torch_available ( ) : if isinstance ( dst_tensor , torch . Tensor ) and isinstance ( src_tensor , torch . Tensor ) : dst_tensor . copy_ ( src_tensor ) elif isinstance ( dst_tensor , torch . Tensor ) and isinstance ( src_tensor , numpy . ndarray ) : t = torch . Tensor ( src_tensor ) dst_tensor . copy_ ( t ) elif isinstance ( dst_tensor , numpy . ndarray ) and isinstance ( src_tensor , torch . Tensor ) : t = src_tensor . numpy ( ) numpy . copyto ( dst_tensor , t ) else : copied = False else : copied = False if not copied : raise ValueError ( "Unsupported tensor type. Got: {} and {}. Supported " "CPU tensor types are: torch.Tensor, numpy.ndarray." . format ( type ( dst_tensor ) , type ( src_tensor ) ) )
Copy the content from src_tensor to dst_tensor.
Copy the content from src_tensor to dst_tensor .
"""Copy the content from src_tensor to dst_tensor.

    Args:
        dst_tensor: the tensor to copy from.
        src_tensor: the tensor to copy to.

    Returns:
        None
    """
None
dst_tensor
the tensor to copy from.
the tensor to copy from .
src_tensor
the tensor to copy to.
the tensor to copy to .