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

Gradient returns wrong result for static arrays #1382

Closed
touste opened this issue Apr 5, 2024 · 2 comments
Closed

Gradient returns wrong result for static arrays #1382

touste opened this issue Apr 5, 2024 · 2 comments

Comments

@touste
Copy link

touste commented Apr 5, 2024

julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 20 × 13th Gen Intel(R) Core(TM) i9-13900H
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, goldmont)
Threads: 1 default, 0 interactive, 1 GC (on 20 virtual cores)

(@v1.10) pkg> st
Status `~/.julia/environments/v1.10/Project.toml`
  [7da242da] Enzyme v0.11.20
  [295af30f] Revise v3.5.14
  [90137ffa] StaticArrays v1.9.3

julia> using StaticArrays, Enzyme

julia> x = @SArray [5.0 0.0 6.0]
1×3 SMatrix{1, 3, Float64, 3} with indices SOneTo(1)×SOneTo(3):
 5.0  0.0  6.0

julia> dx = Enzyme.gradient(Enzyme.Reverse, prod, x)
1×3 SMatrix{1, 3, Float64, 3} with indices SOneTo(1)×SOneTo(3):
 0.0  0.0  0.0   <--- Should be [0 30 0]

Strange thing is that this is taken from the tests and ]test Enzyme runs without any issue...

@wsmoses
Copy link
Member

wsmoses commented Apr 5, 2024

Prior to a recent commit on Enzyme.jl#main gradient had the restriction that only Julia arrays were permitted as inputs. This has been alleviated already on main (which added the test).

@wsmoses wsmoses closed this as completed Apr 5, 2024
@touste
Copy link
Author

touste commented Apr 5, 2024

Oh that makes sense! Sorry for the confusion.

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

2 participants