Skip to content

Remove LazyArrays.jl dependency #750

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MKL_jll = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
Expand Down Expand Up @@ -105,7 +104,6 @@ Krylov = "0.10"
KrylovKit = "0.10"
KrylovPreconditioners = "0.3"
LAPACK_jll = "3"
LazyArrays = "2.3"
Libdl = "1.10"
LinearAlgebra = "1.10"
MPI = "0.20"
Expand Down
1 change: 0 additions & 1 deletion src/LinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ using LinearAlgebra: LinearAlgebra, BlasInt, LU, Adjoint, BLAS, Bidiagonal, Bunc
cholesky, cholesky!, diagind, dot, inv, ldiv!, ldlt!, lu, lu!, mul!,
norm,
qr, qr!, svd, svd!
using LazyArrays: @~, BroadcastArray
using SciMLBase: SciMLBase, LinearAliasSpecifier, AbstractSciMLOperator,
init, solve!, reinit!, solve, ReturnCode, LinearProblem
using SciMLOperators: SciMLOperators, AbstractSciMLOperator, IdentityOperator,
Expand Down
2 changes: 1 addition & 1 deletion src/adjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function CRC.rrule(::typeof(SciMLBase.solve), prob::LinearProblem,
end

tu = adjoint(sol.u)
∂A = BroadcastArray(@~ .-(λ .* tu))
∂A = .-(λ .* tu)
∂b = λ
∂prob = LinearProblem(∂A, ∂b, ∂∅)

Expand Down
9 changes: 4 additions & 5 deletions test/adjoint.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Zygote, ForwardDiff
using LinearSolve, LinearAlgebra, Test
using FiniteDiff, RecursiveFactorization
using LazyArrays: BroadcastArray

n = 4
A = rand(n, n);
Expand All @@ -19,7 +18,7 @@ end
f(A, b1) # Uses BLAS

dA, db1 = Zygote.gradient(f, A, b1)
@test dA isa BroadcastArray
@test dA isa AbstractMatrix

dA2 = ForwardDiff.gradient(x -> f(x, eltype(x).(b1)), copy(A))
db12 = ForwardDiff.gradient(x -> f(eltype(x).(A), x), copy(b1))
Expand All @@ -37,7 +36,7 @@ _ff = (x,
_ff(copy(A), copy(b1))

dA, db1 = Zygote.gradient(_ff, copy(A), copy(b1))
@test dA isa BroadcastArray
@test dA isa AbstractMatrix

dA2 = ForwardDiff.gradient(x -> f(x, eltype(x).(b1)), copy(A))
db12 = ForwardDiff.gradient(x -> f(eltype(x).(A), x), copy(b1))
Expand All @@ -58,7 +57,7 @@ function f3(A, b1, b2; alg = KrylovJL_GMRES())
end

dA, db1, db2 = Zygote.gradient(f3, A, b1, b1)
@test dA isa BroadcastArray
@test dA isa AbstractMatrix

dA2 = FiniteDiff.finite_difference_gradient(
x -> f3(x, eltype(x).(b1), eltype(x).(b1)), copy(A))
Expand All @@ -83,7 +82,7 @@ function f4(A, b1, b2; alg = LUFactorization())
end

dA, db1, db2 = Zygote.gradient(f4, A, b1, b1)
@test dA isa BroadcastArray
@test dA isa AbstractMatrix

dA2 = ForwardDiff.gradient(x -> f4(x, eltype(x).(b1), eltype(x).(b1)), copy(A))
db12 = ForwardDiff.gradient(x -> f4(eltype(x).(A), x, eltype(x).(b1)), copy(b1))
Expand Down
Loading