Skip to content

expanded scalar is not contiguous #3919

@shekhovt

Description

@shekhovt

torch.Tensor(1,1).expand(1,2).view(1,2)

Traceback (most recent call last):
File "", line 1, in
RuntimeError: invalid argument 1: input is not contiguous at /pytorch/torch/lib/TH/generic/THTensor.c:231

There are two problems:

  1. view of the same size as the input should always succeed, regardless continuity
  2. an expanded scalar is of course contiguous, no?
    I think these are bugs.

As a feature request, may I suggest that some of the reshaping should also succeed on non-contiguous Tensors as long as only dimensions that are contiguous are affected. Examples:
size (4,4, X), strides (1,4, Y) -> size (16, X), stride (1, Y)

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