Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from FluxML:master #41

Merged
merged 3 commits into from
Dec 20, 2020
Merged

[pull] master from FluxML:master #41

merged 3 commits into from
Dec 20, 2020

Conversation

pull[bot]
Copy link

@pull pull bot commented Dec 20, 2020

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 馃挅 Please sponsor : )

Dhairya Gandhi and others added 3 commits November 4, 2020 11:40
819: Fix UnionAll stackoverflow r=DhairyaLGandhi a=DhairyaLGandhi

MWE:

```Julia
c = RGB(0,1,1)
t = RGB(1,1,1)

gradient(colordiff, c, t)
ERROR: StackOverflowError:
Stacktrace:
 [1] unwrap_unionall at ./essentials.jl:234 [inlined]
 [2] _pullback(::Zygote.Context, ::typeof(Base.unwrap_unionall), ::Type{M}) at /Users/dhairyagandhi/Downloads/new_clones/Zygote.jl/src/compiler/interface2.jl:0
 [3] nameof at ./reflection.jl:211 [inlined]
 ...聽(the last 2 lines are repeated 43620 more times)
 [87244] _pullback(::Zygote.Context, ::typeof(nameof), ::Type{M}) at /Users/dhairyagandhi/Downloads/new_clones/Zygote.jl/src/
```

This pointed me to check why there was a stackoverflow, which really shouldn't happen. In some cases, it crashes Julia entirely.

Turns out `nameof` which `UnionAll` structs can cause this but rewriting the complete function like so differentiates as expected.

```Julia
function mynameof(x::UnionAll)
  while isa(x, UnionAll)
    x = x.body
  end
  x.name.name
end
```

Since `nameof` would not produce gradients anyway, I went ahead and gave it a consistent gradient and added the couple other annotations needed to get the Colors.jl examples functional again.

Co-authored-by: Dhairya Gandhi <dhairya@juliacopmuting.com>
@pull pull bot added the 猡碉笍 pull label Dec 20, 2020
@pull pull bot merged commit 6d882d2 into avik-pal:master Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
0 participants