KEMBAR78
Confusing as_storage_and_layout(x, want_contiguous=True) behavior · Issue #145561 · pytorch/pytorch · GitHub
Skip to content

Confusing as_storage_and_layout(x, want_contiguous=True) behavior #145561

@eellison

Description

@eellison

🐛 Describe the bug

The following two invocations are not equivalent:

x = ExternKernel.require_contiguous(x)
storage, old_layout = as_storage_and_layout(x, want_contiguous=True)

and

x = ExternKernel.realize_input(x)
storage, old_layout = as_storage_and_layout(x, want_contiguous=True)

This is because as_storage_and_layout(x, want_contiguous=True) will not behave well with ReinterpretView.

See:

        # making the base of x contiguous or stride_ordered will not necessarily make
        # the ReinterpretView either, so don't pass along those arguments

The comment comes from me (oops). this was two years ago and I forget some of the context but I think we were making unnecessary clones.

We should be able to translate what strides the base of x would require for the output ReinterpretView to be contiguous and then fix the layout.

Versions

master

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @aakhundov

Metadata

Metadata

Assignees

No one assigned

    Labels

    internal ramp-up taskTasks that are suitable for new folks w/ high-touch guidance from senior PyTorch folksmodule: inductoroncall: pt2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions