From fef35c233064bd5f06c5d92c0785c410ea005307 Mon Sep 17 00:00:00 2001 From: houpc Date: Mon, 25 Sep 2023 15:36:44 +0800 Subject: [PATCH] add test for forwardAD with graph vector --- test/computational_graph.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/computational_graph.jl b/test/computational_graph.jl index fceff4a6..e3b4ea8d 100644 --- a/test/computational_graph.jl +++ b/test/computational_graph.jl @@ -328,6 +328,16 @@ end leaf = [5.0, -1.0, 2.0, 0.0, 0.0, 1.0] @test eval!(dual1[F0.id], leafmap, leaf) == 240.0 @test isequiv(dual[F1.id], dual1[F1.id], :id, :weight, :vertices) + + F0_r1 = F1 + F3 + dual = forwardAD_root([F0, F0_r1]) + leafmap[dual[g1.id].id] = 4 + leafmap[dual[g2.id].id] = 5 + leafmap[dual[g3.id].id] = 6 + @test eval!(dual[F0.id], leafmap, leaf) == 240.0 + @test eval!(dual[F0_r1.id], leafmap, leaf) == 60.0 + @test isequiv(dual[F0.id], dual1[F0.id], :id, :weight) + @test isequiv(dual[F1.id], dual1[F1.id], :id, :weight) end end