Skip to content

Commit 7c2b4b1

Browse files
committed
Use SIMDDualNumbers for forward diff special functions
1 parent 2758296 commit 7c2b4b1

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.12.82"
4+
version = "0.12.83"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
@@ -15,6 +15,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1515
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
1616
PolyesterWeave = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad"
1717
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
18+
SIMDDualNumbers = "3cdde19b-5bb0-4aaf-8931-af3e248e098b"
1819
SLEEFPirates = "476501e8-09a2-5ece-8869-fb82de89a1fa"
1920
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
2021
ThreadingUtilities = "8290d209-cae3-49c0-8002-c8c24d57dab5"
@@ -32,6 +33,7 @@ LayoutPointers = "0.1.2"
3233
OffsetArrays = "1.4.1"
3334
PolyesterWeave = "0.1"
3435
Requires = "1"
36+
SIMDDualNumbers = "0.1"
3537
SLEEFPirates = "0.6.23"
3638
Static = "0.3.3"
3739
ThreadingUtilities = "0.4.5"

src/simdfunctionals/vmap_grad_forwarddiff.jl

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
11
import .ForwardDiff
2+
using SIMDDualNumbers
23

3-
@generated function SLEEFPirates.tanh_fast(x::ForwardDiff.Dual{T,S,N}) where {T,S,N}
4-
quote
5-
$(Expr(:meta,:inline))
6-
t = tanh_fast(x.value)
7-
∂t = vfnmadd_fast(t, t, one(S))
8-
p = x.partials
9-
ForwardDiff.Dual{T}(t, ForwardDiff.Partials(Base.Cartesian.@ntuple $N n -> mul_fast(∂t, p[n])))
10-
end
11-
end
12-
@generated function SLEEFPirates.sigmoid_fast(x::ForwardDiff.Dual{T,S,N}) where {T,S,N}
13-
quote
14-
$(Expr(:meta,:inline))
15-
s = sigmoid_fast(x.value)
16-
∂s = vfnmadd_fast(s,s,s)
17-
p = x.partials
18-
ForwardDiff.Dual{T}(s, ForwardDiff.Partials(Base.Cartesian.@ntuple $N n -> mul_fast(∂s, p[n])))
19-
end
20-
end
21-
@generated function VectorizationBase.relu(x::ForwardDiff.Dual{T,S,N}) where {T,S,N}
22-
quote
23-
$(Expr(:meta,:inline))
24-
v = x.value
25-
z = zero(v)
26-
cmp = v < z
27-
r = ifelse(cmp, z, v)
28-
p = x.partials
29-
ForwardDiff.Dual{T}(r, ForwardDiff.Partials(Base.Cartesian.@ntuple $N n -> ifelse(cmp, z, p[n])))
30-
end
31-
end
324
@generated function init_dual(v::Tuple{Vararg{AbstractSIMD,A}}) where {A}
335
res = Expr(:tuple)
346
q = Expr(:block, Expr(:meta,:inline))

test/grouptests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const START_TIME = time()
1212

1313
@time if LOOPVECTORIZATION_TEST == "all" || LOOPVECTORIZATION_TEST == "part2"
1414
using Aqua
15-
@time Aqua.test_all(LoopVectorization, ambiguities = VERSION v"1.6")
15+
@time Aqua.test_all(LoopVectorization, ambiguities = VERSION v"1.6", stale_deps = false)
16+
@time Aqua.test_stale_deps(LoopVectorization, ignore = [:SIMDDualNumbers])
1617
# @test isempty(detect_unbound_args(LoopVectorization))
1718

1819
@time include("printmethods.jl")

0 commit comments

Comments
 (0)