Rate this Page

torch.clone#

torch.clone(input,*,memory_format=torch.preserve_format)Tensor#

Returns a copy ofinput.

Note

This function is differentiable, so gradients will flow back from theresult of this operation toinput. To create a tensor without anautograd relationship toinput seedetach().

In addition, whentorch.preserve_format is 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.