pytorch
3c0c1c4e - Fix incorrectly sized tensors for svd when full_matrices=False (#62022)

Commit
4 years ago
Fix incorrectly sized tensors for svd when full_matrices=False (#62022) Summary: Before this PR for m x n input matrix, the return matrices were always allocated as m x m and n x n and then narrowed. This unnecessarily requires a lot of memory that is then discarded. With this PR when `compute_uv=True and full_matrices=False` correctly sized tensors are allocated. Moreover, if `compute_uv=False` U, V matrices are not allocated as they are not needed. However, cusolver's gesvdj routines fail when these matrices are not allocated, which is a bug, so this allocation is done separately in cusolver specific code path. MAGMA doesn't work for this input because it tries to allocate a large matrix internally (ROCm doesn't work as it uses MAGMA). Example error: ``` CUBLAS error: memory mapping error (11) in magma_sgelqf at /opt/conda/conda-bld/magma-cuda110_1598416697386/work/src/sgelqf.cpp:161 CUBLAS error: out of memory (3) in magma_sgeqrf2_gpu at /opt/conda/conda-bld/magma-cuda110_1598416697386/work/src/sgeqrf2_gpu.cpp:145 CUBLAS error: not initialized (1) in magma_sgeqrf2_gpu at /opt/conda/conda-bld/magma-cuda110_1598416697386/work/src/sgeqrf2_gpu.cpp:145 MAGMA error: function-specific error, see documentation (1) in magma_sgeqrf2_gpu at /opt/conda/conda-bld/magma-cuda110_1598416697386/work/src/sgeqrf2_gpu.cpp:145 MAGMA error: function-specific error, see documentation (1) in magma_sgeqrf2_gpu at /opt/conda/conda-bld/magma-cuda110_1598416697386/work/src/sgeqrf2_gpu.cpp:145 python: /opt/conda/conda-bld/magma-cuda110_1598416697386/work/interface_cuda/interface.cpp:806: void magma_queue_create_internal(magma_device_t, magma_queue**, const char*, const char*, int): Assertion `queue->dAarray__ != __null' failed. Aborted (core dumped) ``` Fixes https://github.com/pytorch/pytorch/issues/61949. Pull Request resolved: https://github.com/pytorch/pytorch/pull/62022 Reviewed By: heitorschueroff Differential Revision: D29994429 Pulled By: ngimel fbshipit-source-id: c3f7744d7adc5fd6787f6cbb1ec41405f89a6d4c
Author
Parents
Loading