File tree 3 files changed +31
-3
lines changed
3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"
3
3
license = " MIT"
4
4
desc = " Tape based task copying in Turing"
5
5
repo = " https://github.com/TuringLang/Libtask.jl.git"
6
- version = " 0.8.2 "
6
+ version = " 0.8.3 "
7
7
8
8
[deps ]
9
9
FunctionWrappers = " 069b7b12-0de2-55c6-9aab-29f3d0a68a2e"
Original file line number Diff line number Diff line change @@ -63,10 +63,17 @@ function TapedTask(tf::TapedFunction, args...)
63
63
return t
64
64
end
65
65
66
+ BASE_COPY_TYPES = Union{Array, Ref}
67
+
66
68
# NOTE: evaluating model without a trace, see
67
69
# https://github.com/TuringLang/Turing.jl/pull/1757#diff-8d16dd13c316055e55f300cd24294bb2f73f46cbcb5a481f8936ff56939da7ceR329
68
- function TapedTask (f, args... ; deepcopy_types= Union{Array, Ref}) # deepcoy Array and Ref by default.
69
- tf = TapedFunction (f, args... ; cache= true , deepcopy_types= deepcopy_types)
70
+ function TapedTask (f, args... ; deepcopy_types= nothing ) # deepcoy Array and Ref by default.
71
+ if isnothing (deepcopy_types)
72
+ deepcopy = BASE_COPY_TYPES
73
+ else
74
+ deepcopy = Union{BASE_COPY_TYPES, deepcopy_types}
75
+ end
76
+ tf = TapedFunction (f, args... ; cache= true , deepcopy_types= deepcopy)
70
77
TapedTask (tf, args... )
71
78
end
72
79
Original file line number Diff line number Diff line change 171
171
y[][2 ] = 19
172
172
@test y[][2 ] == 19
173
173
end
174
+
175
+ @testset " override deepcopy_types #57" begin
176
+ struct DummyType end
177
+
178
+ function f (start:: Int )
179
+ t = [start]
180
+ while true
181
+ produce (t[1 ])
182
+ t[1 ] = 1 + t[1 ]
183
+ end
184
+ end
185
+
186
+ ttask = TapedTask (f, 0 ; deepcopy_types= DummyType)
187
+ consume (ttask)
188
+
189
+ ttask2 = copy (ttask)
190
+ consume (ttask2)
191
+
192
+ @test consume (ttask) == 1
193
+ @test consume (ttask2) == 2
194
+ end
174
195
end
You can’t perform that action at this time.
0 commit comments