ger is an alias to outer, not the other way around (#59448)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/59448
Test Plan: Imported from OSS
Reviewed By: zou3519
Differential Revision: D28900487
Pulled By: albanD
fbshipit-source-id: e9065c5b29078d92ea9b746e188ebc1e62a407a0
diff --git a/aten/src/ATen/native/native_functions.yaml b/aten/src/ATen/native/native_functions.yaml
index 368272f..70d86db 100644
--- a/aten/src/ATen/native/native_functions.yaml
+++ b/aten/src/ATen/native/native_functions.yaml
@@ -9818,20 +9818,20 @@
- func: inner.out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)
-# torch.outer, alias for torch.ger
- func: outer(Tensor self, Tensor vec2) -> Tensor
variants: function, method
+ dispatch:
+ CompositeExplicitAutograd: outer
- func: outer.out(Tensor self, Tensor vec2, *, Tensor(a!) out) -> Tensor(a!)
+ dispatch:
+ CompositeExplicitAutograd: outer_out
+# torch.ger, alias for torch.outer
- func: ger(Tensor self, Tensor vec2) -> Tensor
variants: function, method
- dispatch:
- CompositeExplicitAutograd: ger
- func: ger.out(Tensor self, Tensor vec2, *, Tensor(a!) out) -> Tensor(a!)
- dispatch:
- CompositeExplicitAutograd: ger_out
- func: linalg_norm(Tensor self, Scalar? ord=None, int[1]? dim=None, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
python_module: linalg
diff --git a/tools/autograd/derivatives.yaml b/tools/autograd/derivatives.yaml
index e480f55..0384c3c 100644
--- a/tools/autograd/derivatives.yaml
+++ b/tools/autograd/derivatives.yaml
@@ -578,9 +578,9 @@
- name: geqrf(Tensor self) -> (Tensor a, Tensor tau)
self: not_implemented("geqrf")
-- name: ger(Tensor self, Tensor vec2) -> Tensor
- self: grad.mv(vec2.conj())
- vec2: grad.t().mv(self.conj())
+- name: outer(Tensor self, Tensor vec2) -> Tensor
+ self: grad.mm(vec2.unsqueeze(-1).conj()).squeeze(-1)
+ vec2: grad.t().mm(self.unsqueeze(-1).conj()).squeeze(-1)
- name: indices(Tensor(a) self) -> Tensor(a)
output_differentiability: [False]
diff --git a/tools/autograd/gen_variable_type.py b/tools/autograd/gen_variable_type.py
index 73ef753..c9d5a9d 100644
--- a/tools/autograd/gen_variable_type.py
+++ b/tools/autograd/gen_variable_type.py
@@ -87,7 +87,7 @@
'sgn', 'asin', 'acos', 'sub', 'div', 'cat', 'view_as_complex',
'neg', 'complex', 'select', '_s_where', 'as_strided', 'slice', 'constant_pad_nd',
'unbind', 'split', 'split_with_sizes', 'unsafe_split', 'split_with_sizes_backward',
- 'dot', 'vdot', 'cholesky', 'triangular_solve', 'mm', '_unsafe_view', 'mv', 'ger',
+ 'dot', 'vdot', 'cholesky', 'triangular_solve', 'mm', '_unsafe_view', 'mv', 'outer',
'bmm', 'diagonal', 'alias', 'atan', 'log', 'log10', 'log1p', 'log2', 'reciprocal',
'tan', 'pow', 'rsqrt', 'tanh', 'tanh_backward', 'asinh', 'acosh', 'atanh', 'take', 'fill_',
'exp', 'nonzero', 'mean', 'inverse', 'solve', 'linalg_cholesky', 'addcmul', 'addcdiv',