torch.clone#
- 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 theresult of this operation to
input. To create a tensor without anautograd relationship toinputseedetach().In addition, when
torch.preserve_formatis used:If the input tensor is dense (i.e., non-overlapping strided),its memory format (including strides) is retained.Otherwise (e.g., a non-dense view like a stepped slice),the output is converted to the dense (contiguous) format.- Parameters
input (Tensor) – the input tensor.
- Keyword Arguments
memory_format (
torch.memory_format, optional) – the desired memory format ofreturned tensor. Default:torch.preserve_format.