Skip to content

numpy conversion is wrong when the storage offset is nonzero #148

@bamos

Description

@bamos

Hi, it seems like the numpy conversion ignores the storage offset:

In [9]: x = torch.randn(4)

In [10]: x
Out[10]:

-0.3685
-0.7098
 0.5450
 0.7965
[torch.FloatTensor of size 4]

In [11]: y = x[2:]

In [12]: x.storage_offset()
Out[12]: 0

In [13]: y.storage_offset()
Out[13]: 2

In [14]: x.numpy()
Out[14]: array([-0.36845183, -0.70976418,  0.54498219,  0.79646742], dtype=float32)

In [15]: y.numpy()
Out[15]: array([-0.36845183, -0.70976418], dtype=float32)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions