Skip to content

View CreationMeta are not propagated when chaining views #49824

@albanD

Description

@albanD

As per title.
Example failing code that generates potentially wrong gradients:

import torch

a = torch.rand(10, requires_grad=True).clone()

# View for which inplace are invalid
b = a.unbind(0)
# Chain of view where the last one is valid for inplace
c = b[0].view_as(b[0])

# This one should fail but does not
c.mul_(2)
# This one properly fails
b.mul_(2)

In general, the CreationMeta should be inherited from the previous view to ensure invalid chain of views are properly forbidden.

cc @ezyang @albanD @zou3519 @gqchen @pearu @nikitaved @soulitzer

Metadata

Metadata

Assignees

No one assigned

    Labels

    better-engineeringRelatively self-contained tasks for better engineering contributorsmodule: autogradRelated to torch.autograd, and the autograd engine in generalmodule: correctness (silent)issue that returns an incorrect result silentlysmallWe think this is a small issue to fix. Consider knocking off high priority small issuestriagedThis 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