From dce10a65abb1d694fb051d12057af2a3183aff33 Mon Sep 17 00:00:00 2001 From: Jin Wang Date: Sun, 30 Jun 2024 18:46:34 +0800 Subject: [PATCH] replace the unimplemented tensor.mH used to the implemented adjoint, fixed the wrong shape and dtype of return. Now there are somehow numerial difference between return of groundtruth torch.svd and ivy.svd --- .../frontends/torch/blas_and_lapack_ops.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ivy/functional/frontends/torch/blas_and_lapack_ops.py b/ivy/functional/frontends/torch/blas_and_lapack_ops.py index 074a1a62a75a5..7100d79330090 100644 --- a/ivy/functional/frontends/torch/blas_and_lapack_ops.py +++ b/ivy/functional/frontends/torch/blas_and_lapack_ops.py @@ -193,15 +193,17 @@ def slogdet(A, *, out=None): @to_ivy_arrays_and_back def svd(input, some=True, compute_uv=True, *, out=None): # TODO: add handling for driver - ret = ivy.svd(input, full_matrices=not some, compute_uv=compute_uv) + retu = ivy.svd(input, full_matrices=not some, compute_uv=compute_uv) results = namedtuple("svd", ['U', 'S', 'V']) if compute_uv: - ret = results(ret.U, ret.S, ret.Vh.mH) + ret = results(retu[0], retu[1], ivy.adjoint(retu[2])) else: - shape = input.shape - m = shape[-2] - n = shape[-1] - ret = results(ivy.zeros((m,m), device=input.device), ret.S, ivy.zeros((n,n), device=input.device)) + shape = list(input.shape) + shape1 = shape + shape2 = shape + shape1[-2] = shape[-1] + shape2[-1] = shape[-2] + ret = results(ivy.zeros(shape1, device=input.device, dtype=input.dtype), retu[0], ivy.zeros(shape2, device=input.device, dtype=input.dtype)) if ivy.exists(out): return ivy.inplace_update(out, ret) return ret