Skip to content

Commit 6467279

Browse files
committed
Add a test for threaded observe
1 parent 92c84b5 commit 6467279

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/fasteval.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ end
7575
end
7676
end
7777
end
78+
79+
@testset "Threaded observe" begin
80+
if Threads.nthreads() > 1
81+
@model function threaded(y)
82+
x ~ Normal()
83+
Threads.@threads for i in eachindex(y)
84+
y[i] ~ Normal(x)
85+
end
86+
end
87+
N = 100
88+
model = threaded(zeros(N))
89+
ldf = DynamicPPL.Experimental.FastLDF(model)
90+
91+
xs = [1.0]
92+
@test LogDensityProblems.logdensity(ldf, xs)
93+
logpdf(Normal(), xs[1]) + N * logpdf(Normal(xs[1]), 0.0)
94+
end
95+
end
7896
end
7997

8098
@testset "FastLDF: performance" begin

0 commit comments

Comments
 (0)