From 3adafe91bc1d62069548a8fd2bf33a7fd152b855 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sun, 18 Jun 2023 11:07:54 -0400 Subject: [PATCH 01/88] Disable check=false on previous Julia versions It's very inconsistently implemented pre v1.9 --- src/ArrayInterface.jl | 128 ++++++++++++++++++++++++++++++------------ 1 file changed, 93 insertions(+), 35 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index ed616a87..04caa7a1 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -440,17 +440,32 @@ matrix_colors(A::Bidiagonal) = _cycle(1:2, Base.size(A, 2)) matrix_colors(A::Union{Tridiagonal, SymTridiagonal}) = _cycle(1:3, Base.size(A, 2)) _cycle(repetend, len) = repeat(repetend, div(len, length(repetend)) + 1)[1:len] -""" -bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance - -Returns an instance of the Bunch-Kaufman factorization object with the correct type -cheaply. -""" -function bunchkaufman_instance(A::Matrix{T}) where T - return bunchkaufman(similar(A, 0, 0), check = false) -end -function bunchkaufman_instance(A::SparseMatrixCSC) - bunchkaufman(sparse(similar(A, 1, 1)), check = false) +@static if VERSION > v"1.9-" + """ + bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance + + Returns an instance of the Bunch-Kaufman factorization object with the correct type + cheaply. + """ + function bunchkaufman_instance(A::Matrix{T}) where T + return bunchkaufman(similar(A, 0, 0), check = false) + end + function bunchkaufman_instance(A::SparseMatrixCSC) + bunchkaufman(sparse(similar(A, 1, 1)), check = false) + end +else + """ + bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance + + Returns an instance of the Bunch-Kaufman factorization object with the correct type + cheaply. + """ + function bunchkaufman_instance(A::Matrix{T}) where T + return bunchkaufman(similar(A, 0, 0)) + end + function bunchkaufman_instance(A::SparseMatrixCSC) + bunchkaufman(sparse(similar(A, 1, 1))) + end end """ @@ -473,18 +488,34 @@ else const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot() end -""" -cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance +@static if VERSION > v"1.9-" + """ + cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance -Returns an instance of the Cholesky factorization object with the correct type -cheaply. -""" -function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} - return cholesky(similar(A, 0, 0), pivot, check = false) -end + Returns an instance of the Cholesky factorization object with the correct type + cheaply. + """ + function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} + return cholesky(similar(A, 0, 0), pivot, check = false) + end + + function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) + cholesky(sparse(similar(A, 1, 1)), check = false) + end +else + """ + cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance + + Returns an instance of the Cholesky factorization object with the correct type + cheaply. + """ + function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} + return cholesky(similar(A, 0, 0), pivot) + end -function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) - cholesky(sparse(similar(A, 1, 1)), check = false) + function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) + cholesky(sparse(similar(A, 1, 1))) + end end """ @@ -494,13 +525,23 @@ Returns the number. """ cholesky_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a -""" -cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) - -Slow fallback which gets the instance via factorization. Should get -specialized for new matrix types. -""" -cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false) +@static if VERSION > v"1.9-" + """ + cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) + + Slow fallback which gets the instance via factorization. Should get + specialized for new matrix types. + """ + cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false) +else + """ + cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) + + Slow fallback which gets the instance via factorization. Should get + specialized for new matrix types. + """ + cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot) +end """ ldlt_instance(A) -> ldlt_factorization_instance @@ -511,8 +552,15 @@ cheaply. function ldlt_instance(A::Matrix{T}) where {T} return ldlt(SymTridiagonal(similar(A, 0, 0))) end -function ldlt_instance(A::SparseMatrixCSC) - ldlt(sparse(similar(A, 1, 1)), check=false) + +@static if VERSION > v"1.9-" + function ldlt_instance(A::SparseMatrixCSC) + ldlt(sparse(similar(A, 1, 1)), check=false) + end +else + function ldlt_instance(A::SparseMatrixCSC) + ldlt(sparse(similar(A, 1, 1))) + end end """ @@ -565,13 +613,23 @@ Returns the number. """ lu_instance(a::Number) = a -""" +@static if VERSION > v"1.9-" + """ + lu_instance(a::Any) -> lu(a, check=false) + + Slow fallback which gets the instance via factorization. Should get + specialized for new matrix types. + """ + lu_instance(a::Any) = lu(a, check = false) +else + """ lu_instance(a::Any) -> lu(a, check=false) -Slow fallback which gets the instance via factorization. Should get -specialized for new matrix types. -""" -lu_instance(a::Any) = lu(a, check = false) + Slow fallback which gets the instance via factorization. Should get + specialized for new matrix types. + """ + lu_instance(a::Any) = lu(a) +end """ qr_instance(A) -> qr_factorization_instance From 175cf1ba956d2e0ea177eedb8f05fe6a88af7e3c Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 18 Jun 2023 11:42:19 -0400 Subject: [PATCH 02/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index d91b1cbd..1fc489bc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.8" +version = "7.4.9" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 19f73ab94185492af64ac1dc03d58f65c74ad48f Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sun, 18 Jun 2023 13:40:09 -0400 Subject: [PATCH 03/88] Fix pivot definition by version --- .github/workflows/ci.yml | 2 ++ src/ArrayInterface.jl | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ebbcfdd..cee8d255 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,8 @@ jobs: version: - '1' - '1.6' + - '1.7' + - '1.8' steps: - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@v1 diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 04caa7a1..e5169892 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -482,7 +482,7 @@ Returns the number. """ bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false) -@static if VERSION < v"1.7beta" +@static if VERSION < v"1.8beta" const DEFAULT_CHOLESKY_PIVOT = Val(false) else const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot() From 61fa0ebe85a3360d7df23c0164b270ec7565a172 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sun, 18 Jun 2023 15:21:05 -0400 Subject: [PATCH 04/88] some checks did exist? --- src/ArrayInterface.jl | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index e5169892..b104f403 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -498,10 +498,6 @@ end function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} return cholesky(similar(A, 0, 0), pivot, check = false) end - - function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) - cholesky(sparse(similar(A, 1, 1)), check = false) - end else """ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance @@ -512,10 +508,10 @@ else function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} return cholesky(similar(A, 0, 0), pivot) end +end - function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) - cholesky(sparse(similar(A, 1, 1))) - end +function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) + cholesky(sparse(similar(A, 1, 1)), check = false) end """ @@ -553,14 +549,8 @@ function ldlt_instance(A::Matrix{T}) where {T} return ldlt(SymTridiagonal(similar(A, 0, 0))) end -@static if VERSION > v"1.9-" - function ldlt_instance(A::SparseMatrixCSC) - ldlt(sparse(similar(A, 1, 1)), check=false) - end -else - function ldlt_instance(A::SparseMatrixCSC) - ldlt(sparse(similar(A, 1, 1))) - end +function ldlt_instance(A::SparseMatrixCSC) + ldlt(sparse(similar(A, 1, 1)), check=false) end """ From 92400fa1b80723753aba32199fd974c082f4976a Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 18 Jun 2023 16:38:45 -0400 Subject: [PATCH 05/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1fc489bc..4d7a075d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.9" +version = "7.4.10" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 612a3aca242db5974dea6bed84b1d81fc2cce094 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sun, 18 Jun 2023 21:57:41 -0400 Subject: [PATCH 06/88] Allow for setting QR pivot types --- Project.toml | 2 +- src/ArrayInterface.jl | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 4d7a075d..5c84a8b2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.10" +version = "7.4.11" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index b104f403..521522dc 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -622,11 +622,28 @@ else end """ - qr_instance(A) -> qr_factorization_instance + qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance Returns an instance of the QR factorization object with the correct type cheaply. """ +function qr_instance(A::Matrix{T},pivot = DEFAULT_CHOLESKY_PIVOT) where {T} + if pivot === DEFAULT_CHOLESKY_PIVOT + LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) + else + LinearAlgebra.QRPivoted(zeros(T,0,0),zeros(T,0),zeros(Int,0)) + end +end + +function qr_instance(A::Matrix{BigFloat},pivot = DEFAULT_CHOLESKY_PIVOT) + LinearAlgebra.QR(zeros(BigFloat,0,0),zeros(BigFloat,0)) +end + +# Could be optimized but this should work for any real case. +function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT) + qr(sparse(rand(1,1))) +end + function qr_instance(A::Matrix{T}) where {T} LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) end From 08aebd387710d7694681f5b5be999305735b842a Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sun, 18 Jun 2023 21:58:51 -0400 Subject: [PATCH 07/88] clean up other dispatches --- src/ArrayInterface.jl | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 521522dc..cb1c91bb 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -644,25 +644,12 @@ function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PI qr(sparse(rand(1,1))) end -function qr_instance(A::Matrix{T}) where {T} - LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) -end - -function qr_instance(A::Matrix{BigFloat}) - LinearAlgebra.QR(zeros(BigFloat,0,0),zeros(BigFloat,0)) -end - -# Could be optimized but this should work for any real case. -function qr_instance(jac_prototype::SparseMatrixCSC) - qr(sparse(rand(1,1))) -end - """ qr_instance(a::Number) -> a Returns the number. """ -qr_instance(a::Number) = a +qr_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a """ qr_instance(a::Any) -> qr(a) @@ -670,7 +657,7 @@ qr_instance(a::Number) = a Slow fallback which gets the instance via factorization. Should get specialized for new matrix types. """ -qr_instance(a::Any) = qr(a)# check = false) +qr_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = qr(a)# check = false) """ svd_instance(A) -> qr_factorization_instance From e63b7938bb45a36a15f17073c979ef5bcbf76dc2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 04:09:42 -0400 Subject: [PATCH 08/88] Bump actions/checkout from 3 to 4 (#421) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/Documentation.yml | 2 +- .github/workflows/Downstream.yml | 4 ++-- .github/workflows/Invalidations.yml | 4 ++-- .github/workflows/ci.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index d2b8c0fa..adc1628e 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -11,7 +11,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@latest with: version: '1' diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index 64794111..0c20c43e 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -32,14 +32,14 @@ jobs: - {user: SciML, repo: DelayDiffEq.jl, group: Interface} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.julia-version }} arch: x64 - uses: julia-actions/julia-buildpkg@latest - name: Clone Downstream - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ${{ matrix.package.user }}/${{ matrix.package.repo }} path: downstream diff --git a/.github/workflows/Invalidations.yml b/.github/workflows/Invalidations.yml index 4d0004e8..28b9ce2f 100644 --- a/.github/workflows/Invalidations.yml +++ b/.github/workflows/Invalidations.yml @@ -19,12 +19,12 @@ jobs: - uses: julia-actions/setup-julia@v1 with: version: '1' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-invalidations@v1 id: invs_pr - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.repository.default_branch }} - uses: julia-actions/julia-buildpkg@v1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cee8d255..30af0d8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - '1.7' - '1.8' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} From 9e5a85aa373ddff10124f376456bf256539686eb Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sun, 15 Oct 2023 16:09:34 -0400 Subject: [PATCH 09/88] Add dispatches for Transpose and Adjoint for Banded Matrices --- Project.toml | 2 +- ext/ArrayInterfaceBandedMatricesExt.jl | 24 ++++++++---- test/bandedmatrices.jl | 53 ++++++++++++++++++++------ 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/Project.toml b/Project.toml index 5c84a8b2..32c6f9be 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.11" +version = "7.5.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/ext/ArrayInterfaceBandedMatricesExt.jl b/ext/ArrayInterfaceBandedMatricesExt.jl index 358434f1..a3b8ca67 100644 --- a/ext/ArrayInterfaceBandedMatricesExt.jl +++ b/ext/ArrayInterfaceBandedMatricesExt.jl @@ -1,16 +1,26 @@ module ArrayInterfaceBandedMatricesExt - if isdefined(Base, :get_extension) using ArrayInterface using ArrayInterface: BandedMatrixIndex using BandedMatrices + using LinearAlgebra else using ..ArrayInterface using ..ArrayInterface: BandedMatrixIndex using ..BandedMatrices + using ..LinearAlgebra end +const TransOrAdjBandedMatrix = Union{ + Adjoint{T, <:BandedMatrix{T}}, + Transpose{T, <:BandedMatrix{T}}, +} where {T} + +const AllBandedMatrix = Union{ + BandedMatrix{T}, + TransOrAdjBandedMatrix{T}, +} where {T} Base.firstindex(i::BandedMatrixIndex) = 1 Base.lastindex(i::BandedMatrixIndex) = i.count @@ -45,12 +55,12 @@ end function BandedMatrixIndex(rowsize, colsize, lowerbandwidth, upperbandwidth, isrow) upperbandwidth > -lowerbandwidth || throw(ErrorException("Invalid Bandwidths")) - bandinds = upperbandwidth:-1:-lowerbandwidth + bandinds = upperbandwidth:-1:(-lowerbandwidth) bandsizes = [_bandsize(band, rowsize, colsize) for band in bandinds] BandedMatrixIndex(sum(bandsizes), rowsize, colsize, bandinds, bandsizes, isrow) end -function ArrayInterface.findstructralnz(x::BandedMatrices.BandedMatrix) +function ArrayInterface.findstructralnz(x::AllBandedMatrix) l, u = BandedMatrices.bandwidths(x) rowsize, colsize = Base.size(x) rowind = BandedMatrixIndex(rowsize, colsize, l, u, true) @@ -58,11 +68,11 @@ function ArrayInterface.findstructralnz(x::BandedMatrices.BandedMatrix) return (rowind, colind) end -ArrayInterface.has_sparsestruct(::Type{<:BandedMatrices.BandedMatrix}) = true -ArrayInterface.isstructured(::Type{<:BandedMatrices.BandedMatrix}) = true -ArrayInterface.fast_matrix_colors(::Type{<:BandedMatrices.BandedMatrix}) = true +ArrayInterface.has_sparsestruct(::Type{<:AllBandedMatrix}) = true +ArrayInterface.isstructured(::Type{<:AllBandedMatrix}) = true +ArrayInterface.fast_matrix_colors(::Type{<:AllBandedMatrix}) = true -function ArrayInterface.matrix_colors(A::BandedMatrices.BandedMatrix) +function ArrayInterface.matrix_colors(A::AllBandedMatrix) l, u = BandedMatrices.bandwidths(A) width = u + l + 1 return ArrayInterface._cycle(1:width, Base.size(A, 2)) diff --git a/test/bandedmatrices.jl b/test/bandedmatrices.jl index a6142efd..94626aac 100644 --- a/test/bandedmatrices.jl +++ b/test/bandedmatrices.jl @@ -1,19 +1,50 @@ - using ArrayInterface using BandedMatrices using Test -B=BandedMatrix(Ones(5,5), (-1,2)) -B[band(1)].=[1,2,3,4] -B[band(2)].=[5,6,7] +function checkequal(idx1::ArrayInterface.BandedMatrixIndex, + idx2::ArrayInterface.BandedMatrixIndex) + return idx1.rowsize == idx2.rowsize && idx1.colsize == idx2.colsize && + idx1.bandinds == idx2.bandinds && idx1.bandsizes == idx2.bandsizes && + idx1.isrow == idx2.isrow && idx1.count == idx2.count +end + +B = BandedMatrix(Ones(5, 5), (-1, 2)) +B[band(1)] .= [1, 2, 3, 4] +B[band(2)] .= [5, 6, 7] @test ArrayInterface.has_sparsestruct(B) -rowind,colind=ArrayInterface.findstructralnz(B) -@test [B[rowind[i],colind[i]] for i in 1:length(rowind)]==[5,6,7,1,2,3,4] -B=BandedMatrix(Ones(4,6), (-1,2)) -B[band(1)].=[1,2,3,4] -B[band(2)].=[5,6,7,8] -rowind,colind=ArrayInterface.findstructralnz(B) -@test [B[rowind[i],colind[i]] for i in 1:length(rowind)]==[5,6,7,8,1,2,3,4] +rowind, colind = ArrayInterface.findstructralnz(B) +@test [B[rowind[i], colind[i]] for i in 1:length(rowind)] == [5, 6, 7, 1, 2, 3, 4] +B = BandedMatrix(Ones(4, 6), (-1, 2)) +B[band(1)] .= [1, 2, 3, 4] +B[band(2)] .= [5, 6, 7, 8] +rowind, colind = ArrayInterface.findstructralnz(B) +@test [B[rowind[i], colind[i]] for i in 1:length(rowind)] == [5, 6, 7, 8, 1, 2, 3, 4] @test ArrayInterface.isstructured(typeof(B)) @test ArrayInterface.fast_matrix_colors(typeof(B)) +for op in (adjoint, transpose) + B = BandedMatrix(Ones(5, 5), (-1, 2)) + B[band(1)] .= [1, 2, 3, 4] + B[band(2)] .= [5, 6, 7] + B′ = op(B) + @test ArrayInterface.has_sparsestruct(B′) + rowind′, colind′ = ArrayInterface.findstructralnz(B′) + rowind′′, colind′′ = ArrayInterface.findstructralnz(BandedMatrix(B′)) + @test checkequal(rowind′, rowind′′) + @test checkequal(colind′, colind′′) + + B = BandedMatrix(Ones(4, 6), (-1, 2)) + B[band(1)] .= [1, 2, 3, 4] + B[band(2)] .= [5, 6, 7, 8] + B′ = op(B) + rowind′, colind′ = ArrayInterface.findstructralnz(B′) + rowind′′, colind′′ = ArrayInterface.findstructralnz(BandedMatrix(B′)) + @test checkequal(rowind′, rowind′′) + @test checkequal(colind′, colind′′) + + @test ArrayInterface.isstructured(typeof(B′)) + @test ArrayInterface.fast_matrix_colors(typeof(B′)) + + @test ArrayInterface.matrix_colors(B′) == ArrayInterface.matrix_colors(BandedMatrix(B′)) +end From b3a3246bdd0ce089460918c32fb54a88edd636ec Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 16 Oct 2023 03:26:22 -0400 Subject: [PATCH 10/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 32c6f9be..478aea9c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.5.0" +version = "7.6.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 2215344309dc5fe41bddfba6c9f55104f60d582f Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 29 Oct 2023 07:39:04 -0400 Subject: [PATCH 11/88] Support and test complex instance types --- src/ArrayInterface.jl | 2 +- test/core.jl | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index cb1c91bb..5297a87e 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -666,7 +666,7 @@ Returns an instance of the SVD factorization object with the correct type cheaply. """ function svd_instance(A::Matrix{T}) where {T} - LinearAlgebra.SVD(zeros(T,0,0),zeros(T,0),zeros(T,0,0)) + LinearAlgebra.SVD(zeros(T,0,0),zeros(real(T),0),zeros(T,0,0)) end """ diff --git a/test/core.jl b/test/core.jl index bd0cd6cf..bf9b0712 100644 --- a/test/core.jl +++ b/test/core.jl @@ -261,16 +261,18 @@ end end @testset "linearalgebra instances" begin - for A in [rand(2,2), rand(Float32,2,2), rand(BigFloat,2,2)] + for A in [rand(2,2), rand(Float32,2,2), rand(BigFloat,2,2), rand(ComplexF32,2,2), rand(ComplexF64,2,2)] @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) @test ArrayInterface.qr_instance(A) isa typeof(qr(A)) if !(eltype(A) <: BigFloat) - @test ArrayInterface.bunchkaufman_instance(A' * A) isa typeof(bunchkaufman(A' * A)) @test ArrayInterface.cholesky_instance(A' * A) isa typeof(cholesky(A' * A)) - @test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A))) @test ArrayInterface.svd_instance(A) isa typeof(svd(A)) + if !(eltype(A) <: Union{ComplexF16,ComplexF32,ComplexF64}) + @test ArrayInterface.bunchkaufman_instance(A' * A) isa typeof(bunchkaufman(A' * A)) + @test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A))) + end end end From 1ba6664e7f9e9dc84485aaf9fb59bb221b9bc8df Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 29 Oct 2023 07:39:29 -0400 Subject: [PATCH 12/88] bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 478aea9c..bc02b5c1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.6.0" +version = "7.6.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 96950ea402988dbba4a611a3140d221cf7605d7e Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 29 Oct 2023 07:40:42 -0400 Subject: [PATCH 13/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index bc02b5c1..32c6f9be 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.6.1" +version = "7.5.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 646b8aba27cb05ee065c5d4c9fdf0ac413e4a2b5 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 29 Oct 2023 07:46:37 -0400 Subject: [PATCH 14/88] Update Project.toml --- Project.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Project.toml b/Project.toml index 32c6f9be..181046cf 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,10 @@ SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [compat] Adapt = "3" +LinearAlgebra = "1.6" Requires = "1" +SparseArrays = "1.6" +SuiteSparse = "1.6" julia = "1.6" [extensions] From 76673b6d198de6391ffa3db15132e58f1bc357b3 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 1 Nov 2023 08:24:36 -0400 Subject: [PATCH 15/88] Better instance construction for ldlt Cannot be singular checked in some versions, so this is a nicer way to handle it. Fixes https://github.com/SciML/OrdinaryDiffEq.jl/issues/2041 --- src/ArrayInterface.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 5297a87e..b364c5de 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -546,13 +546,17 @@ Returns an instance of the LDLT factorization object with the correct type cheaply. """ function ldlt_instance(A::Matrix{T}) where {T} - return ldlt(SymTridiagonal(similar(A, 0, 0))) + return ldlt_instance(SymTridiagonal(similar(A, 0, 0))) end function ldlt_instance(A::SparseMatrixCSC) ldlt(sparse(similar(A, 1, 1)), check=false) end +function ldlt_instance(A::SymTridiagonal{T,V}) where {T,V} + return LinearAlgebra.LDLt{T,SymTridiagonal{T,V}}(A) +end + """ ldlt_instance(a::Number) -> a From 43dafbb867cfb39a78e48176003de8ed1b90263a Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 1 Nov 2023 09:15:41 -0400 Subject: [PATCH 16/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 181046cf..7dbf6a02 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.5.0" +version = "7.5.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From eabb167bac910c2f46d15fd0a13cb2f86a7b663f Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 22 Nov 2023 04:37:10 -0500 Subject: [PATCH 17/88] Cover more lu instance types --- Project.toml | 2 +- src/ArrayInterface.jl | 22 ++++++++++++++++++++++ test/core.jl | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7dbf6a02..58b2fd1c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.5.1" +version = "7.5.2" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index b364c5de..7c5ab168 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -600,6 +600,28 @@ function lu_instance(jac_prototype::SparseMatrixCSC) end end +function lu_instance(A::Symmetric{T}) where {T} + noUnitT = typeof(zero(T)) + luT = LinearAlgebra.lutype(noUnitT) + ipiv = Vector{LinearAlgebra.BlasInt}(undef, 0) + info = zero(LinearAlgebra.BlasInt) + return LU{luT}(similar(A, 0, 0), ipiv, info) +end + +noalloc_diag(A::Diagonal) = A.diag +noalloc_diag(A::Tridiagonal) = A.d +noalloc_diag(A::SymTridiagonal) = A.dv + +function lu_instance(A::Union{Tridiagonal{T},Diagonal{T},SymTridiagonal{T}}) where {T} + noUnitT = typeof(zero(T)) + luT = LinearAlgebra.lutype(noUnitT) + ipiv = Vector{LinearAlgebra.BlasInt}(undef, 0) + info = zero(LinearAlgebra.BlasInt) + vectype = similar(noalloc_diag(A), 0) + newA = Tridiagonal(vectype, vectype, vectype) + return LU{luT}(newA, ipiv, info) +end + """ lu_instance(a::Number) -> a diff --git a/test/core.jl b/test/core.jl index bf9b0712..5208393f 100644 --- a/test/core.jl +++ b/test/core.jl @@ -71,6 +71,11 @@ end A = sprand(50, 50, 0.5) @test lu_instance(A) isa typeof(lu(A)) @test lu_instance(1) === 1 + + @test lu_instance(Symmetric(rand(3,3))) isa typeof(lu(Symmetric(rand(4,4)))) + @test lu_instance(Tridiagonal(rand(3),rand(4),rand(3))) isa typeof(lu(Tridiagonal(rand(3),rand(4),rand(3)))) + @test lu_instance(SymTridiagonal(rand(4),rand(3))) isa typeof(lu(SymTridiagonal(rand(4),rand(3)))) + @test lu_instance(Diagonal(rand(4))) isa typeof(lu(Diagonal(rand(4)))) end @testset "ismutable" begin From 78f4ca1886a24399aa2a017430fa034da830a63b Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 22 Nov 2023 04:43:38 -0500 Subject: [PATCH 18/88] bump version --- .github/workflows/ci.yml | 3 --- Project.toml | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30af0d8b..d0835864 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,6 @@ jobs: - Core version: - '1' - - '1.6' - - '1.7' - - '1.8' steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 diff --git a/Project.toml b/Project.toml index 58b2fd1c..104b251e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.5.2" +version = "7.6.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -11,11 +11,11 @@ SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [compat] Adapt = "3" -LinearAlgebra = "1.6" +LinearAlgebra = "1.9" Requires = "1" -SparseArrays = "1.6" -SuiteSparse = "1.6" -julia = "1.6" +SparseArrays = "1.9" +SuiteSparse = "1.9" +julia = "1.9" [extensions] ArrayInterfaceBandedMatricesExt = "BandedMatrices" From 0660226c74c1b07d89762d4bc99ef855d9ae1512 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 22 Nov 2023 05:27:59 -0500 Subject: [PATCH 19/88] remove back compats --- .github/workflows/Downstream.yml | 2 +- src/ArrayInterface.jl | 211 ++++++++----------------------- 2 files changed, 56 insertions(+), 157 deletions(-) diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index 0c20c43e..922d4adf 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - julia-version: [1,1.6] + julia-version: [1] os: [ubuntu-latest] package: - {user: JuliaDiff, repo: SparseDiffTools.jl, group: Core} diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 7c5ab168..75a49f01 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -40,22 +40,8 @@ julia> ArrayInterface.map_tuple_type(sqrt, Tuple{1,4,16}) ``` """ function map_tuple_type end -if VERSION >= v"1.8" - @inline function map_tuple_type(f, @nospecialize(T::Type)) - ntuple(i -> f(fieldtype(T, i)), Val{fieldcount(T)}()) - end -else - function map_tuple_type(f::F, ::Type{T}) where {F, T <: Tuple} - if @generated - t = Expr(:tuple) - for i in 1:fieldcount(T) - push!(t.args, :(f($(fieldtype(T, i))))) - end - Expr(:block, Expr(:meta, :inline), t) - else - Tuple(f(fieldtype(T, i)) for i in 1:fieldcount(T)) - end - end +@inline function map_tuple_type(f, @nospecialize(T::Type)) + ntuple(i -> f(fieldtype(T, i)), Val{fieldcount(T)}()) end """ @@ -78,50 +64,22 @@ julia> ArrayInterface.flatten_tuples((1, (2, (3,)))) ``` """ function flatten_tuples end -if VERSION >= v"1.8" - function flatten_tuples(t::Tuple) - fields = _new_field_positions(t) - ntuple(Val{nfields(fields)}()) do k - i, j = getfield(fields, k) - i = length(t) - i - @inbounds j === 0 ? getfield(t, i) : getfield(getfield(t, i), j) - end - end - _new_field_positions(::Tuple{}) = () - @nospecialize - function _new_field_positions(x::Tuple) - (_fl1(x, x[1])..., _new_field_positions(Base.tail(x))...) - end - _fl1(x::Tuple, x1::Tuple) = ntuple(Base.Fix1(tuple, length(x) - 1), Val(length(x1))) - _fl1(x::Tuple, x1) = ((length(x) - 1, 0),) - @specialize -else - @inline function flatten_tuples(t::Tuple) - if @generated - texpr = Expr(:tuple) - for i in 1:fieldcount(t) - p = fieldtype(t, i) - if p <: Tuple - for j in 1:fieldcount(p) - push!(texpr.args, :(@inbounds(getfield(getfield(t, $i), $j)))) - end - else - push!(texpr.args, :(@inbounds(getfield(t, $i)))) - end - end - Expr(:block, Expr(:meta, :inline), texpr) - else - _flatten(t) - end - end - _flatten(::Tuple{}) = () - @inline function _flatten(t::Tuple{Any, Vararg{Any}}) - (getfield(t, 1), _flatten(Base.tail(t))...) - end - @inline function _flatten(t::Tuple{Tuple, Vararg{Any}}) - (getfield(t, 1)..., _flatten(Base.tail(t))...) +function flatten_tuples(t::Tuple) + fields = _new_field_positions(t) + ntuple(Val{nfields(fields)}()) do k + i, j = getfield(fields, k) + i = length(t) - i + @inbounds j === 0 ? getfield(t, i) : getfield(getfield(t, i), j) end end +_new_field_positions(::Tuple{}) = () +@nospecialize +function _new_field_positions(x::Tuple) + (_fl1(x, x[1])..., _new_field_positions(Base.tail(x))...) +end +_fl1(x::Tuple, x1::Tuple) = ntuple(Base.Fix1(tuple, length(x) - 1), Val(length(x1))) +_fl1(x::Tuple, x1) = ((length(x) - 1, 0),) +@specialize """ parent_type(::Type{T}) -> Type @@ -299,11 +257,7 @@ ismutable(::Type{BigFloat}) = false ismutable(::Type{BigInt}) = false function ismutable(::Type{T}) where {T} if parent_type(T) <: T - @static if VERSION ≥ v"1.7.0-DEV.1208" - return Base.ismutabletype(T) - else - return T.mutable - end + return Base.ismutabletype(T) else return ismutable(parent_type(T)) end @@ -440,32 +394,17 @@ matrix_colors(A::Bidiagonal) = _cycle(1:2, Base.size(A, 2)) matrix_colors(A::Union{Tridiagonal, SymTridiagonal}) = _cycle(1:3, Base.size(A, 2)) _cycle(repetend, len) = repeat(repetend, div(len, length(repetend)) + 1)[1:len] -@static if VERSION > v"1.9-" - """ - bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance +""" +bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance - Returns an instance of the Bunch-Kaufman factorization object with the correct type - cheaply. - """ - function bunchkaufman_instance(A::Matrix{T}) where T - return bunchkaufman(similar(A, 0, 0), check = false) - end - function bunchkaufman_instance(A::SparseMatrixCSC) - bunchkaufman(sparse(similar(A, 1, 1)), check = false) - end -else - """ - bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance - - Returns an instance of the Bunch-Kaufman factorization object with the correct type - cheaply. - """ - function bunchkaufman_instance(A::Matrix{T}) where T - return bunchkaufman(similar(A, 0, 0)) - end - function bunchkaufman_instance(A::SparseMatrixCSC) - bunchkaufman(sparse(similar(A, 1, 1))) - end +Returns an instance of the Bunch-Kaufman factorization object with the correct type +cheaply. +""" +function bunchkaufman_instance(A::Matrix{T}) where T + return bunchkaufman(similar(A, 0, 0), check = false) +end +function bunchkaufman_instance(A::SparseMatrixCSC) + bunchkaufman(sparse(similar(A, 1, 1)), check = false) end """ @@ -482,32 +421,16 @@ Returns the number. """ bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false) -@static if VERSION < v"1.8beta" - const DEFAULT_CHOLESKY_PIVOT = Val(false) -else - const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot() -end +const DEFAULT_CHOLESKY_PIVOT = Val(false) -@static if VERSION > v"1.9-" - """ - cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance +""" +cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance - Returns an instance of the Cholesky factorization object with the correct type - cheaply. - """ - function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} - return cholesky(similar(A, 0, 0), pivot, check = false) - end -else - """ - cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance - - Returns an instance of the Cholesky factorization object with the correct type - cheaply. - """ - function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} - return cholesky(similar(A, 0, 0), pivot) - end +Returns an instance of the Cholesky factorization object with the correct type +cheaply. +""" +function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} + return cholesky(similar(A, 0, 0), pivot, check = false) end function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) @@ -521,23 +444,13 @@ Returns the number. """ cholesky_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a -@static if VERSION > v"1.9-" - """ - cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) - - Slow fallback which gets the instance via factorization. Should get - specialized for new matrix types. - """ - cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false) -else - """ - cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) - - Slow fallback which gets the instance via factorization. Should get - specialized for new matrix types. - """ - cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot) -end +""" +cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) + +Slow fallback which gets the instance via factorization. Should get +specialized for new matrix types. +""" +cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false) """ ldlt_instance(A) -> ldlt_factorization_instance @@ -586,18 +499,14 @@ function lu_instance(A::Matrix{T}) where {T} return LU{luT}(similar(A, 0, 0), ipiv, info) end function lu_instance(jac_prototype::SparseMatrixCSC) - @static if VERSION < v"1.9.0-DEV.1622" - SuiteSparse.UMFPACK.UmfpackLU(Ptr{Cvoid}(), - Ptr{Cvoid}(), - 1, - 1, - jac_prototype.colptr[1:1], - jac_prototype.rowval[1:1], - jac_prototype.nzval[1:1], - 0) - else - SuiteSparse.UMFPACK.UmfpackLU(similar(jac_prototype, 1, 1)) - end + SuiteSparse.UMFPACK.UmfpackLU(Ptr{Cvoid}(), + Ptr{Cvoid}(), + 1, + 1, + jac_prototype.colptr[1:1], + jac_prototype.rowval[1:1], + jac_prototype.nzval[1:1], + 0) end function lu_instance(A::Symmetric{T}) where {T} @@ -629,23 +538,13 @@ Returns the number. """ lu_instance(a::Number) = a -@static if VERSION > v"1.9-" - """ - lu_instance(a::Any) -> lu(a, check=false) - - Slow fallback which gets the instance via factorization. Should get - specialized for new matrix types. - """ - lu_instance(a::Any) = lu(a, check = false) -else - """ +""" lu_instance(a::Any) -> lu(a, check=false) - Slow fallback which gets the instance via factorization. Should get - specialized for new matrix types. - """ - lu_instance(a::Any) = lu(a) -end +Slow fallback which gets the instance via factorization. Should get +specialized for new matrix types. +""" +lu_instance(a::Any) = lu(a, check = false) """ qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance From c42fd7e066852be8ab1f6eedf742fc5455dc3cdd Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 22 Nov 2023 05:40:42 -0500 Subject: [PATCH 20/88] fix wrong branch --- src/ArrayInterface.jl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 75a49f01..be612970 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -499,14 +499,7 @@ function lu_instance(A::Matrix{T}) where {T} return LU{luT}(similar(A, 0, 0), ipiv, info) end function lu_instance(jac_prototype::SparseMatrixCSC) - SuiteSparse.UMFPACK.UmfpackLU(Ptr{Cvoid}(), - Ptr{Cvoid}(), - 1, - 1, - jac_prototype.colptr[1:1], - jac_prototype.rowval[1:1], - jac_prototype.nzval[1:1], - 0) + SuiteSparse.UMFPACK.UmfpackLU(similar(jac_prototype, 1, 1)) end function lu_instance(A::Symmetric{T}) where {T} From d0576ea2e95d75a99d5384a7fae84d9b87c8494e Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 22 Nov 2023 10:04:53 -0500 Subject: [PATCH 21/88] Update ArrayInterface.jl --- src/ArrayInterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index be612970..3804c5c7 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -421,7 +421,7 @@ Returns the number. """ bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false) -const DEFAULT_CHOLESKY_PIVOT = Val(false) +const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot() """ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance From 63244927b5ad77d09e01426245d26387785b45e4 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 22 Nov 2023 10:05:02 -0500 Subject: [PATCH 22/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 104b251e..960f42cf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.6.0" +version = "7.6.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 1f2e2e2bb787b555851d9d4813070711c9dfcc89 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Mon, 18 Dec 2023 15:09:25 +0000 Subject: [PATCH 23/88] CompatHelper: bump compat for Adapt to 4, (keep existing compat) --- Project.toml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Project.toml b/Project.toml index 960f42cf..15bdd344 100644 --- a/Project.toml +++ b/Project.toml @@ -9,13 +9,13 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" -[compat] -Adapt = "3" -LinearAlgebra = "1.9" -Requires = "1" -SparseArrays = "1.9" -SuiteSparse = "1.9" -julia = "1.9" +[weakdeps] +BandedMatrices = "aae01518-5342-5314-be14-df237901396f" +BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" +StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" +Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [extensions] ArrayInterfaceBandedMatricesExt = "BandedMatrices" @@ -25,29 +25,29 @@ ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" ArrayInterfaceTrackerExt = "Tracker" +[compat] +Adapt = "3, 4" +LinearAlgebra = "1.9" +Requires = "1" +SparseArrays = "1.9" +SuiteSparse = "1.9" +julia = "1.9" + [extras] -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" -Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" -Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" +SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [targets] test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker"] - -[weakdeps] -BandedMatrices = "aae01518-5342-5314-be14-df237901396f" -BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" -GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" -StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" -Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" From 40d9a87be07ba323cca00f9e59e5285c13f7ee72 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 18 Dec 2023 10:19:26 -0500 Subject: [PATCH 24/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 15bdd344..00467e22 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.6.1" +version = "7.7.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 3f1554c39cab3ecef61526c83a142e2c3cb180a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 07:34:23 +0000 Subject: [PATCH 25/88] Bump actions/cache from 3 to 4 Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0835864..189aacd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} - - uses: actions/cache@v3 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: From 43748d9103731257c4a71ef9ef87759d75b31a6a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 09:47:35 -0500 Subject: [PATCH 26/88] Bump codecov/codecov-action from 3 to 4 (#427) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3...v4) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/Documentation.yml | 2 +- .github/workflows/Downstream.yml | 2 +- .github/workflows/ci.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index adc1628e..d26b9dd0 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -23,6 +23,6 @@ jobs: DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key run: julia --project=docs/ --code-coverage=user docs/make.jl - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: file: lcov.info diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index 922d4adf..34b8e1bc 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -61,6 +61,6 @@ jobs: exit(0) # Exit immediately, as a success end - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: file: lcov.info diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 189aacd5..d9333ffb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,6 @@ jobs: env: GROUP: ${{ matrix.group }} - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: file: lcov.info \ No newline at end of file From 4bfd6ce080c92adc4c7cd3fcf959afc19341f9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20E=2E=20Cruz=20Serrall=C3=A9s?= Date: Wed, 14 Feb 2024 09:54:25 -0500 Subject: [PATCH 27/88] Fixed can_setindex for MArray can_setindex now evaluates to true for Type{<:StaticArraysCore.MArray} --- ext/ArrayInterfaceStaticArraysCoreExt.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/ArrayInterfaceStaticArraysCoreExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl index 5c555f63..c7b14279 100644 --- a/ext/ArrayInterfaceStaticArraysCoreExt.jl +++ b/ext/ArrayInterfaceStaticArraysCoreExt.jl @@ -24,6 +24,7 @@ ArrayInterface.ismutable(::Type{<:StaticArraysCore.MArray}) = true ArrayInterface.ismutable(::Type{<:StaticArraysCore.SizedArray}) = true ArrayInterface.can_setindex(::Type{<:StaticArraysCore.StaticArray}) = false +ArrayInterface.can_setindex(::Type{<:StaticArraysCore.MArray}) = true ArrayInterface.buffer(A::Union{StaticArraysCore.SArray,StaticArraysCore.MArray}) = getfield(A, :data) function ArrayInterface.lu_instance(_A::StaticArraysCore.StaticMatrix{N,N}) where {N} From ae06bba1f148907fe6cd3381924945ff3976bb0e Mon Sep 17 00:00:00 2001 From: jecs Date: Wed, 14 Feb 2024 13:34:57 -0500 Subject: [PATCH 28/88] Added test and bumped version number --- Project.toml | 2 +- test/staticarrayscore.jl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 00467e22..5f3aba73 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.7.0" +version = "7.7.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/test/staticarrayscore.jl b/test/staticarrayscore.jl index 420a05c7..cbbba184 100644 --- a/test/staticarrayscore.jl +++ b/test/staticarrayscore.jl @@ -11,6 +11,7 @@ x = @SVector [1,2,3] x = @MVector [1,2,3] @test ArrayInterface.ismutable(x) == true @test ArrayInterface.ismutable(view(x, 1:2)) == true +@test ArrayInterface.can_setindex(typeof(x)) == true A = @SMatrix(randn(5, 5)) @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) From 3487312630daa4ab1ec7d26cfff8c3fcd91c26d6 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 3 Mar 2024 19:38:27 -0500 Subject: [PATCH 29/88] Specialize Array of Structs to Struct of Array for ReverseDiff --- Project.toml | 17 ++++++++++------- ext/ArrayInterfaceReverseDiffExt.jl | 23 +++++++++++++++++++++++ test/ad.jl | 10 ++++++++++ test/runtests.jl | 3 ++- 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 ext/ArrayInterfaceReverseDiffExt.jl create mode 100644 test/ad.jl diff --git a/Project.toml b/Project.toml index 5f3aba73..b5ba13fb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.7.1" +version = "7.8.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -14,6 +14,7 @@ BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" +ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" @@ -22,16 +23,17 @@ ArrayInterfaceBandedMatricesExt = "BandedMatrices" ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" ArrayInterfaceCUDAExt = "CUDA" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" +ArrayInterfaceReverseDiffExt = "ReverseDiff" ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" ArrayInterfaceTrackerExt = "Tracker" [compat] -Adapt = "3, 4" -LinearAlgebra = "1.9" +Adapt = "4" +LinearAlgebra = "1.10" Requires = "1" -SparseArrays = "1.9" -SuiteSparse = "1.9" -julia = "1.9" +SparseArrays = "1.10" +SuiteSparse = "1.10" +julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" @@ -41,6 +43,7 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" @@ -50,4 +53,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [targets] -test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker"] +test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff"] diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl new file mode 100644 index 00000000..f8c8e4bc --- /dev/null +++ b/ext/ArrayInterfaceReverseDiffExt.jl @@ -0,0 +1,23 @@ +module ArrayInterfaceReverseDiffExt + +if isdefined(Base, :get_extension) + using ArrayInterface + import ReverseDiff +else + using ..ArrayInterface + import ..ReverseDiff +end + +ArrayInterface.ismutable(::Type{<:ReverseDiff.TrackedArray}) = false +ArrayInterface.ismutable(T::Type{<:ReverseDiff.TrackedReal}) = false +ArrayInterface.can_setindex(::Type{<:ReverseDiff.TrackedArray}) = false +ArrayInterface.fast_scalar_indexing(::Type{<:ReverseDiff.TrackedArray}) = false +function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal,N}) where {N} + if length(x) > 1 + reduce(vcat,x) + else + reduce(vcat,[x[1],x[1]])[1:1] + end +end + +end # module diff --git a/test/ad.jl b/test/ad.jl new file mode 100644 index 00000000..92b88461 --- /dev/null +++ b/test/ad.jl @@ -0,0 +1,10 @@ +using ArrayInterface, ReverseDiff, Tracker +x = reduce(vcat, ReverseDiff.track([4.0])) +ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray +x = reduce(vcat, ReverseDiff.track([4.0,4.0])) +ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray + +x = identity.(Tracker.TrackedArray([4.0])) +ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray +x = identity.(Tracker.TrackedArray([4.0,4.0])) +ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray diff --git a/test/runtests.jl b/test/runtests.jl index ec3493fd..bedb7693 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,6 +13,7 @@ end @time @safetestset "BandedMatrices" begin include("bandedmatrices.jl") end @time @safetestset "BlockBandedMatrices" begin include("blockbandedmatrices.jl") end @time @safetestset "Core" begin include("core.jl") end + @time @safetestset "AD Integration" begin include("ad.jl") end @time @safetestset "StaticArraysCore" begin include("staticarrayscore.jl") end end @@ -20,4 +21,4 @@ end activate_gpu_env() @time @safetestset "CUDA" begin include("gpu/cuda.jl") end end -end \ No newline at end of file +end From 7c97b62fbb04b4a28b22c0c568b47cfb54f7032e Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 3 Mar 2024 19:42:48 -0500 Subject: [PATCH 30/88] add tests --- test/ad.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/ad.jl b/test/ad.jl index 92b88461..4754b8b8 100644 --- a/test/ad.jl +++ b/test/ad.jl @@ -1,10 +1,10 @@ -using ArrayInterface, ReverseDiff, Tracker +using ArrayInterface, ReverseDiff, Tracker, Test x = reduce(vcat, ReverseDiff.track([4.0])) -ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray +@test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray x = reduce(vcat, ReverseDiff.track([4.0,4.0])) -ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray +@test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray x = identity.(Tracker.TrackedArray([4.0])) -ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray +@test ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray x = identity.(Tracker.TrackedArray([4.0,4.0])) -ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray +@test ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray From 80e220d9df90ee5c11c0af956933e3ffb76833b8 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 3 Mar 2024 19:55:34 -0500 Subject: [PATCH 31/88] fix tests --- ext/ArrayInterfaceReverseDiffExt.jl | 1 + test/ad.jl | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl index f8c8e4bc..13bfd23f 100644 --- a/ext/ArrayInterfaceReverseDiffExt.jl +++ b/ext/ArrayInterfaceReverseDiffExt.jl @@ -16,6 +16,7 @@ function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal,N} if length(x) > 1 reduce(vcat,x) else + @show "here?" reduce(vcat,[x[1],x[1]])[1:1] end end diff --git a/test/ad.jl b/test/ad.jl index 4754b8b8..7c29c8dd 100644 --- a/test/ad.jl +++ b/test/ad.jl @@ -1,10 +1,20 @@ using ArrayInterface, ReverseDiff, Tracker, Test -x = reduce(vcat, ReverseDiff.track([4.0])) +x = ReverseDiff.track([4.0]) @test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray x = reduce(vcat, ReverseDiff.track([4.0,4.0])) @test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray +x = [ReverseDiff.track([4.0])[1]] +@test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray +x = reduce(vcat, ReverseDiff.track([4.0,4.0])) +x = [x[1],x[2]] +@test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray -x = identity.(Tracker.TrackedArray([4.0])) +x = Tracker.TrackedArray([4.0]) +@test ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray +x = [Tracker.TrackedArray([4.0])[1]] +@test ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray +x = Tracker.TrackedArray([4.0,4.0]) @test ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray -x = identity.(Tracker.TrackedArray([4.0,4.0])) +x = reduce(vcat, Tracker.TrackedArray([4.0,4.0])) +x = [x[1],x[2]] @test ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray From bbf06e2c34648563eb9b4b9b479ddb17419b84f1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 3 Mar 2024 19:58:17 -0500 Subject: [PATCH 32/88] Update ArrayInterfaceReverseDiffExt.jl --- ext/ArrayInterfaceReverseDiffExt.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl index 13bfd23f..f8c8e4bc 100644 --- a/ext/ArrayInterfaceReverseDiffExt.jl +++ b/ext/ArrayInterfaceReverseDiffExt.jl @@ -16,7 +16,6 @@ function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal,N} if length(x) > 1 reduce(vcat,x) else - @show "here?" reduce(vcat,[x[1],x[1]])[1:1] end end From fc353f80a13ad157307555f5627050c647571369 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 7 Mar 2024 12:08:08 -0500 Subject: [PATCH 33/88] Preserve the dimensions of ReverseDiff TrackedArray --- Project.toml | 2 +- ext/ArrayInterfaceReverseDiffExt.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index b5ba13fb..48f462d4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.8.0" +version = "7.8.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl index f8c8e4bc..c303398b 100644 --- a/ext/ArrayInterfaceReverseDiffExt.jl +++ b/ext/ArrayInterfaceReverseDiffExt.jl @@ -14,9 +14,9 @@ ArrayInterface.can_setindex(::Type{<:ReverseDiff.TrackedArray}) = false ArrayInterface.fast_scalar_indexing(::Type{<:ReverseDiff.TrackedArray}) = false function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal,N}) where {N} if length(x) > 1 - reduce(vcat,x) + return reshape(reduce(vcat,x), size(x)) else - reduce(vcat,[x[1],x[1]])[1:1] + return reduce(vcat,[x[1],x[1]])[1:1] end end From f3f07b657aad3309b2cf74c408dfbe7c6e493aff Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 7 Mar 2024 12:24:36 -0500 Subject: [PATCH 34/88] Remove pre 1.9 code --- Project.toml | 2 -- ext/ArrayInterfaceBandedMatricesExt.jl | 15 ++++----------- ext/ArrayInterfaceBlockBandedMatricesExt.jl | 17 ++++------------- ext/ArrayInterfaceCUDAExt.jl | 13 +++---------- ext/ArrayInterfaceGPUArraysCoreExt.jl | 16 ++++------------ ext/ArrayInterfaceReverseDiffExt.jl | 15 +++++---------- ext/ArrayInterfaceStaticArraysCoreExt.jl | 12 +++--------- ext/ArrayInterfaceTrackerExt.jl | 9 ++------- src/ArrayInterface.jl | 14 -------------- 9 files changed, 25 insertions(+), 88 deletions(-) diff --git a/Project.toml b/Project.toml index 48f462d4..12ad530b 100644 --- a/Project.toml +++ b/Project.toml @@ -5,7 +5,6 @@ version = "7.8.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Requires = "ae029012-a4dd-5104-9daa-d747884805df" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" @@ -30,7 +29,6 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" LinearAlgebra = "1.10" -Requires = "1" SparseArrays = "1.10" SuiteSparse = "1.10" julia = "1.10" diff --git a/ext/ArrayInterfaceBandedMatricesExt.jl b/ext/ArrayInterfaceBandedMatricesExt.jl index a3b8ca67..fcd0fb7b 100644 --- a/ext/ArrayInterfaceBandedMatricesExt.jl +++ b/ext/ArrayInterfaceBandedMatricesExt.jl @@ -1,16 +1,9 @@ module ArrayInterfaceBandedMatricesExt -if isdefined(Base, :get_extension) - using ArrayInterface - using ArrayInterface: BandedMatrixIndex - using BandedMatrices - using LinearAlgebra -else - using ..ArrayInterface - using ..ArrayInterface: BandedMatrixIndex - using ..BandedMatrices - using ..LinearAlgebra -end +using ArrayInterface +using ArrayInterface: BandedMatrixIndex +using BandedMatrices +using LinearAlgebra const TransOrAdjBandedMatrix = Union{ Adjoint{T, <:BandedMatrix{T}}, diff --git a/ext/ArrayInterfaceBlockBandedMatricesExt.jl b/ext/ArrayInterfaceBlockBandedMatricesExt.jl index f6636213..e4e7bbae 100644 --- a/ext/ArrayInterfaceBlockBandedMatricesExt.jl +++ b/ext/ArrayInterfaceBlockBandedMatricesExt.jl @@ -1,18 +1,9 @@ module ArrayInterfaceBlockBandedMatricesExt - - -if isdefined(Base, :get_extension) - using ArrayInterface - using ArrayInterface: BandedMatrixIndex - using BlockBandedMatrices - using BlockBandedMatrices.BlockArrays -else - using ..ArrayInterface - using ..ArrayInterface: BandedMatrixIndex - using ..BlockBandedMatrices - using ..BlockBandedMatrices.BlockArrays -end +using ArrayInterface +using ArrayInterface: BandedMatrixIndex +using BlockBandedMatrices +using BlockBandedMatrices.BlockArrays struct BlockBandedMatrixIndex <: ArrayInterface.MatrixIndex count::Int diff --git a/ext/ArrayInterfaceCUDAExt.jl b/ext/ArrayInterfaceCUDAExt.jl index f5d2a950..ae4477d3 100644 --- a/ext/ArrayInterfaceCUDAExt.jl +++ b/ext/ArrayInterfaceCUDAExt.jl @@ -1,16 +1,9 @@ module ArrayInterfaceCUDAExt using ArrayInterface - -if isdefined(Base, :get_extension) - using CUDA - using CUDA.CUSOLVER - using LinearAlgebra -else - using ..CUDA - using ..CUDA.CUSOLVER - using ..LinearAlgebra -end +using CUDA +using CUDA.CUSOLVER +using LinearAlgebra function ArrayInterface.lu_instance(A::CuMatrix{T}) where {T} if VERSION >= v"1.8-" diff --git a/ext/ArrayInterfaceGPUArraysCoreExt.jl b/ext/ArrayInterfaceGPUArraysCoreExt.jl index 40d0fc1a..79bbf606 100644 --- a/ext/ArrayInterfaceGPUArraysCoreExt.jl +++ b/ext/ArrayInterfaceGPUArraysCoreExt.jl @@ -1,17 +1,9 @@ module ArrayInterfaceGPUArraysCoreExt - -if isdefined(Base, :get_extension) - using Adapt - using ArrayInterface - using LinearAlgebra: lu - import GPUArraysCore -else - using Adapt # Will cause problems for relocatability. - using ..ArrayInterface - using ..LinearAlgebra: lu - import ..GPUArraysCore -end +using Adapt +using ArrayInterface +using LinearAlgebra: lu +import GPUArraysCore ArrayInterface.fast_scalar_indexing(::Type{<:GPUArraysCore.AbstractGPUArray}) = false @inline ArrayInterface.allowed_getindex(x::GPUArraysCore.AbstractGPUArray, i...) = GPUArraysCore.@allowscalar(x[i...]) diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl index c303398b..ed544e48 100644 --- a/ext/ArrayInterfaceReverseDiffExt.jl +++ b/ext/ArrayInterfaceReverseDiffExt.jl @@ -1,22 +1,17 @@ module ArrayInterfaceReverseDiffExt -if isdefined(Base, :get_extension) - using ArrayInterface - import ReverseDiff -else - using ..ArrayInterface - import ..ReverseDiff -end +using ArrayInterface +import ReverseDiff ArrayInterface.ismutable(::Type{<:ReverseDiff.TrackedArray}) = false ArrayInterface.ismutable(T::Type{<:ReverseDiff.TrackedReal}) = false ArrayInterface.can_setindex(::Type{<:ReverseDiff.TrackedArray}) = false ArrayInterface.fast_scalar_indexing(::Type{<:ReverseDiff.TrackedArray}) = false -function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal,N}) where {N} +function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal, N}) where {N} if length(x) > 1 - return reshape(reduce(vcat,x), size(x)) + return reshape(reduce(vcat, x), size(x)) else - return reduce(vcat,[x[1],x[1]])[1:1] + return reduce(vcat,[x[1], x[1]])[1:1] end end diff --git a/ext/ArrayInterfaceStaticArraysCoreExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl index c7b14279..acf06adf 100644 --- a/ext/ArrayInterfaceStaticArraysCoreExt.jl +++ b/ext/ArrayInterfaceStaticArraysCoreExt.jl @@ -1,14 +1,8 @@ module ArrayInterfaceStaticArraysCoreExt -if isdefined(Base, :get_extension) - import ArrayInterface - using LinearAlgebra - import StaticArraysCore -else - import ..ArrayInterface - using ..LinearAlgebra - import ..StaticArraysCore -end +import ArrayInterface +using LinearAlgebra +import StaticArraysCore function ArrayInterface.undefmatrix(::StaticArraysCore.MArray{S, T, N, L}) where {S, T, N, L} return StaticArraysCore.MMatrix{L, L, T, L*L}(undef) diff --git a/ext/ArrayInterfaceTrackerExt.jl b/ext/ArrayInterfaceTrackerExt.jl index 4bb10c39..d2d4e2ce 100644 --- a/ext/ArrayInterfaceTrackerExt.jl +++ b/ext/ArrayInterfaceTrackerExt.jl @@ -1,12 +1,7 @@ module ArrayInterfaceTrackerExt -if isdefined(Base, :get_extension) - using ArrayInterface - import Tracker -else - using ..ArrayInterface - import ..Tracker -end +using ArrayInterface +import Tracker ArrayInterface.ismutable(::Type{<:Tracker.TrackedArray}) = false ArrayInterface.ismutable(T::Type{<:Tracker.TrackedReal}) = false diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 3804c5c7..0ce3faa6 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1000,18 +1000,4 @@ ensures_sorted(@nospecialize( T::Type{<:AbstractRange})) = true ensures_sorted(T::Type) = is_forwarding_wrapper(T) ? ensures_sorted(parent_type(T)) : false ensures_sorted(@nospecialize(x)) = ensures_sorted(typeof(x)) -## Extensions - -import Requires -@static if !isdefined(Base, :get_extension) - function __init__() - Requires.@require BandedMatrices = "aae01518-5342-5314-be14-df237901396f" begin include("../ext/ArrayInterfaceBandedMatricesExt.jl") end - Requires.@require BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" begin include("../ext/ArrayInterfaceBlockBandedMatricesExt.jl") end - Requires.@require GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" begin include("../ext/ArrayInterfaceGPUArraysCoreExt.jl") end - Requires.@require StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" begin include("../ext/ArrayInterfaceStaticArraysCoreExt.jl") end - Requires.@require CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" begin include("../ext/ArrayInterfaceCUDAExt.jl") end - Requires.@require Tracker="9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" begin include("../ext/ArrayInterfaceTrackerExt.jl") end - end -end - end # module From 061c0c979fb2e368442291a194ca58891cc4fb85 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sun, 10 Mar 2024 20:22:58 -0400 Subject: [PATCH 35/88] Add can_setindex for ChainRules OneElement --- Project.toml | 7 +++++-- ext/ArrayInterfaceChainRulesExt.jl | 8 ++++++++ test/chainrules.jl | 6 ++++++ test/runtests.jl | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 ext/ArrayInterfaceChainRulesExt.jl create mode 100644 test/chainrules.jl diff --git a/Project.toml b/Project.toml index 12ad530b..a751d7d4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.8.1" +version = "7.9.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -12,6 +12,7 @@ SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" @@ -21,6 +22,7 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" ArrayInterfaceBandedMatricesExt = "BandedMatrices" ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" ArrayInterfaceCUDAExt = "CUDA" +ArrayInterfaceChainRulesExt = "ChainRules" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceReverseDiffExt = "ReverseDiff" ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" @@ -38,6 +40,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" @@ -51,4 +54,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [targets] -test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff"] +test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff", "ChainRules"] diff --git a/ext/ArrayInterfaceChainRulesExt.jl b/ext/ArrayInterfaceChainRulesExt.jl new file mode 100644 index 00000000..0a91bbb3 --- /dev/null +++ b/ext/ArrayInterfaceChainRulesExt.jl @@ -0,0 +1,8 @@ +module ArrayInterfaceChainRulesExt + +using ArrayInterface +using ChainRules: OneElement + +ArrayInterface.can_setindex(::Type{<:OneElement}) = false + +end \ No newline at end of file diff --git a/test/chainrules.jl b/test/chainrules.jl new file mode 100644 index 00000000..df47b2ff --- /dev/null +++ b/test/chainrules.jl @@ -0,0 +1,6 @@ +using ArrayInterface, ChainRules, Test + +x = ChainRules.OneElement(3.0, (3, 3), (1:4, 1:4)) + +@test !ArrayInterface.can_setindex(x) +@test !ArrayInterface.can_setindex(typeof(x)) diff --git a/test/runtests.jl b/test/runtests.jl index bedb7693..7999dbec 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,6 +15,7 @@ end @time @safetestset "Core" begin include("core.jl") end @time @safetestset "AD Integration" begin include("ad.jl") end @time @safetestset "StaticArraysCore" begin include("staticarrayscore.jl") end + @time @safetestset "ChainRules" begin include("chainrules.jl") end end if GROUP == "GPU" From 10d99f367914b737fa0ec43b512ca42b918c5951 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 19 Apr 2024 12:48:31 -0400 Subject: [PATCH 36/88] Add CUDSS extension for LU factorization instances --- Project.toml | 2 ++ ext/ArrayInterfaceCUDSSExt.jl | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 ext/ArrayInterfaceCUDSSExt.jl diff --git a/Project.toml b/Project.toml index a751d7d4..6ac7ff25 100644 --- a/Project.toml +++ b/Project.toml @@ -12,6 +12,7 @@ SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e" ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" @@ -22,6 +23,7 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" ArrayInterfaceBandedMatricesExt = "BandedMatrices" ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" ArrayInterfaceCUDAExt = "CUDA" +ArrayInterfaceCUDSSExt = "CUDSS" ArrayInterfaceChainRulesExt = "ChainRules" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceReverseDiffExt = "ReverseDiff" diff --git a/ext/ArrayInterfaceCUDSSExt.jl b/ext/ArrayInterfaceCUDSSExt.jl new file mode 100644 index 00000000..01fb2395 --- /dev/null +++ b/ext/ArrayInterfaceCUDSSExt.jl @@ -0,0 +1,17 @@ +module ArrayInterfaceCUDSSExt + +using ArrayInterface +using CUDSS + +function ArrayInterface.lu_instance(A::CUDSS.CuSparseMatrixCSR) + ArrayInterface.LinearAlgebra.checksquare(A) + fact = CudssSolver(A, "G", 'F') + T = eltype(A) + n = size(A,1) + x = CudssMatrix(T, n) + b = CudssMatrix(T, n) + cudss("analysis", fact, x, b) + fact +end + +end From 1e2c83d5a3f259e1576117af890dcf7a5ce6f620 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 19 Apr 2024 12:48:54 -0400 Subject: [PATCH 37/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6ac7ff25..e66aaa6d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.9.0" +version = "7.10.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 2d834a1fb4bf55a3b2f58ba1da96d6c768bd86f7 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:01 +0000 Subject: [PATCH 38/88] CompatHelper: add new compat entry for StaticArraysCore in [weakdeps] at version 1, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..753967dd 100644 --- a/Project.toml +++ b/Project.toml @@ -34,6 +34,7 @@ ArrayInterfaceTrackerExt = "Tracker" Adapt = "4" LinearAlgebra = "1.10" SparseArrays = "1.10" +StaticArraysCore = "1" SuiteSparse = "1.10" julia = "1.10" From cda5d4f0d66e78c108ebb91a467c049f2452f092 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:05 +0000 Subject: [PATCH 39/88] CompatHelper: add new compat entry for GPUArraysCore in [weakdeps] at version 0.1, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..5a2baf3d 100644 --- a/Project.toml +++ b/Project.toml @@ -32,6 +32,7 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" +GPUArraysCore = "0.1" LinearAlgebra = "1.10" SparseArrays = "1.10" SuiteSparse = "1.10" From f4dbab657e2f432708ab7b8a82cae2906cda17c0 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:08 +0000 Subject: [PATCH 40/88] CompatHelper: add new compat entry for BlockBandedMatrices in [weakdeps] at version 0.13, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..e7f776ba 100644 --- a/Project.toml +++ b/Project.toml @@ -32,6 +32,7 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" +BlockBandedMatrices = "0.13" LinearAlgebra = "1.10" SparseArrays = "1.10" SuiteSparse = "1.10" From 9c1b75441480b913922bf98ccfbf16646ba28733 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:10 +0000 Subject: [PATCH 41/88] CompatHelper: add new compat entry for ChainRules in [weakdeps] at version 1, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..cbecab45 100644 --- a/Project.toml +++ b/Project.toml @@ -32,6 +32,7 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" +ChainRules = "1" LinearAlgebra = "1.10" SparseArrays = "1.10" SuiteSparse = "1.10" From f031f9523fe8231a257b2d606933e07e12c97f69 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:12 +0000 Subject: [PATCH 42/88] CompatHelper: add new compat entry for BandedMatrices in [weakdeps] at version 1, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..aa9d01db 100644 --- a/Project.toml +++ b/Project.toml @@ -32,6 +32,7 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" +BandedMatrices = "1" LinearAlgebra = "1.10" SparseArrays = "1.10" SuiteSparse = "1.10" From a15455a5fd9b5ac313f5494435e5e7d0a500745f Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:14 +0000 Subject: [PATCH 43/88] CompatHelper: add new compat entry for ReverseDiff in [weakdeps] at version 1, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..fe05eb5e 100644 --- a/Project.toml +++ b/Project.toml @@ -33,6 +33,7 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" LinearAlgebra = "1.10" +ReverseDiff = "1" SparseArrays = "1.10" SuiteSparse = "1.10" julia = "1.10" From b697273cd7f973b40c2b8b087a9aec7f5997fe55 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:17 +0000 Subject: [PATCH 44/88] CompatHelper: add new compat entry for CUDSS in [weakdeps] at version 0.2, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..94bd3ddd 100644 --- a/Project.toml +++ b/Project.toml @@ -32,6 +32,7 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" +CUDSS = "0.2" LinearAlgebra = "1.10" SparseArrays = "1.10" SuiteSparse = "1.10" From b645d892ad266aa084fa96c1df66a8d6525ed78f Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:19 +0000 Subject: [PATCH 45/88] CompatHelper: add new compat entry for Tracker in [weakdeps] at version 0.2, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..f226bb08 100644 --- a/Project.toml +++ b/Project.toml @@ -35,6 +35,7 @@ Adapt = "4" LinearAlgebra = "1.10" SparseArrays = "1.10" SuiteSparse = "1.10" +Tracker = "0.2" julia = "1.10" [extras] From c8f61da2e020c29ebcde8ee0b33fcb2ef5cef326 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 24 May 2024 18:12:21 +0000 Subject: [PATCH 46/88] CompatHelper: add new compat entry for CUDA in [weakdeps] at version 5, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index e66aaa6d..30e4de54 100644 --- a/Project.toml +++ b/Project.toml @@ -32,6 +32,7 @@ ArrayInterfaceTrackerExt = "Tracker" [compat] Adapt = "4" +CUDA = "5" LinearAlgebra = "1.10" SparseArrays = "1.10" SuiteSparse = "1.10" From 4007fbbfb0d968fabeb45982a3151380cdbf12fc Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Mon, 3 Jun 2024 19:41:38 +0530 Subject: [PATCH 47/88] chore: add has_trivial_array_convert --- src/ArrayInterface.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 0ce3faa6..2766c44e 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1000,4 +1000,8 @@ ensures_sorted(@nospecialize( T::Type{<:AbstractRange})) = true ensures_sorted(T::Type) = is_forwarding_wrapper(T) ? ensures_sorted(parent_type(T)) : false ensures_sorted(@nospecialize(x)) = ensures_sorted(typeof(x)) +function has_trivial_array_contstructor(::Type{T}, args...) as T + applicable(T, args...) +end + end # module From 487f961fd0971597b81cc5e08e1dde7cc196802e Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Mon, 3 Jun 2024 20:14:08 +0530 Subject: [PATCH 48/88] chore: typo --- src/ArrayInterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 2766c44e..31d9156d 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1000,7 +1000,7 @@ ensures_sorted(@nospecialize( T::Type{<:AbstractRange})) = true ensures_sorted(T::Type) = is_forwarding_wrapper(T) ? ensures_sorted(parent_type(T)) : false ensures_sorted(@nospecialize(x)) = ensures_sorted(typeof(x)) -function has_trivial_array_contstructor(::Type{T}, args...) as T +function has_trivial_array_contstructor(::Type{T}, args...) where T applicable(T, args...) end From 9ff91bb4aedcd3494e66f362b6169a0ad8c86e3d Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Mon, 3 Jun 2024 20:17:04 +0530 Subject: [PATCH 49/88] build: add ComponentArrays to test deps --- Project.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 812ea014..dc2db46b 100644 --- a/Project.toml +++ b/Project.toml @@ -52,6 +52,7 @@ BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" +ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" @@ -65,4 +66,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [targets] -test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff", "ChainRules"] +test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff", "ChainRules", "ComponentArrays"] From 90fc3513b061a81fd1137824feb85c6a2ed27c04 Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Tue, 4 Jun 2024 14:16:46 +0530 Subject: [PATCH 50/88] chore: check convert method instead --- src/ArrayInterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 31d9156d..2b80b611 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1001,7 +1001,7 @@ ensures_sorted(T::Type) = is_forwarding_wrapper(T) ? ensures_sorted(parent_type( ensures_sorted(@nospecialize(x)) = ensures_sorted(typeof(x)) function has_trivial_array_contstructor(::Type{T}, args...) where T - applicable(T, args...) + applicable(convert, T, args...) end end # module From c1ce4c19b36e7c20a625f1a0e395958eae20453c Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Tue, 4 Jun 2024 14:20:15 +0530 Subject: [PATCH 51/88] test: add CA test --- src/ArrayInterface.jl | 2 +- test/core.jl | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 2b80b611..ed1ea127 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1000,7 +1000,7 @@ ensures_sorted(@nospecialize( T::Type{<:AbstractRange})) = true ensures_sorted(T::Type) = is_forwarding_wrapper(T) ? ensures_sorted(parent_type(T)) : false ensures_sorted(@nospecialize(x)) = ensures_sorted(typeof(x)) -function has_trivial_array_contstructor(::Type{T}, args...) where T +function has_trivial_array_constructor(::Type{T}, args...) where T applicable(convert, T, args...) end diff --git a/test/core.jl b/test/core.jl index 5208393f..003f7b5d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2,6 +2,7 @@ using ArrayInterface using ArrayInterface: zeromatrix, undefmatrix import ArrayInterface: has_sparsestruct, findstructralnz, fast_scalar_indexing, lu_instance, parent_type, zeromatrix +using ComponentArrays using LinearAlgebra using Random using SparseArrays @@ -289,4 +290,9 @@ end end @test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A))) end -end \ No newline at end of file +end + +@testset "Array conversion" begin + cv = ComponentVector((x = rand(3), y = rand(3))) + @test ArrayInterface.has_trivial_array_constructor(typeof(cv), rand(6)) +end From 72370e19982815e907eec8a0366116f99c9cb182 Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Tue, 4 Jun 2024 14:34:30 +0530 Subject: [PATCH 52/88] docs: add docstrings for array conversion --- src/ArrayInterface.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index ed1ea127..ddf661f6 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1000,6 +1000,26 @@ ensures_sorted(@nospecialize( T::Type{<:AbstractRange})) = true ensures_sorted(T::Type) = is_forwarding_wrapper(T) ? ensures_sorted(parent_type(T)) : false ensures_sorted(@nospecialize(x)) = ensures_sorted(typeof(x)) +""" + has_trivial_array_constructor(T::Type, args...) -> Bool + +Returns `true` if an object of type `T` can be constructed using the collection of `args` + +Note: This checks if a compatible `convert` methood exists between `T` and `args` + +# Examples: + +```julia +julia> ca = ComponentVector((x = rand(3), y = rand(4),)) +ComponentVector{Float64}(x = [0.6549137106381634, 0.37555505280294565, 0.8521039568665254], y = [0.40314196291239024, 0.35484725607638834, 0.6580528978034597, 0.10055508457632167]) + +julia> ArrayInterface.has_trivial_array_constructor(typeof(ca), ones(6)) +true + +julia> ArrayInterface.has_trivial_array_constructor(typeof(cv), (x = rand(6),)) +false +``` +""" function has_trivial_array_constructor(::Type{T}, args...) where T applicable(convert, T, args...) end From d35771b223de45007b6588584fa4cda9f55ec9aa Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 5 Jun 2024 07:51:15 -0400 Subject: [PATCH 53/88] Fix tests --- test/blockbandedmatrices.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/blockbandedmatrices.jl b/test/blockbandedmatrices.jl index 9f29716d..2a34a852 100644 --- a/test/blockbandedmatrices.jl +++ b/test/blockbandedmatrices.jl @@ -1,6 +1,7 @@ using ArrayInterface using BlockBandedMatrices +using FillArrays using Test BB=BlockBandedMatrix(Ones(10,10),[1,2,3,4],[4,3,2,1],(1,0)) From 65ce9d4f0238c49ef8b5ce1507b52b055d4e1cf8 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 5 Jun 2024 07:55:57 -0400 Subject: [PATCH 54/88] Update Project.toml --- Project.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 812ea014..a26a4435 100644 --- a/Project.toml +++ b/Project.toml @@ -52,6 +52,7 @@ BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" +FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" @@ -65,4 +66,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [targets] -test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff", "ChainRules"] +test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff", "ChainRules", "FillArrays"] From ecabd8e6dd11a50ed7740f041312ea117708ec60 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 5 Jun 2024 08:46:53 -0400 Subject: [PATCH 55/88] Update blockbandedmatrices.jl --- test/blockbandedmatrices.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/blockbandedmatrices.jl b/test/blockbandedmatrices.jl index 2a34a852..5f158868 100644 --- a/test/blockbandedmatrices.jl +++ b/test/blockbandedmatrices.jl @@ -5,8 +5,8 @@ using FillArrays using Test BB=BlockBandedMatrix(Ones(10,10),[1,2,3,4],[4,3,2,1],(1,0)) -BB[Block(1,1)].=[1 2 3 4] -BB[Block(2,1)].=[5 6 7 8;9 10 11 12] +BB[BlockBandedMatrices.Block(1,1)].=[1 2 3 4] +BB[BlockBandedMatrices.Block(2,1)].=[5 6 7 8;9 10 11 12] rowind,colind=ArrayInterface.findstructralnz(BB) @test [BB[rowind[i],colind[i]] for i in 1:length(rowind)]== [1,5,9,2,6,10,3,7,11,4,8,12, From 889f895ef026cc0cfbd67ba70acd1bc0b3ab8af6 Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Wed, 5 Jun 2024 19:54:30 +0530 Subject: [PATCH 56/88] docs: add docstring to generated docs --- docs/src/conversions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/conversions.md b/docs/src/conversions.md index 51f9b1a3..46d7fecd 100644 --- a/docs/src/conversions.md +++ b/docs/src/conversions.md @@ -12,4 +12,5 @@ ArrayInterface.aos_to_soa ArrayInterface.promote_eltype ArrayInterface.restructure ArrayInterface.safevec -``` \ No newline at end of file +ArrayInterface.has_trivial_array_constructor +``` From edc2dcece9bb67733657bbfbc77204f507493345 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 5 Jun 2024 10:47:58 -0400 Subject: [PATCH 57/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3a445d27..80bf493f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.10.0" +version = "7.11.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 0b7fb62c424f218828115802b123b4cb1659b53a Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Thu, 4 Jul 2024 04:11:29 +0000 Subject: [PATCH 58/88] CompatHelper: bump compat for CUDSS in [weakdeps] to 0.3, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 80bf493f..4075635e 100644 --- a/Project.toml +++ b/Project.toml @@ -35,7 +35,7 @@ Adapt = "4" BandedMatrices = "1" BlockBandedMatrices = "0.13" CUDA = "5" -CUDSS = "0.2" +CUDSS = "0.2, 0.3" ChainRules = "1" GPUArraysCore = "0.1" LinearAlgebra = "1.10" From fdac74cb764953872e76e94c5068ba341997bd33 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 5 Jul 2024 06:57:00 -0400 Subject: [PATCH 59/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4075635e..eb0c12e5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.11.0" +version = "7.12.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From ac0b31a069cc11067209bc94cad1702955f3af50 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 5 Jul 2024 06:57:17 -0400 Subject: [PATCH 60/88] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 812b7753..9d20d7bc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://docs.sciml.ai/ArrayInterface/stable/) [![CI](https://github.com/JuliaArrays/ArrayInterface.jl/workflows/CI/badge.svg)](https://github.com/JuliaArrays/ArrayInterface.jl/actions?query=workflow%3ACI) -[![CI (Julia nightly)](https://github.com/JuliaArrays/ArrayInterface.jl/workflows/CI%20(Julia%20nightly)/badge.svg)](https://github.com/JuliaArrays/ArrayInterface.jl/actions?query=workflow%3A%22CI+%28Julia+nightly%29%22) [![Build status](https://badge.buildkite.com/a2db252d92478e1d7196ee7454004efdfb6ab59496cbac91a2.svg?branch=master)](https://buildkite.com/julialang/arrayinterface-dot-jl) [![codecov](https://codecov.io/gh/JuliaArrays/ArrayInterface.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaArrays/ArrayInterface.jl) From cb614b5fddf71da121668ddbe35a68fb93c2d5a8 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 27 Jul 2024 12:39:15 -0400 Subject: [PATCH 61/88] Make sparsearrays an ext Fixes https://github.com/JuliaArrays/ArrayInterface.jl/issues/447 --- Project.toml | 5 ++-- ext/ArrayInterfaceSparseArraysExt.jl | 38 ++++++++++++++++++++++++++++ src/ArrayInterface.jl | 34 ++----------------------- 3 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 ext/ArrayInterfaceSparseArraysExt.jl diff --git a/Project.toml b/Project.toml index eb0c12e5..1a192674 100644 --- a/Project.toml +++ b/Project.toml @@ -5,8 +5,6 @@ version = "7.12.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [weakdeps] BandedMatrices = "aae01518-5342-5314-be14-df237901396f" @@ -16,6 +14,7 @@ CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e" ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" +SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" @@ -27,6 +26,7 @@ ArrayInterfaceCUDSSExt = "CUDSS" ArrayInterfaceChainRulesExt = "ChainRules" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceReverseDiffExt = "ReverseDiff" +ArrayInterfaceSparseArraysExt = "SparseArrays" ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" ArrayInterfaceTrackerExt = "Tracker" @@ -42,7 +42,6 @@ LinearAlgebra = "1.10" ReverseDiff = "1" SparseArrays = "1.10" StaticArraysCore = "1" -SuiteSparse = "1.10" Tracker = "0.2" julia = "1.10" diff --git a/ext/ArrayInterfaceSparseArraysExt.jl b/ext/ArrayInterfaceSparseArraysExt.jl new file mode 100644 index 00000000..61fff69d --- /dev/null +++ b/ext/ArrayInterfaceSparseArraysExt.jl @@ -0,0 +1,38 @@ +module ArrayInterfaceSparseArraysExt + +import ArrayInterface: buffer, has_sparsestruct, issingular, findstructralnz, bunchkaufman_instance, DEFAULT_CHOLESKY_PIVOT, cholesky_instance, ldlt_instance, lu_instance, qr_instance +using ArrayInterface.LinearAlgebra +using SparseArrays + +buffer(x::SparseMatrixCSC) = getfield(x, :nzval) +buffer(x::SparseVector) = getfield(x, :nzval) +has_sparsestruct(::Type{<:SparseMatrixCSC}) = true +issingular(A::AbstractSparseMatrix) = !issuccess(lu(A, check = false)) + +function findstructralnz(x::SparseMatrixCSC) + rowind, colind, _ = findnz(x) + (rowind, colind) +end + +function bunchkaufman_instance(A::SparseMatrixCSC) + bunchkaufman(sparse(similar(A, 1, 1)), check = false) +end + +function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) + cholesky(sparse(similar(A, 1, 1)), check = false) +end + +function ldlt_instance(A::SparseMatrixCSC) + ldlt(sparse(similar(A, 1, 1)), check=false) +end + +# Could be optimized but this should work for any real case. +function lu_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT) + lu(sparse(rand(1,1))) +end + +function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT) + qr(sparse(rand(1,1))) +end + +end diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index ddf661f6..b9e56d01 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1,8 +1,6 @@ module ArrayInterface using LinearAlgebra -using SparseArrays -using SuiteSparse @static if isdefined(Base, Symbol("@assume_effects")) using Base: @assume_effects @@ -121,8 +119,6 @@ Return the buffer data that `x` points to. Unlike `parent(x::AbstractArray)`, `b may not return another array type. """ buffer(x) = parent(x) -buffer(x::SparseMatrixCSC) = getfield(x, :nzval) -buffer(x::SparseVector) = getfield(x, :nzval) buffer(@nospecialize x::Union{Base.Slice, Base.IdentityUnitRange}) = getfield(x, :indices) """ @@ -308,7 +304,6 @@ Determine whether `findstructralnz` accepts the parameter `x`. has_sparsestruct(x) = has_sparsestruct(typeof(x)) has_sparsestruct(::Type) = false has_sparsestruct(::Type{<:AbstractArray}) = false -has_sparsestruct(::Type{<:SparseMatrixCSC}) = true has_sparsestruct(::Type{<:Diagonal}) = true has_sparsestruct(::Type{<:Bidiagonal}) = true has_sparsestruct(::Type{<:Tridiagonal}) = true @@ -320,7 +315,6 @@ has_sparsestruct(::Type{<:SymTridiagonal}) = true Determine whether a given abstract matrix is singular. """ issingular(A::AbstractMatrix) = issingular(Matrix(A)) -issingular(A::AbstractSparseMatrix) = !issuccess(lu(A, check = false)) issingular(A::Matrix) = !issuccess(lu(A, check = false)) issingular(A::UniformScaling) = A.λ == 0 issingular(A::Diagonal) = any(iszero, A.diag) @@ -359,11 +353,6 @@ function findstructralnz(x::Union{Tridiagonal, SymTridiagonal}) (rowind, colind) end -function findstructralnz(x::SparseMatrixCSC) - rowind, colind, _ = findnz(x) - (rowind, colind) -end - abstract type ColoringAlgorithm end """ @@ -403,9 +392,6 @@ cheaply. function bunchkaufman_instance(A::Matrix{T}) where T return bunchkaufman(similar(A, 0, 0), check = false) end -function bunchkaufman_instance(A::SparseMatrixCSC) - bunchkaufman(sparse(similar(A, 1, 1)), check = false) -end """ bunchkaufman_instance(a::Number) -> a @@ -429,14 +415,10 @@ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorizati Returns an instance of the Cholesky factorization object with the correct type cheaply. """ -function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} +function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T} return cholesky(similar(A, 0, 0), pivot, check = false) end -function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) - cholesky(sparse(similar(A, 1, 1)), check = false) -end - """ cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) -> a @@ -458,14 +440,10 @@ ldlt_instance(A) -> ldlt_factorization_instance Returns an instance of the LDLT factorization object with the correct type cheaply. """ -function ldlt_instance(A::Matrix{T}) where {T} +function ldlt_instance(A::Matrix{T}) where {T} return ldlt_instance(SymTridiagonal(similar(A, 0, 0))) end -function ldlt_instance(A::SparseMatrixCSC) - ldlt(sparse(similar(A, 1, 1)), check=false) -end - function ldlt_instance(A::SymTridiagonal{T,V}) where {T,V} return LinearAlgebra.LDLt{T,SymTridiagonal{T,V}}(A) end @@ -498,9 +476,6 @@ function lu_instance(A::Matrix{T}) where {T} info = zero(LinearAlgebra.BlasInt) return LU{luT}(similar(A, 0, 0), ipiv, info) end -function lu_instance(jac_prototype::SparseMatrixCSC) - SuiteSparse.UMFPACK.UmfpackLU(similar(jac_prototype, 1, 1)) -end function lu_instance(A::Symmetric{T}) where {T} noUnitT = typeof(zero(T)) @@ -557,11 +532,6 @@ function qr_instance(A::Matrix{BigFloat},pivot = DEFAULT_CHOLESKY_PIVOT) LinearAlgebra.QR(zeros(BigFloat,0,0),zeros(BigFloat,0)) end -# Could be optimized but this should work for any real case. -function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT) - qr(sparse(rand(1,1))) -end - """ qr_instance(a::Number) -> a From 0187aa673768bc8438aee17e863c815782e3497d Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 27 Jul 2024 18:08:30 -0400 Subject: [PATCH 62/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1a192674..ee1afdfc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.12.0" +version = "7.13.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 50e2776941258a465f33cd4e0c8b589fbdf74009 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Sat, 27 Jul 2024 23:12:25 -0400 Subject: [PATCH 63/88] Make extension depend on StaticArrays and optimize lu_instance --- Project.toml | 6 ++-- ext/ArrayInterfaceStaticArraysCoreExt.jl | 30 ---------------- ext/ArrayInterfaceStaticArraysExt.jl | 34 +++++++++++++++++++ test/runtests.jl | 2 +- test/{staticarrayscore.jl => staticarrays.jl} | 0 5 files changed, 38 insertions(+), 34 deletions(-) delete mode 100644 ext/ArrayInterfaceStaticArraysCoreExt.jl create mode 100644 ext/ArrayInterfaceStaticArraysExt.jl rename test/{staticarrayscore.jl => staticarrays.jl} (100%) diff --git a/Project.toml b/Project.toml index ee1afdfc..8065d156 100644 --- a/Project.toml +++ b/Project.toml @@ -15,7 +15,7 @@ ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [extensions] @@ -27,7 +27,7 @@ ArrayInterfaceChainRulesExt = "ChainRules" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceReverseDiffExt = "ReverseDiff" ArrayInterfaceSparseArraysExt = "SparseArrays" -ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" +ArrayInterfaceStaticArraysExt = "StaticArrays" ArrayInterfaceTrackerExt = "Tracker" [compat] @@ -66,4 +66,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [targets] -test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff", "ChainRules", "FillArrays", "ComponentArrays"] +test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "Tracker", "ReverseDiff", "ChainRules", "FillArrays", "ComponentArrays"] diff --git a/ext/ArrayInterfaceStaticArraysCoreExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl deleted file mode 100644 index acf06adf..00000000 --- a/ext/ArrayInterfaceStaticArraysCoreExt.jl +++ /dev/null @@ -1,30 +0,0 @@ -module ArrayInterfaceStaticArraysCoreExt - -import ArrayInterface -using LinearAlgebra -import StaticArraysCore - -function ArrayInterface.undefmatrix(::StaticArraysCore.MArray{S, T, N, L}) where {S, T, N, L} - return StaticArraysCore.MMatrix{L, L, T, L*L}(undef) -end -# SArray doesn't have an undef constructor and is going to be small enough that this is fine. -function ArrayInterface.undefmatrix(s::StaticArraysCore.SArray) - v = vec(s) - return v.*v' -end - -ArrayInterface.ismutable(::Type{<:StaticArraysCore.StaticArray}) = false -ArrayInterface.ismutable(::Type{<:StaticArraysCore.MArray}) = true -ArrayInterface.ismutable(::Type{<:StaticArraysCore.SizedArray}) = true - -ArrayInterface.can_setindex(::Type{<:StaticArraysCore.StaticArray}) = false -ArrayInterface.can_setindex(::Type{<:StaticArraysCore.MArray}) = true -ArrayInterface.buffer(A::Union{StaticArraysCore.SArray,StaticArraysCore.MArray}) = getfield(A, :data) - -function ArrayInterface.lu_instance(_A::StaticArraysCore.StaticMatrix{N,N}) where {N} - lu(one(_A)) -end - -ArrayInterface.restructure(x::StaticArraysCore.SArray{S}, y) where {S} = StaticArraysCore.SArray{S}(y) - -end diff --git a/ext/ArrayInterfaceStaticArraysExt.jl b/ext/ArrayInterfaceStaticArraysExt.jl new file mode 100644 index 00000000..80e8e4a7 --- /dev/null +++ b/ext/ArrayInterfaceStaticArraysExt.jl @@ -0,0 +1,34 @@ +module ArrayInterfaceStaticArraysExt + +import ArrayInterface +using LinearAlgebra +import StaticArrays: SArray, SMatrix, SVector, StaticMatrix, StaticArray, SizedArray, MArray, MMatrix, LU + +function ArrayInterface.undefmatrix(::MArray{S, T, N, L}) where {S, T, N, L} + return MMatrix{L, L, T, L*L}(undef) +end +# SArray doesn't have an undef constructor and is going to be small enough that this is fine. +function ArrayInterface.undefmatrix(s::SArray) + v = vec(s) + return v.*v' +end + +ArrayInterface.ismutable(::Type{<:StaticArray}) = false +ArrayInterface.ismutable(::Type{<:MArray}) = true +ArrayInterface.ismutable(::Type{<:SizedArray}) = true + +ArrayInterface.can_setindex(::Type{<:StaticArray}) = false +ArrayInterface.can_setindex(::Type{<:MArray}) = true +ArrayInterface.buffer(A::Union{SArray, MArray}) = getfield(A, :data) + +function ArrayInterface.lu_instance(A::SMatrix{N,N}) where {N} + LU(LowerTriangular(A), UpperTriangular(A), SVector{N}(1:N)) +end + +function ArrayInterface.lu_instance(A::StaticMatrix{N,N}) where {N} + lu(one(A)) +end + +ArrayInterface.restructure(x::SArray{S}, y) where {S} = SArray{S}(y) + +end diff --git a/test/runtests.jl b/test/runtests.jl index 7999dbec..8a5d7b36 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -14,7 +14,7 @@ end @time @safetestset "BlockBandedMatrices" begin include("blockbandedmatrices.jl") end @time @safetestset "Core" begin include("core.jl") end @time @safetestset "AD Integration" begin include("ad.jl") end - @time @safetestset "StaticArraysCore" begin include("staticarrayscore.jl") end + @time @safetestset "StaticArrays" begin include("staticarrays.jl") end @time @safetestset "ChainRules" begin include("chainrules.jl") end end diff --git a/test/staticarrayscore.jl b/test/staticarrays.jl similarity index 100% rename from test/staticarrayscore.jl rename to test/staticarrays.jl From 61bfe08dcf94b98102a3da1816be826e782aa229 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 27 Jul 2024 23:21:46 -0400 Subject: [PATCH 64/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 8065d156..47f9c0be 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.13.0" +version = "7.14.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From f7464cada12ed2f3a160b7842a5ae61116c8d0f2 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Sun, 28 Jul 2024 04:13:12 +0000 Subject: [PATCH 65/88] CompatHelper: add new compat entry for StaticArrays in [weakdeps] at version 1, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 47f9c0be..bd870bcf 100644 --- a/Project.toml +++ b/Project.toml @@ -41,6 +41,7 @@ GPUArraysCore = "0.1" LinearAlgebra = "1.10" ReverseDiff = "1" SparseArrays = "1.10" +StaticArrays = "1" StaticArraysCore = "1" Tracker = "0.2" julia = "1.10" From 83e7dd9a3855a48fefbac45e7c5867ea81af7e8d Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 30 Jul 2024 11:17:15 -0400 Subject: [PATCH 66/88] revert #449 --- Project.toml | 4 ++-- ...taticArraysExt.jl => ArrayInterfaceStaticArraysCoreExt.jl} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename ext/{ArrayInterfaceStaticArraysExt.jl => ArrayInterfaceStaticArraysCoreExt.jl} (86%) diff --git a/Project.toml b/Project.toml index 47f9c0be..f729089c 100644 --- a/Project.toml +++ b/Project.toml @@ -15,7 +15,7 @@ ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [extensions] @@ -27,7 +27,7 @@ ArrayInterfaceChainRulesExt = "ChainRules" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceReverseDiffExt = "ReverseDiff" ArrayInterfaceSparseArraysExt = "SparseArrays" -ArrayInterfaceStaticArraysExt = "StaticArrays" +ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" ArrayInterfaceTrackerExt = "Tracker" [compat] diff --git a/ext/ArrayInterfaceStaticArraysExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl similarity index 86% rename from ext/ArrayInterfaceStaticArraysExt.jl rename to ext/ArrayInterfaceStaticArraysCoreExt.jl index 80e8e4a7..774ecd8e 100644 --- a/ext/ArrayInterfaceStaticArraysExt.jl +++ b/ext/ArrayInterfaceStaticArraysCoreExt.jl @@ -1,8 +1,8 @@ -module ArrayInterfaceStaticArraysExt +module ArrayInterfaceStaticArraysCoreExt import ArrayInterface using LinearAlgebra -import StaticArrays: SArray, SMatrix, SVector, StaticMatrix, StaticArray, SizedArray, MArray, MMatrix, LU +import StaticArraysCore: SArray, SMatrix, SVector, StaticMatrix, StaticArray, SizedArray, MArray, MMatrix function ArrayInterface.undefmatrix(::MArray{S, T, N, L}) where {S, T, N, L} return MMatrix{L, L, T, L*L}(undef) From e52026743c02e2be17e121f17f72366b90e83187 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 30 Jul 2024 11:30:19 -0400 Subject: [PATCH 67/88] delete optimization --- ext/ArrayInterfaceStaticArraysCoreExt.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ext/ArrayInterfaceStaticArraysCoreExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl index 774ecd8e..7b33dc80 100644 --- a/ext/ArrayInterfaceStaticArraysCoreExt.jl +++ b/ext/ArrayInterfaceStaticArraysCoreExt.jl @@ -21,10 +21,6 @@ ArrayInterface.can_setindex(::Type{<:StaticArray}) = false ArrayInterface.can_setindex(::Type{<:MArray}) = true ArrayInterface.buffer(A::Union{SArray, MArray}) = getfield(A, :data) -function ArrayInterface.lu_instance(A::SMatrix{N,N}) where {N} - LU(LowerTriangular(A), UpperTriangular(A), SVector{N}(1:N)) -end - function ArrayInterface.lu_instance(A::StaticMatrix{N,N}) where {N} lu(one(A)) end From e895785a1a12703347af8f19a0111a569e8e4a3b Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 Jul 2024 18:11:17 -0400 Subject: [PATCH 68/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index f729089c..c70312fb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.14.0" +version = "7.15.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From feba85594ec9c5e8d88be20811751e1ce5983174 Mon Sep 17 00:00:00 2001 From: homocomputeris <7422433+homocomputeris@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:56:58 +0000 Subject: [PATCH 69/88] Remove empty section in conversions.md --- docs/src/conversions.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/src/conversions.md b/docs/src/conversions.md index 46d7fecd..129e3746 100644 --- a/docs/src/conversions.md +++ b/docs/src/conversions.md @@ -3,8 +3,6 @@ The following ArrayInterface functions extend Julia's Array interface for how arrays can be converted to different forms. -## - ## Conversion Functions ```@docs From 0acd84746f909ba7cbecc779d905c7e5b3886a47 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 31 Aug 2024 20:58:55 -0400 Subject: [PATCH 70/88] Fix Tracker with restructure --- ext/ArrayInterfaceTrackerExt.jl | 7 +++++++ test/ad.jl | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/ext/ArrayInterfaceTrackerExt.jl b/ext/ArrayInterfaceTrackerExt.jl index d2d4e2ce..6d26f410 100644 --- a/ext/ArrayInterfaceTrackerExt.jl +++ b/ext/ArrayInterfaceTrackerExt.jl @@ -9,4 +9,11 @@ ArrayInterface.can_setindex(::Type{<:Tracker.TrackedArray}) = false ArrayInterface.fast_scalar_indexing(::Type{<:Tracker.TrackedArray}) = false ArrayInterface.aos_to_soa(x::AbstractArray{<:Tracker.TrackedReal,N}) where {N} = Tracker.collect(x) +function ArrayInterface.restructure(x::Array, y::TrackedArray) + reshape(y, Base.size(x)...) +end +function ArrayInterface.restructure(x::Array, y::Array{<:Tracker.TrackedReal}) + reshape(y, Base.size(x)...) +end + end # module diff --git a/test/ad.jl b/test/ad.jl index 7c29c8dd..c1a207b7 100644 --- a/test/ad.jl +++ b/test/ad.jl @@ -18,3 +18,12 @@ x = Tracker.TrackedArray([4.0,4.0]) x = reduce(vcat, Tracker.TrackedArray([4.0,4.0])) x = [x[1],x[2]] @test ArrayInterface.aos_to_soa(x) isa Tracker.TrackedArray + +x = rand(4) +y = Tracker.TrackedReal.(rand(2,2)) +@test ArrayInterface.restructure(x, y) isa Array +@test eltype(ArrayInterface.restructure(x, y)) <: Tracker.TrackedReal +@test size(ArrayInterface.restructure(x, y)) == (4,) +y = Tracker.TrackedArray(rand(2,2)) +@test ArrayInterface.restructure(x, y) isa Tracker.TrackedArray +@test size(ArrayInterface.restructure(x, y)) == (4,) \ No newline at end of file From c3acb74ea96540abec7644a7d8bd9c26d0dae644 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 31 Aug 2024 21:00:10 -0400 Subject: [PATCH 71/88] Namespace --- ext/ArrayInterfaceTrackerExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ArrayInterfaceTrackerExt.jl b/ext/ArrayInterfaceTrackerExt.jl index 6d26f410..5723d9f1 100644 --- a/ext/ArrayInterfaceTrackerExt.jl +++ b/ext/ArrayInterfaceTrackerExt.jl @@ -9,7 +9,7 @@ ArrayInterface.can_setindex(::Type{<:Tracker.TrackedArray}) = false ArrayInterface.fast_scalar_indexing(::Type{<:Tracker.TrackedArray}) = false ArrayInterface.aos_to_soa(x::AbstractArray{<:Tracker.TrackedReal,N}) where {N} = Tracker.collect(x) -function ArrayInterface.restructure(x::Array, y::TrackedArray) +function ArrayInterface.restructure(x::Array, y::Tracker.TrackedArray) reshape(y, Base.size(x)...) end function ArrayInterface.restructure(x::Array, y::Array{<:Tracker.TrackedReal}) From 00cc8c6e747c0ec2bf7fa53147e4fff241bee0ee Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 31 Aug 2024 21:28:13 -0400 Subject: [PATCH 72/88] Add ReverseDiff --- ext/ArrayInterfaceReverseDiffExt.jl | 4 ++++ test/ad.jl | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl index ed544e48..37176824 100644 --- a/ext/ArrayInterfaceReverseDiffExt.jl +++ b/ext/ArrayInterfaceReverseDiffExt.jl @@ -15,4 +15,8 @@ function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal, N end end +function ArrayInterface.restructure(x::Array, y::ReverseDiff.TrackedArray) + reshape(y, Base.size(x)...) +end + end # module diff --git a/test/ad.jl b/test/ad.jl index c1a207b7..bc3c3dd8 100644 --- a/test/ad.jl +++ b/test/ad.jl @@ -26,4 +26,13 @@ y = Tracker.TrackedReal.(rand(2,2)) @test size(ArrayInterface.restructure(x, y)) == (4,) y = Tracker.TrackedArray(rand(2,2)) @test ArrayInterface.restructure(x, y) isa Tracker.TrackedArray -@test size(ArrayInterface.restructure(x, y)) == (4,) \ No newline at end of file +@test size(ArrayInterface.restructure(x, y)) == (4,) + +x = rand(4) +y = ReverseDiff.track(rand(2,2)) +@test ArrayInterface.restructure(x, y) isa ReverseDiff.TrackedArray +@test size(ArrayInterface.restructure(x, y)) == (4,) +y = ReverseDiff.track.(rand(2,2)) +@test ArrayInterface.restructure(x, y) isa Array +@test eltype(ArrayInterface.restructure(x, y)) <: ReverseDiff.TrackedReal +@test size(ArrayInterface.restructure(x, y)) == (4,) From 2e2b81bfb53e9e9fc41f26b927fb980afcbfa9f5 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 31 Aug 2024 21:31:49 -0400 Subject: [PATCH 73/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c70312fb..dcd5306c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.15.0" +version = "7.16.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 845c62d8fbc37150efd12bd145b8aaa45988e466 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Thu, 17 Oct 2024 15:10:30 +0000 Subject: [PATCH 74/88] CompatHelper: bump compat for GPUArraysCore in [weakdeps] to 0.2, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index dcd5306c..52cce972 100644 --- a/Project.toml +++ b/Project.toml @@ -37,7 +37,7 @@ BlockBandedMatrices = "0.13" CUDA = "5" CUDSS = "0.2, 0.3" ChainRules = "1" -GPUArraysCore = "0.1" +GPUArraysCore = "0.1, 0.2" LinearAlgebra = "1.10" ReverseDiff = "1" SparseArrays = "1.10" From 4db06d7a01118c4c2323de6bcdfa85a716150843 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Thu, 17 Oct 2024 15:10:31 +0000 Subject: [PATCH 75/88] CompatHelper: bump compat for GPUArraysCore in [weakdeps] to 0.2, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index dcd5306c..52cce972 100644 --- a/Project.toml +++ b/Project.toml @@ -37,7 +37,7 @@ BlockBandedMatrices = "0.13" CUDA = "5" CUDSS = "0.2, 0.3" ChainRules = "1" -GPUArraysCore = "0.1" +GPUArraysCore = "0.1, 0.2" LinearAlgebra = "1.10" ReverseDiff = "1" SparseArrays = "1.10" From c7216c3241346d550f3ac2a4fe0211161e268ffe Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Fri, 8 Nov 2024 19:38:44 +0530 Subject: [PATCH 76/88] feat: add adjoint for `ArrayInterface.restructure` --- Project.toml | 7 ++++++- ext/ArrayInterfaceChainRulesCoreExt.jl | 22 ++++++++++++++++++++++ test/chainrules.jl | 7 +++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 ext/ArrayInterfaceChainRulesCoreExt.jl diff --git a/Project.toml b/Project.toml index 52cce972..c1b74442 100644 --- a/Project.toml +++ b/Project.toml @@ -12,6 +12,7 @@ BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e" ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" +ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" @@ -24,6 +25,7 @@ ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" ArrayInterfaceCUDAExt = "CUDA" ArrayInterfaceCUDSSExt = "CUDSS" ArrayInterfaceChainRulesExt = "ChainRules" +ArrayInterfaceChainRulesCoreExt = "ChainRulesCore" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceReverseDiffExt = "ReverseDiff" ArrayInterfaceSparseArraysExt = "SparseArrays" @@ -37,6 +39,8 @@ BlockBandedMatrices = "0.13" CUDA = "5" CUDSS = "0.2, 0.3" ChainRules = "1" +ChainRulesCore = "1" +ChainRulesTestUtils = "1" GPUArraysCore = "0.1, 0.2" LinearAlgebra = "1.10" ReverseDiff = "1" @@ -51,6 +55,7 @@ BandedMatrices = "aae01518-5342-5314-be14-df237901396f" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" +ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a" ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" @@ -66,4 +71,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [targets] -test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "Tracker", "ReverseDiff", "ChainRules", "FillArrays", "ComponentArrays"] +test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "Tracker", "ReverseDiff", "ChainRules", "FillArrays", "ComponentArrays", "ChainRulesTestUtils"] diff --git a/ext/ArrayInterfaceChainRulesCoreExt.jl b/ext/ArrayInterfaceChainRulesCoreExt.jl new file mode 100644 index 00000000..6cf4c406 --- /dev/null +++ b/ext/ArrayInterfaceChainRulesCoreExt.jl @@ -0,0 +1,22 @@ +module ArrayInterfaceChainRulesCoreExt + +import ArrayInterface +import ChainRulesCore +import ChainRulesCore: unthunk, NoTangent, ZeroTangent, ProjectTo, @thunk + +function ChainRulesCore.rrule(::typeof(ArrayInterface.restructure), target, src) + projectT = ProjectTo(target) + function restructure_pullback(dt) + dt = unthunk(dt) + + f̄ = NoTangent() + t̄ = ZeroTangent() + s̄ = @thunk(projectT(ArrayInterface.restructure(src, dt))) + + f̄, t̄, s̄ + end + + return ArrayInterface.restructure(target, src), restructure_pullback +end + +end diff --git a/test/chainrules.jl b/test/chainrules.jl index df47b2ff..759a55be 100644 --- a/test/chainrules.jl +++ b/test/chainrules.jl @@ -1,6 +1,13 @@ using ArrayInterface, ChainRules, Test +using ComponentArrays, ChainRulesTestUtils, StaticArrays x = ChainRules.OneElement(3.0, (3, 3), (1:4, 1:4)) @test !ArrayInterface.can_setindex(x) @test !ArrayInterface.can_setindex(typeof(x)) + +arr = ComponentArray(a = 1.0, b = [2.0, 3.0], c = (; a = 4.0, b = 5.0), d = SVector{2}(6.0, 7.0)) +b = zeros(length(arr)) + +ChainRulesTestUtils.test_rrule(ArrayInterface.restructure, arr, b) +ChainRulesTestUtils.test_rrule(ArrayInterface.restructure, b, arr) From baa807ed42fd323a627287cc510afe8718bb3850 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 8 Nov 2024 13:48:50 -0100 Subject: [PATCH 77/88] Update Project.toml --- Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Project.toml b/Project.toml index a9804a7b..c1b74442 100644 --- a/Project.toml +++ b/Project.toml @@ -45,7 +45,6 @@ GPUArraysCore = "0.1, 0.2" LinearAlgebra = "1.10" ReverseDiff = "1" SparseArrays = "1.10" -StaticArrays = "1" StaticArraysCore = "1" Tracker = "0.2" julia = "1.10" From 264310459ebeba024b0c3e6e49d8e62b4290d88f Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 8 Nov 2024 13:49:15 -0100 Subject: [PATCH 78/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c1b74442..3dfc4a97 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.16.0" +version = "7.17.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From d6f380a882c736ed7f82936c37e657fd36bffdc6 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sun, 17 Nov 2024 20:39:14 -0500 Subject: [PATCH 79/88] fix: aos_to_soa for all singleton dims --- ext/ArrayInterfaceReverseDiffExt.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl index 37176824..3a000def 100644 --- a/ext/ArrayInterfaceReverseDiffExt.jl +++ b/ext/ArrayInterfaceReverseDiffExt.jl @@ -8,11 +8,8 @@ ArrayInterface.ismutable(T::Type{<:ReverseDiff.TrackedReal}) = false ArrayInterface.can_setindex(::Type{<:ReverseDiff.TrackedArray}) = false ArrayInterface.fast_scalar_indexing(::Type{<:ReverseDiff.TrackedArray}) = false function ArrayInterface.aos_to_soa(x::AbstractArray{<:ReverseDiff.TrackedReal, N}) where {N} - if length(x) > 1 - return reshape(reduce(vcat, x), size(x)) - else - return reduce(vcat,[x[1], x[1]])[1:1] - end + y = length(x) > 1 ? reduce(vcat, x) : reduce(vcat, [x[1], x[1]])[1:1] + return reshape(y, size(x)) end function ArrayInterface.restructure(x::Array, y::ReverseDiff.TrackedArray) From 1d931145ffb5765b82cb3021edb4b408866db8c2 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sun, 17 Nov 2024 20:41:59 -0500 Subject: [PATCH 80/88] test: singleton dims AoS --- test/ad.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/ad.jl b/test/ad.jl index bc3c3dd8..3c61873e 100644 --- a/test/ad.jl +++ b/test/ad.jl @@ -1,6 +1,9 @@ using ArrayInterface, ReverseDiff, Tracker, Test x = ReverseDiff.track([4.0]) @test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray +x = reshape([ReverseDiff.track(rand(1, 1, 1))[1]], 1, 1, 1) +@test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray +@test ndims(ArrayInterface.aos_to_soa(x)) == 3 x = reduce(vcat, ReverseDiff.track([4.0,4.0])) @test ArrayInterface.aos_to_soa(x) isa ReverseDiff.TrackedArray x = [ReverseDiff.track([4.0])[1]] From 251535f2083c01f1483c2ee2bea85bfe5f53e238 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 18 Nov 2024 05:59:54 -0100 Subject: [PATCH 81/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3dfc4a97..df828b51 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.17.0" +version = "7.17.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From b4d4ab4357121f49653a9aa5496738b30c04bd4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 07:18:26 +0000 Subject: [PATCH 82/88] Bump codecov/codecov-action from 4 to 5 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/Documentation.yml | 2 +- .github/workflows/Downstream.yml | 2 +- .github/workflows/ci.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index d26b9dd0..d7285850 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -23,6 +23,6 @@ jobs: DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key run: julia --project=docs/ --code-coverage=user docs/make.jl - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v5 with: file: lcov.info diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index 34b8e1bc..1af21937 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -61,6 +61,6 @@ jobs: exit(0) # Exit immediately, as a success end - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v5 with: file: lcov.info diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9333ffb..cb9fe51a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,6 @@ jobs: env: GROUP: ${{ matrix.group }} - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v5 with: file: lcov.info \ No newline at end of file From 007399d0627f57b04192ddc76557e7c19f0bdc54 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Thu, 12 Dec 2024 21:11:10 +0000 Subject: [PATCH 83/88] CompatHelper: bump compat for CUDSS in [weakdeps] to 0.4, (keep existing compat) --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index df828b51..ab82ddfa 100644 --- a/Project.toml +++ b/Project.toml @@ -24,8 +24,8 @@ ArrayInterfaceBandedMatricesExt = "BandedMatrices" ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" ArrayInterfaceCUDAExt = "CUDA" ArrayInterfaceCUDSSExt = "CUDSS" -ArrayInterfaceChainRulesExt = "ChainRules" ArrayInterfaceChainRulesCoreExt = "ChainRulesCore" +ArrayInterfaceChainRulesExt = "ChainRules" ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" ArrayInterfaceReverseDiffExt = "ReverseDiff" ArrayInterfaceSparseArraysExt = "SparseArrays" @@ -37,7 +37,7 @@ Adapt = "4" BandedMatrices = "1" BlockBandedMatrices = "0.13" CUDA = "5" -CUDSS = "0.2, 0.3" +CUDSS = "0.2, 0.3, 0.4" ChainRules = "1" ChainRulesCore = "1" ChainRulesTestUtils = "1" From 9e3936c9e3a76845a53971dd18e099898123df85 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 13 Dec 2024 12:28:53 -0100 Subject: [PATCH 84/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ab82ddfa..2d09c1c7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.17.1" +version = "7.18.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 9d38d864d9fafa3ca290439f400da3823681bf20 Mon Sep 17 00:00:00 2001 From: Jan Philipp Thiele <54978337+jpthiele@users.noreply.github.com> Date: Tue, 6 May 2025 15:04:38 +0200 Subject: [PATCH 85/88] Fully qualify constructor extension Extending constructors without module specification can lead to undefined behaviour in case of name clashes. This is fixed by fully qualifying `ArrayInterface.BandedMatrixIndex` when it is extended in the banded matrix ext. --- ext/ArrayInterfaceBandedMatricesExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ArrayInterfaceBandedMatricesExt.jl b/ext/ArrayInterfaceBandedMatricesExt.jl index fcd0fb7b..5eaeb0cd 100644 --- a/ext/ArrayInterfaceBandedMatricesExt.jl +++ b/ext/ArrayInterfaceBandedMatricesExt.jl @@ -46,7 +46,7 @@ function _bandsize(bandind, rowsize, colsize) end end -function BandedMatrixIndex(rowsize, colsize, lowerbandwidth, upperbandwidth, isrow) +function ArrayInterface.BandedMatrixIndex(rowsize, colsize, lowerbandwidth, upperbandwidth, isrow) upperbandwidth > -lowerbandwidth || throw(ErrorException("Invalid Bandwidths")) bandinds = upperbandwidth:-1:(-lowerbandwidth) bandsizes = [_bandsize(band, rowsize, colsize) for band in bandinds] From 147b8a22fd32478dd11d6aa568c2d7c2b70145f5 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 6 May 2025 10:16:33 -0400 Subject: [PATCH 86/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2d09c1c7..6537a4b7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.18.0" +version = "7.18.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From e2b9740618045f1506d663101aa385cce286468e Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 12 May 2025 16:12:16 +0000 Subject: [PATCH 87/88] Fix SparseMatrixCSC with alternative Integer types Fixes https://github.com/SciML/NonlinearSolve.jl/issues/599 --- ext/ArrayInterfaceSparseArraysExt.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/ArrayInterfaceSparseArraysExt.jl b/ext/ArrayInterfaceSparseArraysExt.jl index 61fff69d..9f0e06b4 100644 --- a/ext/ArrayInterfaceSparseArraysExt.jl +++ b/ext/ArrayInterfaceSparseArraysExt.jl @@ -14,25 +14,25 @@ function findstructralnz(x::SparseMatrixCSC) (rowind, colind) end -function bunchkaufman_instance(A::SparseMatrixCSC) - bunchkaufman(sparse(similar(A, 1, 1)), check = false) +function bunchkaufman_instance(A::SparseMatrixCSC{Tv, Ti}) where {Tv, Ti} + bunchkaufman(SparseMatrixCSC{Tv, Ti}(similar(A, 1, 1)), check = false) end -function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) - cholesky(sparse(similar(A, 1, 1)), check = false) +function cholesky_instance(A::Union{SparseMatrixCSC{Tv, Ti},Symmetric{<:Number,<:SparseMatrixCSC{Tv, Ti}}}, pivot = DEFAULT_CHOLESKY_PIVOT) where {Tv, Ti} + cholesky(SparseMatrixCSC{Tv, Ti}(similar(A, 1, 1)), check = false) end -function ldlt_instance(A::SparseMatrixCSC) - ldlt(sparse(similar(A, 1, 1)), check=false) +function ldlt_instance(A::SparseMatrixCSC{Tv, Ti}) where {Tv, Ti} + ldlt(SparseMatrixCSC{Tv, Ti}(similar(A, 1, 1)), check=false) end # Could be optimized but this should work for any real case. -function lu_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT) - lu(sparse(rand(1,1))) +function lu_instance(jac_prototype::SparseMatrixCSC{Tv, Ti}, pivot = DEFAULT_CHOLESKY_PIVOT) where {Tv, Ti} + lu(SparseMatrixCSC{Tv, Ti}(rand(1,1))) end -function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT) - qr(sparse(rand(1,1))) +function qr_instance(jac_prototype::SparseMatrixCSC{Tv, Ti}, pivot = DEFAULT_CHOLESKY_PIVOT) where {Tv, Ti} + qr(SparseMatrixCSC{Tv, Ti}(rand(1,1))) end end From bda054847db8d5ba9df047639bd8a88a75136091 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 12 May 2025 16:27:39 +0000 Subject: [PATCH 88/88] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6537a4b7..c4a079e5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.18.1" +version = "7.19.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"