Skip to content

getproperty on a property not found in a Composite should return Zero #103

@oxinabox

Description

@oxinabox

Compsites act like any field not present is Zero during multiplication.

For for getproperty they don't, they just check the backing named tuple.

Consider the following:

struct Foo
a::Float64
b::Float64
end

function bar(ina, inb)
    f = Foo(a, b)
    y = f.a
    return y
end

So the pullback for f.a will be: dy-> NO_FIELDS, Composite{Foo}(;a=dy)
the pullback for Foo(a,b) will be df -> NO_FIELDS, df.a, df,b
And that would error since df.b isn't set.
The correct answer though is to have it be Zero() -- inb has not effect on y

We need to add something that checks propertynames and if not found returns zero, to getproperty

Testcase is:

@test Composite{Foo}(;a=1.4).b === Zero()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Structural TangentRelated to the `Tangent` type for structured (composite) valuesbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions