Error when allocating in a function
Open
- Dominant language
- Julia
- Stars
- 54
- Forks
- 37
- Avg merge
- 5h 49m
- Merged PRs (30d)
- 1
Description
Hi!
The following example seems to expose a weird bug possibly related to allocation:
```julia
using Tracker
x = [1.0]
# Works
function f1(x)
@assert length(x) == 1
return (x .- sum(x))[1]
end
f1(x)
l_tracked, grad = Tracker.forward(f1, x)
l, ∂l∂θ = Tracker.data(l_tracked), Tracker.data(grad(1)[1])
# Errors
function f2(x)
@assert length(x) == 1
theta = x[1]
y = [theta]
return (y .- sum(y))[1]
end
f2(x)
l_tracked, grad = Tracker.forward(f2, x)
l, ∂l∂θ = Tracker.data(l_tracked), Tracker.data(grad(1)[1])
```
Ref: https://github.com/TuringLang/Turing.jl/issues/780
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.