Skip to content

Add torch.fill_diagonal #21796

@colesbury

Description

@colesbury

🚀 Feature

Implement torch.fill_diagonal based on numpy.fill_diagonal

See https://docs.scipy.org/doc/numpy/reference/generated/numpy.fill_diagonal.html

Motivation

Alex asked me how to do this today.

Alternatives

The following works but isn't obvious and may not work for non-strided Tensors:

torch.diagonal(x).fill_(value)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA request for a proper, new feature.module: numpyRelated to numpy support, and also numpy compatibility of our operatorstriagedThis 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