Skip to content

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

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions