Skip to content

Use nograd keyword for functions too#71

Open
mcabbott wants to merge 6 commits into
masterfrom
nograd2
Open

Use nograd keyword for functions too#71
mcabbott wants to merge 6 commits into
masterfrom
nograd2

Conversation

@mcabbott
Copy link
Copy Markdown
Owner

@mcabbott mcabbott commented Dec 18, 2020

julia> using Tullio, Tracker, ForwardDiff

julia> plus10(x) = x + 10; # a function unknown to DiffRules

julia> Tracker.gradient(rand(3)) do x
         @tullio res := x[k] * plus10(k)  verbose=true
       end
┌ Warning: symbolic gradient failed
│   err = "no diffrule found for function plus10(_)."
└ @ Tullio ~/.julia/dev/Tullio/src/macro.jl:1260
ERROR: no gradient definition here!

julia> Tracker.gradient(rand(3)) do x
         @tullio res := x[k] * plus10(k)  grad=Dual  # old solution
       end
([11.0, 12.0, 13.0] (tracked),)

julia> Tracker.gradient(rand(3)) do x
         @tullio res := x[k] * plus10(k)  nograd=plus10  # new solution
       end
([11.0, 12.0, 13.0] (tracked),)

Needs a test, but #57 is re-organising them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant