Skip to content

ord with str values and the length 3 of dim for linalg.norm() wrongly gets the error message with mut instead of must #136454

@hyperkai

Description

@hyperkai

🐛 Describe the bug

ord with str values and the length 3 of dim for linalg.norm() wrongly gets the error message with mut instead of must as shown below:

import torch
from torch import linalg

my_tensor = torch.tensor([[[8., -3., 0., 1.]]])
                           # ↓ ↓ ↓ ↓ ↓
linalg.norm(input=my_tensor, ord='fro', dim=(0, 1, 2)) # Error
                           # ↓ ↓ ↓ ↓ ↓
linalg.norm(input=my_tensor, ord='nuc', dim=(0, 1, 2)) # Error
                                                 # ↓↓↓
RuntimeError: linalg.norm: If dim is specified, it mut be of length 1 or 2. Got [0, 1, 2]

In addition, ord with None and int values and the length 3 of dim for linalg.norm() properly gets the error message with must instead of mut as shown below:

import torch
from torch import linalg

my_tensor = torch.tensor([[[8., -3., 0., 1.]]])
                           # ↓ ↓ ↓ ↓
linalg.norm(input=my_tensor, ord=None, dim=(0, 1, 2)) # Error
                           # ↓ ↓ ↓
linalg.norm(input=my_tensor, ord=2, dim=(0, 1, 2)) # Error
                                                 # ↓↓↓↓
RuntimeError: linalg.norm: If dim is specified, it must be of length 1 or 2. Got [0, 1, 2]

Versions

import torch

torch.__version__ # 2.4.1+cu121

cc @svekars @brycebortree @sekyondaMeta @jianyuh @nikitaved @pearu @mruberry @walterddr @xwang233 @lezcano

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: docsRelated to our documentation, both in docs/ and docblocksmodule: linear algebraIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmultriagedThis 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