Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor::log_sum_exp() loses precision for small numbers #2356

Closed
leejuyuu opened this issue Jul 25, 2024 · 1 comment
Closed

Tensor::log_sum_exp() loses precision for small numbers #2356

leejuyuu opened this issue Jul 25, 2024 · 1 comment

Comments

@leejuyuu
Copy link

The current implementation of the Tensor::log_sum_exp() function does not handle small numbers correctly. For example, the following code

let arr = Tensor::full(-1000_f64, (10,), &Device::Cpu)?;
let logsumexp = arr.log_sum_exp(0)?;
println!("{:?}", logsumexp);

prints

Tensor[-inf; f64]

whereas on torch 2.3.0

>>> arr = torch.tensor([-1000]*10)
>>> torch.logsumexp(arr, 0)
tensor(-997.6974)

Version info

candle-core = "0.6.0"
Tested on Arch Linux

@LaurentMazare
Copy link
Collaborator

Closing based on the fix in #2367, feel free to reopen if it's still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants