Skip to content

Commit

Permalink
Fix CUDA issue with irrational constant (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored Aug 18, 2023
1 parent 24fcdab commit cbd1bbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LogExpFunctions"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
authors = ["StatsFun.jl contributors, Tamas K. Papp <[email protected]>"]
version = "0.3.24"
version = "0.3.25"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
10 changes: 9 additions & 1 deletion src/basicfuns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,15 @@ See:
Note: different than Maechler (2012), no negation inside parentheses
"""
log1mexp(x::Real) = x < IrrationalConstants.loghalf ? log1p(-exp(x)) : log(-expm1(x))
function log1mexp(x::Real)
# Use explicit `oftype(..)` instead of just `loghalf` to avoid CUDA issues:
# https://github.com/JuliaStats/LogExpFunctions.jl/issues/73
if x < oftype(float(x), IrrationalConstants.loghalf)
return log1p(-exp(x))
else
return log(-expm1(x))
end
end

"""
$(SIGNATURES)
Expand Down

2 comments on commit cbd1bbe

@devmotion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/89872

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.25 -m "<description of version>" cbd1bbe3ceea197db9b0fa3468bb5ba703ffdbac
git push origin v0.3.25

Please sign in to comment.