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

Generalize rrule for svdvals #791

Merged
merged 3 commits into from
Apr 16, 2024
Merged

Generalize rrule for svdvals #791

merged 3 commits into from
Apr 16, 2024

Conversation

devmotion
Copy link
Member

Fixes #206.
Fixes #587.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@oxinabox
Copy link
Member

This seems reasonable to me.
Do we expect a performance regression for thhe symmetric case?

@devmotion
Copy link
Member Author

A simple comparison:

main

julia> using ChainRules, BenchmarkTools, LinearAlgebra

julia> @btime ChainRules.rrule(svdvals, $(Symmetric(randn(50, 50))));
  155.542 μs (17 allocations: 79.92 KiB)

julia> @btime $(ChainRules.rrule(svdvals, Symmetric(randn(50, 50)))[2])($(randn(50)));
  7.903 μs (7 allocations: 40.34 KiB)

This PR

julia> @btime ChainRules.rrule(svdvals, $(Symmetric(randn(50, 50))));
  155.875 μs (20 allocations: 118.78 KiB)

julia> @btime $(ChainRules.rrule(svdvals, Symmetric(randn(50, 50)))[2])($(randn(50)));
  7.597 μs (6 allocations: 59.02 KiB)

Setup

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: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M2 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 6 virtual cores)
Environment:
  JULIA_PKG_USE_CLI_GIT = true

@oxinabox oxinabox merged commit d11755b into main Apr 16, 2024
9 of 11 checks passed
@oxinabox oxinabox deleted the dw/svdvals branch April 16, 2024 11:48
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

Successfully merging this pull request may close these issues.

Rule for svdvals Support for svdvals
2 participants