Rate this Page

torch.Tensor.set_#

Tensor.set_(source=None,storage_offset=0,size=None,stride=None)Tensor#

Sets the underlying storage, size, and strides. Ifsource is a tensor,self tensor will share the same storage and have the same size andstrides assource. Changes to elements in one tensor will be reflectedin the other.

Ifsource is aStorage, the method sets the underlyingstorage, offset, size, and stride.

Parameters
  • source (Tensor orStorage) – the tensor or storage to use

  • storage_offset (int,optional) – the offset in the storage

  • size (torch.Size,optional) – the desired size. Defaults to the size of the source.

  • stride (tuple,optional) – the desired stride. Defaults to C-contiguous strides.