torch.clone — PyTorch 2.7 documentation (original) (raw)
torch.clone(input, *, memory_format=torch.preserve_format) → Tensor¶
Returns a copy of input
.
Note
This function is differentiable, so gradients will flow back from the result of this operation to input
. To create a tensor without an autograd relationship to input
see detach().
Parameters
input (Tensor) – the input tensor.
Keyword Arguments
memory_format (torch.memory_format, optional) – the desired memory format of returned tensor. Default: torch.preserve_format
.
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.