|
50 | 50 |
|
51 | 51 | function DynamicPPL._determine_varinfo_jet( |
52 | 52 | model::DynamicPPL.Model, |
53 | | - context::DynamicPPL.AbstractContext=DynamicPPL.DefaultContext(); |
54 | | - verbose::Bool=false, |
| 53 | + context::DynamicPPL.AbstractContext; |
55 | 54 | only_tilde::Bool=true, |
56 | 55 | ) |
57 | 56 | # First we try with the typed varinfo. |
58 | | - varinfo = DynamicPPL.typed_varinfo(model) |
| 57 | + varinfo = if DynamicPPL.hassampler(context) |
| 58 | + # Don't need to add sampling context for this to work. |
| 59 | + DynamicPPL.typed_varinfo(model, context) |
| 60 | + else |
| 61 | + # Need a sampling context to initialize the varinfo. |
| 62 | + DynamicPPL.typed_varinfo(model, DynamicPPL.SamplingContext(context)) |
| 63 | + end |
59 | 64 | issuccess = true |
60 | 65 |
|
61 | 66 | # Let's make sure that both evaluation and sampling doesn't result in type errors. |
62 | | - issuccess, reports_eval = DynamicPPL.is_suitable_varinfo( |
| 67 | + issuccess, reports = DynamicPPL.is_suitable_varinfo( |
63 | 68 | model, context, varinfo; only_tilde |
64 | 69 | ) |
65 | 70 |
|
66 | | - if issuccess |
67 | | - # Evaluation succeeded, let's try sampling. |
68 | | - issuccess_sample, reports_sample = DynamicPPL.is_suitable_varinfo( |
69 | | - model, DynamicPPL.SamplingContext(context), varinfo; only_tilde |
70 | | - ) |
71 | | - issuccess &= issuccess_sample |
72 | | - if !issuccess && verbose |
73 | | - # Show the user the issues. |
74 | | - @warn "Sampling with typed varinfo failed with the following issues:" |
75 | | - for report in reports_sample |
76 | | - @warn report |
77 | | - end |
78 | | - end |
79 | | - elseif verbose |
80 | | - # Show the user the issues. |
81 | | - @warn "Evaluaton with typed varinfo failed with the following issues:" |
82 | | - for report in reports_eval |
83 | | - @warn report |
| 71 | + if !issuccess |
| 72 | + # Useful information for debugging. |
| 73 | + @debug "Evaluaton with typed varinfo failed with the following issues:" |
| 74 | + for report in reports |
| 75 | + @debug report |
84 | 76 | end |
85 | 77 | end |
86 | 78 |
|
|
0 commit comments