|
47 | 47 | @test size(y_d) == (2, 6) |
48 | 48 | @test Array(y_d) ≈ y_cpu rtol = 1.0f-4 atol = 1.0f-5 |
49 | 49 | end |
| 50 | + |
| 51 | +@testset "Reactant GCNConv keeps device graph indices dynamic" begin |
| 52 | + rng = Xoshiro(42) |
| 53 | + model = GCNConv(3 => 2, relu) |
| 54 | + ps, st = Lux.setup(rng, model) |
| 55 | + g1 = test_graph() |
| 56 | + g2 = GNNGraph( |
| 57 | + ([1, 1, 1, 2, 2, 3], [4, 5, 6, 5, 6, 6]); |
| 58 | + num_nodes = 6, |
| 59 | + ) |
| 60 | + x = randn(rng, Float32, 3, 6) |
| 61 | + f(g, x, ps, st) = first(model(g, x, ps, st)) |
| 62 | + |
| 63 | + dev = reactant_device() |
| 64 | + ps_d, st_d, x_d, g1_d, g2_d = (ps, st, x, g1, g2) |> dev |
| 65 | + compiled = @compile f(g1_d, x_d, ps_d, st_d) |
| 66 | + |
| 67 | + y1_cpu = f(g1, x, ps, st) |
| 68 | + y2_cpu = f(g2, x, ps, st) |
| 69 | + y1_compiled = Array(compiled(g1_d, x_d, ps_d, st_d)) |
| 70 | + y2_compiled = Array(compiled(g2_d, x_d, ps_d, st_d)) |
| 71 | + |
| 72 | + @test size(y1_compiled) == (2, 6) |
| 73 | + @test y1_compiled ≈ y1_cpu rtol = 1.0f-4 atol = 1.0f-5 |
| 74 | + @test size(y2_compiled) == (2, 6) |
| 75 | + @test y2_compiled ≈ y2_cpu rtol = 1.0f-4 atol = 1.0f-5 |
| 76 | +end |
0 commit comments