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

Broadcast with Bool and Array causes error #42

Open
mohamed82008 opened this issue Jul 21, 2019 · 0 comments
Open

Broadcast with Bool and Array causes error #42

mohamed82008 opened this issue Jul 21, 2019 · 0 comments

Comments

@mohamed82008
Copy link
Collaborator

The following example fails:

using Tracker
f(x, ::Bool) = x;
x = rand(3);
F = x -> sum(f.(x, false));
Tracker.gradient(F, x)

The error is:

ERROR: MethodError: no method matching f(::ForwardDiff.Dual{Nothing,Float64,1}, ::ForwardDiff.Dual{Nothing,Bool,1})
Closest candidates are:
  f(::Any, ::Bool) at REPL[3]:1
Stacktrace:
 [1] partial(::typeof(f), ::Float64, ::Int64, ::Float64, ::Bool) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\lib\array.jl:480
 [2] _broadcast_getindex at .\broadcast.jl:578 [inlined]
 [3] getindex at .\broadcast.jl:511 [inlined]
 [4] copy at .\broadcast.jl:787 [inlined]
 [5] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(Tracker.partial),Tuple{Base.RefValue{typeof(f)},Array{Float64,1},Int64,Array{Float64,1},Bool}}) at .\broadcast.jl:753
 [6] broadcast(::typeof(Tracker.partial), ::Base.RefValue{typeof(f)}, ::Array{Float64,1}, ::Int64, ::Vararg{Any,N} where N) at .\broadcast.jl:707
 [7] ∇broadcast(::typeof(Tracker.partial), ::Base.RefValue{typeof(f)}, ::Array{Float64,1}, ::Int64, ::TrackedArray{…,Array{Float64,1}}, ::Bool) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\lib\array.jl:484
 [8] copy(::Base.Broadcast.Broadcasted{Tracker.TrackedStyle,Tuple{Base.OneTo{Int64}},typeof(Tracker.partial),Tuple{Base.RefValue{typeof(f)},Array{Float64,1},Int64,TrackedArray{,Array{Float64,1}},Bool}}) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\lib\array.jl:515
 [9] materialize at .\broadcast.jl:753 [inlined]
 [10] #547 at C:\Users\user\.julia\packages\Tracker\RRYy6\src\lib\array.jl:488 [inlined]
 [11] ntuple at .\tuple.jl:160 [inlined]
 [12] (::getfield(Tracker, Symbol("#back#548")){2,typeof(f),Tuple{TrackedArray{,Array{Float64,1}},Bool}})(::Array{Float64,1}) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\lib\array.jl:488
 [13] back_(::Tracker.Call{getfield(Tracker, Symbol("#back#548")){2,typeof(f),Tuple{TrackedArray{,Array{Float64,1}},Bool}},Tuple{Tracker.Tracked{Array{Float64,1}},Nothing}}, ::Array{Float64,1}, ::Bool) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:35
 [14] back(::Tracker.Tracked{Array{Float64,1}}, ::Array{Float64,1}, ::Bool) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:58
 [15] foreach at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:38 [inlined]
 [16] back_(::Tracker.Call{getfield(Tracker, Symbol("##482#483")){TrackedArray{,Array{Float64,1}}},Tuple{Tracker.Tracked{Array{Float64,1}}}}, ::Float64, ::Bool) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:38
 [17] back(::Tracker.Tracked{Float64}, ::Int64, ::Bool) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:58
 [18] #back!#15 at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:77 [inlined]
 [19] #back! at .\none:0 [inlined]
 [20] #back!#32 at C:\Users\user\.julia\packages\Tracker\RRYy6\src\lib\real.jl:16 [inlined]
 [21] back!(::Tracker.TrackedReal{Float64}) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\lib\real.jl:14
 [22] gradient_(::Function, ::Array{Float64,1}) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:4
 [23] #gradient#24 at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:164 [inlined]
 [24] gradient(::Function, ::Array{Float64,1}) at C:\Users\user\.julia\packages\Tracker\RRYy6\src\back.jl:164
 [25] top-level scope at none:0
@mohamed82008 mohamed82008 changed the title Broadcast with Bool and TrackedArray causes error Broadcast with Bool and Array causes error Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant