Diffractor.jl icon indicating copy to clipboard operation
Diffractor.jl copied to clipboard

Bounds error in transform! when taking gradients of functions with dict data

Open motabbara opened this issue 3 years ago • 0 comments

Below fails with BoundsError: attempt to access 3-element Vector{Core.Compiler.BasicBlock} at index [4]

Julia Version 1.10.0-DEV.434 Commit 0231c224a1f (2023-01-26 20:27 UTC)

foo = Dict{Symbol,Float32}()
foo[:a] = 30.0f0
foo[:b] = 40.0f0

struct Something
    data::Dict{Symbol,Float32}
end

s = Something(foo)

function stuff(x::Something, t::Float32)
    x.data[:a] * t*t + x.data[:b]*t
end

Diffractor.gradient(y -> stuff(y, 3.0f0), s)

motabbara avatar Jan 28 '23 03:01 motabbara