Trace Translators
Gen.@transform
— Macro@transform f[(params...)] (in1 [,in2]) to (out1 [,out2])
..
end
Write a program in the Trace Transform DSL.
Gen.@read
— Macro@read(<source>, <annotation>)
Macro for reading the value of a random choice from an input trace in the Trace Transform DSL.
<source> is of the form <trace>[<addr>] where <trace> is an input trace, and <annotation> is either :discrete or :continuous.
Gen.@write
— Macro@write(<destination>, <value>, <annotation>)
Macro for writing the value of a random choice to an output trace in the Trace Transform DSL.
<destination> is of the form <trace>[<addr>] where <trace> is an input trace, and <annotation> is either :discrete or :continuous.
Gen.@copy
— Macro@copy(<source>, <destination>)
Macro for copying the value of a random choice (or a whole namespace of random choices) from an input trace to an output trace in the Trace Transform DSL.
<destination> is of the form <trace>[<addr>] where <trace> is an input trace, and <annotation> is either :discrete or :continuous.
Gen.@tcall
— Macro@tcall(ex)
A macro to call a transformation function from inside another transformation fuction.
Gen.pair_bijections!
— Functionpair_bijections!(f1::TraceTransformDSLProgram, f2::TraceTransformDSLProgram)
Assert that a pair of bijections constructed using the Trace Transform DSL are inverses of one another.
Gen.is_involution!
— Functionis_involution!(f::TraceTransformDSLProgram)
Assert that a bijection constructed with the Trace Transform DSL is its own inverse.
Gen.inverse
— Functionb::TraceTransformDSLProgram = inverse(a::TraceTransformDSLProgram)
Obtain the inverse of a bijection that was constructed with the Trace Transform DSL.
The inverse must have been associated with the bijection either via pair_bijections!
or [is_involution!
])(@ref).
Gen.TraceTranslator
— TypeAbstract type for trace translators.
Gen.DeterministicTraceTranslator
— Typetranslator = DeterministicTraceTranslator(;
p_new::GenerativeFunction, p_args::Tuple=();
new_observations::ChoiceMap=EmptyChoiceMap()
f::TraceTransformDSLProgram)
Constructor for a deterministic trace translator.
Run the translator with:
(output_trace, log_weight) = translator(input_trace)
Gen.GeneralTraceTranslator
— Typetranslator = GeneralTraceTranslator(;
p_new::GenerativeFunction,
p_new_args::Tuple = (),
new_observations::ChoiceMap = EmptyChoiceMap(),
q_forward::GenerativeFunction,
q_forward_args::Tuple = (),
q_backward::GenerativeFunction,
q_backward_args::Tuple = (),
f::TraceTransformDSLProgram)
Constructor for a general trace translator.
Run the translator with:
(output_trace, log_weight) = translator(input_trace; check=false, prev_observations=EmptyChoiceMap())
Use check
to enable a bijection check (this requires that the transform f
has been paired with its inverse using `pair_bijections! or is_involution!
).
If check
is enabled, then prev_observations
is a choice map containing the observed random choices in the previous trace.
Gen.SimpleExtendingTraceTranslator
— Typetranslator = SimpleExtendingTraceTranslator(;
p_new_args::Tuple = (),
p_argdiffs::Tuple = (),
new_observations::ChoiceMap = EmptyChoiceMap(),
q_forward::GenerativeFunction,
q_forward_args::Tuple = ())
Constructor for a simple extending trace translator.
Run the translator with:
(output_trace, log_weight) = translator(input_trace)
Gen.SymmetricTraceTranslator
— Typetranslator = SymmetricTraceTranslator(;
q::GenerativeFunction,
q_args::Tuple = (),
involution::Union{TraceTransformDSLProgram,Function})
Constructor for a symmetric trace translator.
The involution is either constructed via the @transform
macro (recommended), or can be provided as a Julia function.
Run the translator with:
(output_trace, log_weight) = translator(input_trace; check=false, observations=EmptyChoiceMap())
Use check
to enable the involution check (this requires that the transform f
has been marked with is_involution!
).
If check
is enabled, then observations
is a choice map containing the observed random choices, and the check will additionally ensure they are not mutated by the involution.
Gen.TraceTransformDSLProgram
— TypeTraceTransformDSLProgram
A program compiled from the Trace Transform DSL.