8000 SVD intermittently reports incorrect tensor size · Issue #393 · LaurentMazare/tch-rs · GitHub
[go: up one dir, main page]

Skip to content
SVD intermittently reports incorrect tensor size #393
@rustrust

Description

@rustrust

I need to check whether a matrix I am working with is singular, so I am placing a call to linalg_matrix_rank. Everything is fine when the matrix is full rank, but tch-rs panics if the matrix is at all singular.

Since the purpose of this function is to report on the rank of the matrix, which is not necessarily full rank, some other behavior is preferred. Most preferably, this function should never panic or error if the matrix is singular, because its purpose is to report on the numeric rank of the matrix.

let rank = my_tensor.reshape(&[1, 1, 1024, 1024]).linalg_matrix_rank(None, false);
println!("my_tensor linalg_matrix_rank: {:?}", &rank);

let rank2 = my_tensor.reshape(&[1, 1, 1024, 1024]).matrix_rank(false);
println!("my_tensor matrix_rank: {:?}", &rank2);

The result of running this looks like:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Torch("svd_cuda: For batch 0: U(1025,1025) is zero, singular U.\nException raised from batchCheckErrors at /pytorch/aten/src/ATen/native/LinearAlgebraUtils.h:251

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0