File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,36 @@ autodiff(
3535true_dX = cat (ones (100 ), - sin .(X[2 , :]), zeros (100 ); dims= 2 )'
3636
3737@test true_dX ≈ dX
38+
39+ # Broken test (see https://github.com/EnzymeAD/Enzyme.jl/issues/1241)
40+ function my_loss_function (tree, X, operators)
41+ # Get the outputs
42+ y = tree (X, operators)
43+ # Sum them (so we can take a gradient, rather than a jacobian)
44+ return sum (y)
45+ end
46+ tree = 0.5 * x1 + cos (x2 - 0.2 )
47+
48+ # Just to keep things simple:
49+ X = [1.0 1.0 ;]
50+
51+ d_tree = begin
52+ storage_tree = copy (tree)
53+ # Set all constants to zero:
54+ foreach (storage_tree) do node
55+ if node. degree == 0 && node. constant
56+ node. val = 0.0
57+ end
58+ end
59+ autodiff (
60+ Reverse,
61+ my_loss_function,
62+ Active,
63+ Duplicated (tree, storage_tree),
64+ Const (X),
65+ Const (operators),
66+ )
67+ storage_tree
68+ end
69+
70+ @test_broken get_constants (d_tree) ≈ [1.0 , 0.717356 ]
You can’t perform that action at this time.
0 commit comments