@@ -5,6 +5,7 @@ using ..DynamicPPL: broadcast_safe, AbstractContext, childcontext
55
66using Random: Random
77using Accessors: Accessors
8+ using InteractiveUtils: InteractiveUtils
89
910using DocStringExtensions
1011using Distributions
@@ -678,4 +679,36 @@ function has_static_constraints(
678679 return all_the_same (transforms)
679680end
680681
682+ """
683+ model_warntype(model[, varinfo, context])
684+
685+ Check the type stability of the model's evaluator, warning about any potential issues.
686+
687+ This simply calls `@code_warntype` on the model's evaluator, filling in internal arguments where needed.
688+ """
689+ function model_warntype (model:: Model , varinfo:: AbstractVarInfo = VarInfo (model), context:: AbstractContext = DefaultContext ())
690+ args, kwargs = DynamicPPL. make_evaluate_args_and_kwargs (model, varinfo, context)
691+ return if isempty (kwargs)
692+ InteractiveUtils. @code_warntype model. f (args... )
693+ else
694+ InteractiveUtils. @code_warntype model. f (args... ; kwargs... )
695+ end
696+ end
697+
698+ """
699+ model_typed(model[, varinfo, context])
700+
701+ Return the type inference for the model's evaluator.
702+
703+ This simply calls `@code_typed` on the model's evaluator, filling in internal arguments where needed.
704+ """
705+ function model_typed (model:: Model , varinfo:: AbstractVarInfo = VarInfo (model), context:: AbstractContext = DefaultContext ())
706+ args, kwargs = DynamicPPL. make_evaluate_args_and_kwargs (model, varinfo, context)
707+ return if isempty (kwargs)
708+ InteractiveUtils. @code_typed model. f (args... )
709+ else
710+ InteractiveUtils. @code_typed model. f (args... ; kwargs... )
711+ end
712+ end
713+
681714end
0 commit comments