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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic rrule for all getfield #153

Open
oxinabox opened this issue Jan 18, 2020 · 3 comments
Open

generic rrule for all getfield #153

oxinabox opened this issue Jan 18, 2020 · 3 comments

Comments

@oxinabox
Copy link
Member

oxinabox commented Jan 18, 2020

If I am correct: the rrule for getfield is always:

function rrule(::typeof(getfield), val::P, field::Symbol) where P
    getfield_pullback(dy) = NO_FIELDS, Composite{P}(; (field => dy,)...)
    return getfield(val, field), getfield_pullback
end
@willtebbutt
Copy link
Member

Looks correct to me 🤷‍♂

@cossio
Copy link
Contributor

cossio commented Apr 26, 2020

There is a typo, name should be :field.

Shouldn't this also return zeros for the other fields (besides the requested field for which the gradient is 1)?

@willtebbutt
Copy link
Member

Shouldn't this also return zeros for the other fields (besides the requested field for which the gradient is 1)?

Composite handles this lazily -- not specifying a field is essentially the same as setting it to Zero :)

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

No branches or pull requests

4 participants