Skip to content

Immutable assignment (akin to array.at[...] in JAX) #159784

@keunhong

Description

@keunhong

🚀 The feature, motivation and pitch

torch.compile, torch.func and friends do not like mutable operations. However, sometimes assignment is the most concise way to implement an operation.

JAX has an immutable assignment operator (https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html). Could a similar feature be added to PyTorch tensors?

Alternatives

No response

Additional context

No response

cc @bdhirsh @ezyang @chauhang @penguinwu @zou3519 @Chillee @samdow @kshitij12345 @albanD

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: functionalizationused for issues that are specific to functionalization (AOTAutograd bugs should start w aotdispatch)module: functorchPertaining to torch.func or pytorch/functorchmodule: pt2-dispatcherPT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op,oncall: 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