Skip to content

Commit 44f9fd8

Browse files
KDr2yebaidevmotiongithub-actions[bot]
authored
Use tape based Libtask (#35)
* use tape based Libtask * code refactor * use new CTask constructor * Update Project.toml * Update Project.toml * use TapeInstruction * remove useless code * Update src/model.jl * Apply suggestions from code review * Fix format Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/container.jl Co-authored-by: Hong Ge <[email protected]> Co-authored-by: David Widmann <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 248d6ea commit 44f9fd8

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
1414
[compat]
1515
AbstractMCMC = "2, 3"
1616
Distributions = "0.23, 0.24, 0.25"
17-
Libtask = "0.5.3"
17+
Libtask = "0.6"
1818
Random123 = "1.3"
1919
StatsFuns = "0.9"
2020
julia = "1.3"

src/container.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ end
77
const Particle = Trace
88

99
function Trace(f, rng::TracedRNG)
10-
ctask = let f = f
11-
Libtask.CTask() do
12-
res = f(rng)
13-
Libtask.produce(nothing)
14-
return res
15-
end
16-
end
10+
ctask = Libtask.CTask(f, rng)
1711

1812
# add backward reference
1913
newtrace = Trace(f, ctask, rng)
@@ -62,13 +56,7 @@ function forkr(trace::Trace)
6256
newf = reset_model(trace.f)
6357
Random123.set_counter!(trace.rng, 1)
6458

65-
ctask = let f = trace.ctask.task.code
66-
Libtask.CTask() do
67-
res = f()(trace.rng)
68-
Libtask.produce(nothing)
69-
return res
70-
end
71-
end
59+
ctask = Libtask.CTask(newf, trace.rng)
7260

7361
# add backward reference
7462
newtrace = Trace(newf, ctask, trace.rng)

test/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
99
[compat]
1010
AbstractMCMC = "2, 3"
1111
Distributions = "0.24, 0.25"
12-
Libtask = "0.5"
12+
Libtask = "0.6"
1313
julia = "1.3"
14-
Random123 = "1.3"
14+
Random123 = "1.3"

0 commit comments

Comments
 (0)