You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If the reshaped self is not invertible catch this error
Tensor result;
try {
result = at::inverse(self.reshape({prod_ind_end, prod_ind_end}));
} catch (...) {
TORCH_CHECK(false, "Failed to invert the input tensor, because it is singular.");
}
In the implementation of tensorinv we have:
This is bad code practice. For example, the inner operation could raise an exception because it ran out of memory, and you would still report it as singular. More concretely, this resulted in wrong behavior at https://github.com/pytorch/pytorch/pull/53682/files/29f176c952d5dd5614c933398fe3ed92de690a9e#diff-7e17421f32124016eb8de04dc2f445da5786a28355e1addc72b305466f590180 We shouldn't do a catch all. Ideally, there would be some interface to at::inverse that would let it explicitly signal, e.g., via boolean, that input was singular.
Related #47608
cc @jianyuh @nikitaved @pearu @mruberry @heitorschueroff @walterddr @IvanYashchuk @glaringlee