Fix occasional execution error

This commit is contained in:
2023-10-04 17:32:23 +02:00
parent 0f50b59933
commit a86901e425
4 changed files with 14 additions and 16 deletions

View File

@@ -160,17 +160,22 @@ function remove_edge!(graph::DAG, node1::Node, node2::Node; track = true, invali
end
function replace_children!(task::FusedComputeTask, before, after)
# TODO: this assert fails sometimes and really shouldn't
@assert length(findall(x -> x == before, task.t1_inputs)) >= 1 ||
length(findall(x -> x == before, task.t2_inputs)) >= 1 "Replacing $before with $after in $(task.t1_inputs...) and $(task.t2_inputs...)"
replacedIn1 = length(findall(x -> x == before, task.t1_inputs))
replacedIn2 = length(findall(x -> x == before, task.t2_inputs))
# recursively descend down the tree
replace_children!(task.first_task, before, after)
replace_children!(task.second_task, before, after)
@assert replacedIn1 >= 1 || replacedIn2 >= 1 "Nothing to replace while replacing $before with $after in $(task.t1_inputs...) and $(task.t2_inputs...)"
replace!(task.t1_inputs, before => after)
replace!(task.t2_inputs, before => after)
# recursively descend down the tree, but only in the tasks where we're replacing things
if replacedIn1 > 0
replace_children!(task.first_task, before, after)
end
if replacedIn2 > 0
replace_children!(task.second_task, before, after)
end
return nothing
end

View File

@@ -9,7 +9,6 @@ function apply_all!(graph::DAG)
op = popfirst!(graph.operationsToApply)
# apply it
println(graph.appliedOperations)
appliedOp = apply_operation!(graph, op)
# push to the end of the appliedOperations deque
@@ -238,12 +237,6 @@ function node_reduction!(graph::DAG, nodes::Vector{Node})
# names of the previous children that n1 now replaces per parent
newParentsChildNames = Dict{Node, Symbol}()
str = Vector{String}()
for n in nodes
push!(str, "$(n.id)")
end
#println("Reducing $(nodes[1].task) Nodes $(str)")
# remove all of the nodes' parents and children and the nodes themselves (except for first node)
for i in 2:length(nodes)
n = nodes[i]