Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
23f79a8
first draft of core functionality
georgematheos May 17, 2020
c9b1d49
add support for address schemas
georgematheos May 17, 2020
1e0a589
update choicemap docs
georgematheos May 17, 2020
623bc8f
refactoring and tests
georgematheos May 18, 2020
83349c7
performance improvements and benchmarking
georgematheos May 19, 2020
b9b5312
benchmark for dynamic choicemap lookups
georgematheos May 19, 2020
bce5e77
inline dynamicchoicemap methods
georgematheos May 19, 2020
a985f9b
remove old version benchmark file
georgematheos May 19, 2020
1f5029c
minor testing cleanup
georgematheos May 19, 2020
eb6adf7
ensure valuechoicemap[] syntax works
georgematheos May 19, 2020
eef9417
provide some examples in the documentation
georgematheos May 19, 2020
a83adfb
fix some typos
georgematheos May 19, 2020
1bd705f
add phrase 'nesting level zero' to docs
georgematheos May 19, 2020
676828b
distribution <: GenFn; dynamic DSL simplification
georgematheos Jun 17, 2020
5bf4207
simplify static ir code
georgematheos Jun 18, 2020
61673a4
brief documentation for Dist <: GenFn
georgematheos Jun 18, 2020
298a333
short map over distribution test
georgematheos Jun 18, 2020
e34875a
default static_get_submap = EmptyChoiceMap
georgematheos Jun 18, 2020
972d455
default static_get_submap = EmptyChoiceMap
georgematheos Jun 18, 2020
ee64d12
dist performance improvements
georgematheos Jun 18, 2020
fd1991f
minor performance improvement
georgematheos Jun 18, 2020
c3d5db0
performance improvement related to zip bug
georgematheos Jun 18, 2020
f652346
Merge branch '20200516-georgematheos-valuechoicemaps' into 20200617-g…
georgematheos Jun 20, 2020
8a43845
better static retdiff checking
georgematheos Jun 20, 2020
ffd9373
add static info for dist trace type
georgematheos Jun 25, 2020
67d5e12
don't use static get_submap for staticchoicemap
georgematheos Jun 25, 2020
4966ea9
some simple MH benchmarks
georgematheos Jun 25, 2020
0909a5b
bug fix
georgematheos Jun 25, 2020
47cca59
remove ChoiceAt; bug fixes
georgematheos Jun 25, 2020
10df952
decrease iters on benchmark
georgematheos Jun 25, 2020
a79390e
merge in updated master
georgematheos Jul 3, 2020
b1c4fc2
address_tree v0
georgematheos Jul 3, 2020
3d1b519
bug fixing
georgematheos Jul 5, 2020
bc9b7f6
bug fixes -> tests passing
georgematheos Jul 6, 2020
9c74360
remove old choicemap & selection code
georgematheos Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better static retdiff checking
  • Loading branch information
georgematheos committed Jun 20, 2020
commit 8a43845bb1e1925125e28ad9131fd5621a9f9d5d
38 changes: 24 additions & 14 deletions src/static_ir/update.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,39 @@ function process_forward!(::Type{<:Union{ChoiceMap, Selection}}, state::ForwardP
end
end

function process_forward!(constraint_type::Type{<:Union{<:ChoiceMap, Selection}}, state::ForwardPassState,
function cannot_statically_guarantee_nochange_retdiff(constraint_type, node, state)
update_fn = constraint_type <: ChoiceMap ? Gen.update : Gen.regenerate

trace_type = get_trace_type(node.generative_function)
argdiff_types = map(input_node -> input_node in state.value_changed ? UnknownChange : NoChange, node.inputs)
argdiff_type = Tuple{argdiff_types...}
# TODO: can we know the arg type statically?
update_rettype = Core.Compiler.return_type(
update_fn,
Tuple{trace_type, Tuple, argdiff_type, constraint_type}
)
has_static_retdiff = update_rettype <: Tuple && update_rettype != Union{} && length(update_rettype.parameters) > 3
guaranteed_returns_nochange = has_static_retdiff && update_rettype.parameters[3] == NoChange

return !guaranteed_returns_nochange
end

function process_forward!(constraint_type::Type{<:Union{<:ChoiceMap, <:Selection}}, state::ForwardPassState,
node::GenerativeFunctionCallNode)
schema = get_address_schema(constraint_type)
will_run_update = false
@assert isa(schema, StaticAddressSchema) || isa(schema, EmptyAddressSchema) || isa(schema, AllAddressSchema)
if isa(schema, AllAddressSchema) || (isa(schema, StaticAddressSchema) && (node.addr in keys(schema)))
push!(state.constrained_or_selected_calls, node)
push!(state.value_changed, node)
push!(state.discard_calls, node)
will_run_update = true
end
if any(input_node in state.value_changed for input_node in node.inputs)
push!(state.input_changed, node)
will_run_update = true
end
if will_run_update
push!(state.discard_calls, node)

## check if we can statically guarantee that this generative function has a `NoChange` diff ##
update_fn = constraint_type <: ChoiceMap ? Gen.update : Gen.regenerate

trace_type = get_trace_type(node.generative_function)
update_rettype = Core.Compiler.return_type(
update_fn,
Tuple{trace_type, Tuple, Tuple, constraint_type}
)
guaranteed_returns_nochange = update_rettype <: Tuple && update_rettype != Union{} && update_rettype.parameters[3] == NoChange
if !guaranteed_returns_nochange
if cannot_statically_guarantee_nochange_retdiff(constraint_type, node, state)
push!(state.value_changed, node)
end
end
Expand Down