Add node fusion test
This commit is contained in:
parent
bbf8106e12
commit
669444ebbd
@ -2,7 +2,6 @@ using MetagraphOptimization
|
||||
using Test
|
||||
|
||||
function test_known_graphs()
|
||||
|
||||
g_ABAB = import_txt(joinpath(@__DIR__, "..", "examples", "AB->AB.txt"))
|
||||
props = graph_properties(g_ABAB)
|
||||
|
||||
@ -10,4 +9,46 @@ function test_known_graphs()
|
||||
@test props.compute_effort == 185
|
||||
@test props.data == 102
|
||||
|
||||
@test length(generate_options(g_ABAB).fusions) == 10
|
||||
|
||||
test_node_fusion(g_ABAB)
|
||||
|
||||
|
||||
g_ABAB3 = import_txt(joinpath(@__DIR__, "..", "examples", "AB->ABBB.txt"))
|
||||
props = graph_properties(g_ABAB3)
|
||||
|
||||
@test length(g_ABAB3.nodes) == 280
|
||||
@test props.compute_effort == 2007
|
||||
@test props.data == 828
|
||||
|
||||
test_node_fusion(g_ABAB3)
|
||||
end
|
||||
|
||||
function test_node_fusion(g)
|
||||
props = graph_properties(g)
|
||||
|
||||
options = generate_options(g)
|
||||
|
||||
nodes_number = length(g.nodes)
|
||||
data = props.data
|
||||
compute_effort = props.compute_effort
|
||||
|
||||
while length(options.fusions) != 0
|
||||
fusion = options.fusions[1]
|
||||
n = node_fusion(g, fusion[1], fusion[2], fusion[3])
|
||||
@test typeof(n.task) <: FusedComputeTask
|
||||
@test length(g.nodes) == nodes_number - 2
|
||||
|
||||
props = graph_properties(g)
|
||||
@test props.data < data
|
||||
@test props.compute_effort == compute_effort
|
||||
|
||||
nodes_number = length(g.nodes)
|
||||
data = props.data
|
||||
compute_effort = props.compute_effort
|
||||
|
||||
options = generate_options(g)
|
||||
end
|
||||
|
||||
print(g)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user