Skip to content

Commit 1ede301

Browse files
authored
fix: remove inlining of sigmoid_fast pre 1.11- (#597)
1 parent a4111c1 commit 1ede301

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/activations.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,10 @@ julia> hardσ(0.2f0)
823823
0.53333336f0
824824
```
825825
"""
826-
@inline function sigmoid_fast(x::Real)
826+
function sigmoid_fast(x::Real)
827+
@static if VERSION v"1.11-"
828+
@inline
829+
end
827830
t = @fastmath exp(-abs(x))
828831
y = ifelse(x 0, inv(1 + t), t / (1 + t))
829832
ifelse(x > 40, one(y), ifelse(x < -80, zero(y), y))

test/ext_cuda/activations.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ end
4141
@test Array(y) == [tanh(1f0)]
4242
@test Array(x) == [tanh(tanh(1f0))]
4343
end
44+
45+
@testset "fused act addition broadcast" begin
46+
x = CUDA.rand(Float32, 10, 10)
47+
b = CUDA.rand(Float32, 10)
48+
49+
for act in getfield.((NNlib,), NNlib.ACTIVATIONS)
50+
fused_act_add = act +
51+
@test fused_act_add.(x, b) act.(x .+ b)
52+
end
53+
end

0 commit comments

Comments
 (0)