Skip to content

tensor.repeat fails because of non-resizable storage. #4054

@maciejkula

Description

@maciejkula

PyTorch version: 0.3.0
Python version: 3.6

This may well be desired behaviour, but it is a departure from 0.2.0. To reproduce:

In [5]: import numpy as np
In [6]: import torch
In [7]: torch.from_numpy(np.arange(10)).repeat(3)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-7-18d470bf42ef> in <module>()
----> 1 torch.from_numpy(np.arange(10)).repeat(3)

/path/torch/tensor.py in repeat(self, *sizes)
    273 
    274         size = torch.Size([a * b for a, b in zip(xsize, repeats)])
--> 275         xtensor.resize_(torch.Size(xsize))
    276         result.resize_(size)
    277         urtensor = result.new(result)

RuntimeError: calling resize_ on a tensor that has non-resizable storage. Clone it first or create a new tensor instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions