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

@fastmath maximum broken on 1.10 #690

Open
mcabbott opened this issue Jan 23, 2023 · 0 comments
Open

@fastmath maximum broken on 1.10 #690

mcabbott opened this issue Jan 23, 2023 · 0 comments

Comments

@mcabbott
Copy link
Member

julia> using Zygote, BenchmarkTools

julia> @macroexpand1 @fastmath maximum(x)  # this is new
:(Base.FastMath.maximum_fast(x))

julia> VERSION
v"1.10.0-DEV.421"

julia> gradient(x -> sum(maximum(x; dims=1)), [1,3,2])
([0.0, 1.0, 0.0],)

julia> @fastmath gradient(x -> sum(maximum(x; dims=1)), [1,3,2])
ERROR: Mutating arrays is not supported -- called setindex!(Vector{Int64}, ...)

julia> @btime gradient(x -> maximum(x), $([1,3,2]))
  min 1.113 μs, mean 1.214 μs (15 allocations, 528 bytes)
([0.0, 1.0, 0.0],)

julia> @btime @fastmath gradient(x -> maximum(x), $([1,3,2]))  # also misses the rule
  min 28.541 μs, mean 29.743 μs (159 allocations, 5.94 KiB)
([0.0, 1.0, 0.0],)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants