torch.Tensor.storage_offset

Tensor.storage_offset() int

返回self张量在底层存储中的偏移量,用存储元素的数量来表示(而不是字节)。

示例:

>>> x = torch.tensor([1, 2, 3, 4, 5])
>>> x.storage_offset()
0
>>> x[3:].storage_offset()
3
本页目录