Skip to content

Commit 8db6c3a

Browse files
authored
Fix non-concrete type near TRCache (#118)
* Fix non-concrete type near TRCache * Add `@inferred` test * Bump version to 0.6.8
1 parent 340df34 commit 8db6c3a

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"
33
license = "MIT"
44
desc = "Tape based task copying in Turing"
55
repo = "https://github.com/TuringLang/Libtask.jl.git"
6-
version = "0.6.7"
6+
version = "0.6.8"
77

88
[deps]
99
IRTools = "7869d1d1-7146-5819-86e3-90919afe41df"

Diff for: src/tapedfunction.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ mutable struct ReturnInstruction{TA, T<:Taped} <: AbstractInstruction
3636
tape::T
3737
end
3838

39-
const TRCache = LRU{Any, Any}(maxsize=10)
40-
4139
mutable struct TapedFunction{F} <: Taped
42-
func::F # maybe a function, a constructor, or a callable obejct
40+
func::F # maybe a function, a constructor, or a callable object
4341
arity::Int
4442
ir::IRTools.IR
4543
tape::RawTape
@@ -53,7 +51,7 @@ mutable struct TapedFunction{F} <: Taped
5351
cache_key = (f, typeof.(args)...)
5452

5553
if cache && haskey(TRCache, cache_key) # use cache
56-
cached_tf = TRCache[cache_key]
54+
cached_tf = TRCache[cache_key]::TapedFunction{F}
5755
tf = copy(cached_tf)
5856
tf.counter = 1
5957
return tf
@@ -77,6 +75,8 @@ mutable struct TapedFunction{F} <: Taped
7775
end
7876
end
7977

78+
const TRCache = LRU{Tuple, TapedFunction}(maxsize=10)
79+
8080
## methods for Box
8181
val(x) = x
8282
val(x::Box) = x.val

Diff for: src/tapedtask.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
struct TapedTaskException
22
exc::Exception
3-
backtrace
3+
backtrace::Vector{Any}
44
end
55

66
struct TapedTask

Diff for: test/ctask.jl

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
@test consume(a) == 3
1818
@test consume(ctask) == 2
1919
@test consume(ctask) == 3
20+
21+
@inferred Libtask.TapedFunction(f)
2022
end
2123

2224
# Test case 2: heap allocated objects are shallowly copied.

0 commit comments

Comments
 (0)