@@ -3,53 +3,19 @@ module DynamicPPLJETExt
3
3
using DynamicPPL: DynamicPPL
4
4
using JET: JET
5
5
6
- """
7
- is_tilde_instance(x)
8
-
9
- Return `true` if `x` is a method instance of a tilde function, otherwise `false`.
10
- """
11
- is_tilde_instance (x) = false
12
- is_tilde_instance (frame:: JET.VirtualFrame ) = is_tilde_instance (frame. linfo)
13
- function is_tilde_instance (mi:: Core.MethodInstance )
14
- types = mi. specTypes
15
- # This can occur, for example, if `specTypes` is `UnionAll` due to an error.
16
- return if hasproperty (types, :parameters )
17
- is_tilde_instance (types. parameters[1 ])
18
- else
19
- false
20
- end
21
- end
22
- is_tilde_instance (:: Type{typeof(DynamicPPL.tilde_assume!!)} ) = true
23
- is_tilde_instance (:: Type{typeof(DynamicPPL.tilde_observe!!)} ) = true
24
- is_tilde_instance (:: Type{typeof(DynamicPPL.dot_tilde_assume!!)} ) = true
25
- is_tilde_instance (:: Type{typeof(DynamicPPL.dot_tilde_observe!!)} ) = true
26
-
27
- """
28
- report_has_error_in_tilde(report)
29
-
30
- Return `true` if the given error `report` contains a tilde function in its frames, otherwise `false`.
31
-
32
- This is used to filter out reports that occur outside of the tilde pipeline, in an attempt to avoid
33
- warning the user about DynamicPPL doing something wrong when it is in fact an issue with the user's code.
34
- """
35
- function report_has_error_in_tilde (report)
36
- frames = report. vst
37
- return any (is_tilde_instance, frames)
38
- end
39
-
40
6
function DynamicPPL. is_suitable_varinfo (
41
7
model:: DynamicPPL.Model ,
42
8
context:: DynamicPPL.AbstractContext ,
43
9
varinfo:: DynamicPPL.AbstractVarInfo ;
44
- only_tilde :: Bool = true ,
10
+ only_ddpl :: Bool = true ,
45
11
)
46
12
# Let's make sure that both evaluation and sampling doesn't result in type errors.
47
13
f, argtypes = DynamicPPL. DebugUtils. gen_evaluator_call_with_types (
48
14
model, varinfo, context
49
15
)
50
16
# If specified, we only check errors originating somewhere in the DynamicPPL.jl.
51
17
# This way we don't just fall back to untyped if the user's code is the issue.
52
- result = if only_tilde
18
+ result = if only_ddpl
53
19
JET. report_call (f, argtypes; target_modules= (JET. AnyFrameModule (DynamicPPL),))
54
20
else
55
21
JET. report_call (f, argtypes)
@@ -58,14 +24,14 @@ function DynamicPPL.is_suitable_varinfo(
58
24
end
59
25
60
26
function DynamicPPL. _determine_varinfo_jet (
61
- model:: DynamicPPL.Model , context:: DynamicPPL.AbstractContext ; only_tilde :: Bool = true
27
+ model:: DynamicPPL.Model , context:: DynamicPPL.AbstractContext ; only_ddpl :: Bool = true
62
28
)
63
29
# First we try with the typed varinfo.
64
30
varinfo = DynamicPPL. typed_varinfo (model, context)
65
31
issuccess = true
66
32
67
33
# Let's make sure that both evaluation and sampling doesn't result in type errors.
68
- issuccess, result = DynamicPPL. is_suitable_varinfo (model, context, varinfo; only_tilde )
34
+ issuccess, result = DynamicPPL. is_suitable_varinfo (model, context, varinfo; only_ddpl )
69
35
70
36
if ! issuccess
71
37
# Useful information for debugging.
0 commit comments