Skip to content

Commit 861b65f

Browse files
zeshengzongpytorchmergebot
authored andcommitted
[Easy] Fix linalg.norm hint message typo (pytorch#144323)
Fixes pytorch#136454 **Test Result** **Before** ```python >>> 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 Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: linalg.norm: If dim is specified, it mut be of length 1 or 2. Got [0, 1, 2] >>> # ↓ ↓ ↓ ↓ ↓ >>> linalg.norm(input=my_tensor, ord='nuc', dim=(0, 1, 2)) # Error Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: linalg.norm: If dim is specified, it mut be of length 1 or 2. Got [0, 1, 2] ``` **After** ```python >>> 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 Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: linalg.norm: If dim is specified, it must be of length 1 or 2. Got [0, 1, 2] >>> # ↓ ↓ ↓ ↓ ↓ >>> linalg.norm(input=my_tensor, ord='nuc', dim=(0, 1, 2)) # Error Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: linalg.norm: If dim is specified, it must be of length 1 or 2. Got [0, 1, 2] ``` Pull Request resolved: pytorch#144323 Approved by: https://github.com/Skylion007, https://github.com/soulitzer
1 parent d38af6e commit 861b65f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

aten/src/ATen/native/LinearAlgebra.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3037,7 +3037,7 @@ Tensor& linalg_norm_out(const Tensor& X, const std::optional<Scalar>& opt_ord, O
30373037
Tensor linalg_norm(const Tensor& X, std::string_view ord, OptionalIntArrayRef opt_dim, bool keepdim, std::optional<ScalarType> opt_dtype) {
30383038
if (opt_dim.has_value()) {
30393039
TORCH_CHECK(opt_dim->size() == 1 || opt_dim ->size() == 2, "linalg.norm: If ",
3040-
"dim is specified, it mut be of length 1 or 2. Got ", *opt_dim);
3040+
"dim is specified, it must be of length 1 or 2. Got ", *opt_dim);
30413041
} else {
30423042
TORCH_CHECK(X.dim() == 1 || X.dim() == 2, "linalg.norm: If ",
30433043
"dim is not specified but ord is, the input must be 1D or 2D. Got ", X.dim(), "D.");

0 commit comments

Comments
 (0)