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

Failure with simple mul operation over an SVector #43

Closed
cdsousa opened this issue Mar 24, 2020 · 4 comments
Closed

Failure with simple mul operation over an SVector #43

cdsousa opened this issue Mar 24, 2020 · 4 comments

Comments

@cdsousa
Copy link

cdsousa commented Mar 24, 2020

Hi, isn't the last line supposed to work already?

using LinearAlgebra, StaticArrays, ForwardDiff2
ForwardDiff2.DI(x -> norm(       SVector(0.0, 0.0, x + 1.0) ))(0.0) # works, returns 1.0
ForwardDiff2.DI(x -> norm( 2.0 * SVector(0.0, 0.0, x + 1.0) ))(0.0) # fails with
            # "promotion of types Float64 and ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Float64,Float64} failed to change any arguments"
@MasonProtter
Copy link
Contributor

I don't experience this issue:

julia> using StaticArrays, ForwardDiff2

julia> ForwardDiff2.DI(x -> norm(       SVector(0.0, 0.0, x + 1.0) ))(0.0)
1.0

julia> ForwardDiff2.DI(x -> norm( 2.0 * SVector(0.0, 0.0, x + 1.0) ))(0.0)
2.0

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6* (2020-03-21 16:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen 5 2600 Six-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, znver1)
Environment:
  JULIA_NUM_THREADS = 6

(@v1.4) pkg> st ForwardDiff2 StaticArrays
Status `~/.julia/environments/v1.4/Project.toml`
  [994df76e] ForwardDiff2 v0.2.2
  [90137ffa] StaticArrays v0.12.1

@cdsousa could you re-run the code and if it still errors let us know more info like your version info and package versions?

@cdsousa
Copy link
Author

cdsousa commented Apr 12, 2020

Yes, it is still the same, even with the same versions as you:

julia> using LinearAlgebra, StaticArrays, ForwardDiff2

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, haswell)
Environment:
  JULIA_PKG_SERVER = https://geo.pkg.julialang.org

(@v1.4) pkg> st ForwardDiff2 StaticArrays
Status `~/.julia/environments/v1.4/Project.toml`
  [994df76e] ForwardDiff2 v0.2.2 #master (https://github.com/YingboMa/ForwardDiff2.jl.git)
  [90137ffa] StaticArrays v0.12.1

julia> ForwardDiff2.DI(x -> norm(       SVector(0.0, 0.0, x + 1.0) ))(0.0)
1.0

julia> ForwardDiff2.DI(x -> norm( 2.0 * SVector(0.0, 0.0, x + 1.0) ))(0.0)
ERROR: promotion of types Float64 and ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Float64,Float64} failed to change any arguments
Stacktrace:
 [1] error(::String, ::String, ::String) at ./error.jl:42
 [2] sametype_error(::Tuple{Float64,ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Float64,Float64}}) at ./promotion.jl:306
 [3] not_sametype(::Tuple{Float64,ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Float64,Float64}}, ::Tuple{Float64,ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Float64,Float64}}) at ./promotion.jl:300
 [4] promote at ./promotion.jl:283 [inlined]
 [5] *(::Float64, ::ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Float64,Float64}) at ./promotion.jl:312
 [6] macro expansion at /Users/csousa/.julia/packages/StaticArrays/1g9bq/src/broadcast.jl:125 [inlined]
 [7] _broadcast at /Users/csousa/.julia/packages/StaticArrays/1g9bq/src/broadcast.jl:100 [inlined]
 [8] overdub at /Users/csousa/.julia/packages/Cassette/7OymZ/src/context.jl:262 [inlined]
 [9] copy at /Users/csousa/.julia/packages/StaticArrays/1g9bq/src/broadcast.jl:26 [inlined]
 [10] materialize at ./broadcast.jl:820 [inlined]
 [11] broadcast at ./broadcast.jl:758 [inlined]
 [12] overdub(::Cassette.Context{nametype(DualContext),Nothing,Nothing,ForwardDiff2.var"##PassType#253",Nothing,Cassette.DisableHooks}, ::typeof(broadcast), ::typeof(*), ::Float64, ::SArray{Tuple{3},Real,1,3}) at /Users/csousa/.julia/packages/Cassette/7OymZ/src/overdub.jl:0
 [13] * at /Users/csousa/.julia/packages/StaticArrays/1g9bq/src/linalg.jl:19 [inlined]
 [14] #5 at ./REPL[5]:1 [inlined]
 [15] overdub(::Cassette.Context{nametype(DualContext),Nothing,Nothing,ForwardDiff2.var"##PassType#253",Nothing,Cassette.DisableHooks}, ::var"#5#6", ::ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Float64,Float64}) at /Users/csousa/.julia/packages/Cassette/7OymZ/src/overdub.jl:0
 [16] _frule_overdub2 at /Users/csousa/.julia/packages/ForwardDiff2/a74Px/src/dual_context.jl:90 [inlined]
 [17] alternative at /Users/csousa/.julia/packages/ForwardDiff2/a74Px/src/dual_context.jl:131 [inlined]
 [18] #41 at /Users/csousa/.julia/packages/ForwardDiff2/a74Px/src/api.jl:54 [inlined]
 [19] overdub(::Cassette.Context{nametype(DualContext),Nothing,Nothing,ForwardDiff2.var"##PassType#253",Nothing,Cassette.DisableHooks}, ::ForwardDiff2.var"#41#43"{ForwardDiff2.D{Float64,var"#5#6"},Float64}) at /Users/csousa/.julia/packages/Cassette/7OymZ/src/overdub.jl:0
 [20] dualrun(::Function) at /Users/csousa/.julia/packages/ForwardDiff2/a74Px/src/dual_context.jl:137
 [21] *(::ForwardDiff2.D{Float64,var"#5#6"}, ::Float64) at /Users/csousa/.julia/packages/ForwardDiff2/a74Px/src/api.jl:52
 [22] (::ForwardDiff2.var"#39#40"{var"#5#6"})(::Float64) at /Users/csousa/.julia/packages/ForwardDiff2/a74Px/src/api.jl:44
 [23] top-level scope at REPL[5]:1

@MasonProtter
Copy link
Contributor

Okay, it appears that it's a Cassette issue, I'm able to reproduce your issue by using the currently tagged version of Cassette.jl. Checking out the master branch fixes it.

@YingboMa
Copy link
Owner

This should be fixed by the latest release of Cassette, so I'll close this.

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

3 participants