Skip to content

Rule for fill! is wrong #514

Closed
Closed
@mcabbott

Description

@mcabbott

I believe these should all be (Zero, 3):

julia> Zygote.gradient((x,y) -> sum(fill!(x,y)), [1,2,3], 4)
(nothing, nothing)

julia> Zygote.gradient((x,y) -> sum(map(_ -> y, x)), [1,2,3], 4)
([nothing, nothing, nothing], 3)

julia> Diffractor.gradient((x,y) -> sum(fill!(x,y)), [1,2,3], 4)
(ChainRulesCore.NoTangent(), ChainRulesCore.NoTangent())

julia> Diffractor.gradient((x,y) -> sum(map(_ -> y, x)), [1,2,3], 4)
ERROR: AssertionError: Base.issingletontype(typeof(f))
Stacktrace:
 [1] (::∂⃖{1})(#unused#::typeof(map), f::Function, a::Vector{Int64})
   @ Diffractor ~/.julia/packages/Diffractor/K2lJa/src/jet.jl:185

More generally, should in-place functions which completely overwrite their input be allowed? Like circshift! or sum! or mul!.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions