From 197dc2040563a0dd8cc33234557274691beded0d Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 8 Mar 2023 08:54:04 -0500 Subject: [PATCH 001/124] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 35da51ed4..812b7753d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # ArrayInterface.jl -[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaarrays.github.io/ArrayInterface.jl/stable) -[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaarrays.github.io/ArrayInterface.jl/dev) +[![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) From bb310529379b2903ebf1ea1662e863e3093466e4 Mon Sep 17 00:00:00 2001 From: spaette <111918424+spaette@users.noreply.github.com> Date: Sun, 12 Mar 2023 19:11:26 -0500 Subject: [PATCH 002/124] typo (#390) --- src/ArrayInterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index b4532e33d..e912b0002 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -638,7 +638,7 @@ Subtypes of `ArrayIndex` represent series of transformations for a provided inde buffer which is typically accomplished with square brackets (e.g., `buffer[index[inds...]]`). The only behavior that is required of a subtype of `ArrayIndex` is the ability to transform individual index elements (i.e. not collections). This does not guarantee bounds checking or -the ability to iterate (although additional functionallity may be provided for specific +the ability to iterate (although additional functionality may be provided for specific types). """ abstract type ArrayIndex{N} end From b4f1173a5d7e26debf55fa7400911b48c14b5a28 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 13 Mar 2023 14:01:22 +0100 Subject: [PATCH 003/124] enable dependabot for GitHub actions --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..700707ced --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From 55aca859347a6a7fe30535ddc4ff24dcb981f23b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:17:26 +0000 Subject: [PATCH 004/124] Bump codecov/codecov-action from 1 to 3 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 3. - [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/v1...v3) --- 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 b3537d8c5..5b65319f1 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@v1 + - uses: codecov/codecov-action@v3 with: file: lcov.info diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index a5badac7a..ad21d3ae9 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@v1 + - uses: codecov/codecov-action@v3 with: file: lcov.info diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b893be44..91a4f5272 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,6 @@ jobs: env: GROUP: ${{ matrix.group }} - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3 with: file: lcov.info \ No newline at end of file From 4579de544d6884c7bcb8ab2fdf0d07adcba03d63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:17:28 +0000 Subject: [PATCH 005/124] Bump actions/cache from 1 to 3 Bumps [actions/cache](https://github.com/actions/cache) from 1 to 3. - [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/v1...v3) --- 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 2b893be44..e2ca4437c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} - - uses: actions/cache@v1 + - uses: actions/cache@v3 env: cache-name: cache-artifacts with: From 22fb69624f5bd2a810b2cdb5e0f667d7b73fc2e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:17:35 +0000 Subject: [PATCH 006/124] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [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/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/Documentation.yml | 2 +- .github/workflows/Downstream.yml | 4 ++-- .github/workflows/ci.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index b3537d8c5..b7e77f9ff 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@v2 + - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@latest with: version: '1' diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index a5badac7a..bbc2cd886 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@v2 + - uses: actions/checkout@v3 - 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@v2 + uses: actions/checkout@v3 with: repository: ${{ matrix.package.user }}/${{ matrix.package.repo }} path: downstream diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b893be44..1af8e259f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - '1' - '1.6' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} From d260aa8340a853641b485c6b3efc0eeb3d597273 Mon Sep 17 00:00:00 2001 From: Daniel Karrasch Date: Sat, 18 Mar 2023 19:52:16 +0100 Subject: [PATCH 007/124] Remove unsused import This is not used anywhere in this file. --- src/ArrayInterface.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index e912b0002..6fea2d50f 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -1,7 +1,6 @@ module ArrayInterface using LinearAlgebra -using LinearAlgebra: AbstractTriangular using SparseArrays using SuiteSparse From 8d99db8b8e0749483fcf71c781eb80eba3ec8334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 21 Mar 2023 10:20:07 +0100 Subject: [PATCH 008/124] Typo fix Warning -> warning --- src/ArrayInterface.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 6fea2d50f..613591033 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -189,7 +189,7 @@ each index. See also [`SetIndex!`](@ref) -!!! Warning +!!! warning Passing `false` as `check` may result in incorrect results/crashes/corruption for out-of-bounds indices, similar to inappropriate use of `@inbounds`. The user is responsible for ensuring this is correctly used. @@ -226,7 +226,7 @@ is `true`, requiring bounds checking for each index. See also [`GetIndex`](@ref) -!!! Warning +!!! warning Passing `false` as `check` may result in incorrect results/crashes/corruption for out-of-bounds indices, similar to inappropriate use of `@inbounds`. The user is responsible for ensuring this is correctly used. From 537c93cae23eddb5885321110583660d6334836b Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 24 Mar 2023 15:00:00 -0400 Subject: [PATCH 009/124] complete the linear algebra instance functions for the main factorizations --- Project.toml | 2 +- docs/src/index.md | 7 +++--- src/ArrayInterface.jl | 53 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 3b169a384..8252f3a42 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.2.1" +version = "7.3.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/docs/src/index.md b/docs/src/index.md index f1a155f4f..ae1e84ab2 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -17,7 +17,7 @@ ArrayInterface.jl uses extension packages in order to add support for popular li ## StaticArrayInterface.jl -If one is looking for an interface which includes functionality for statically-computed values, see +If one is looking for an interface which includes functionality for statically-computed values, see [StaticArrayInterface.jl](https://github.com/JuliaArrays/StaticArrayInterface.jl). This was separated from ArrayInterface.jl because it includes a lot of functionality that does not give substantive improvements to the interface, and is likely to be deprecated in the near future as the compiler matures to automate a lot of its optimizations. @@ -44,7 +44,6 @@ ArrayInterface.isstructured ArrayInterface.has_sparsestruct ArrayInterface.ndims_index ArrayInterface.ndims_shape - ``` ### Functions @@ -57,6 +56,8 @@ ArrayInterface.buffer ArrayInterface.findstructralnz ArrayInterface.flatten_tuples ArrayInterface.lu_instance +ArrayInterface.qr_instance +ArrayInterface.svd_instance ArrayInterface.map_tuple_type ArrayInterface.matrix_colors ArrayInterface.issingular @@ -74,4 +75,4 @@ ArrayInterface.undefmatrix ArrayInterface.ArrayIndex ArrayInterface.GetIndex ArrayInterface.SetIndex! -``` \ No newline at end of file +``` diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 613591033..0043c2e34 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -482,6 +482,59 @@ Returns the number. """ lu_instance(a::Any) = lu(a, check = false) +""" + qr_instance(A) -> qr_factorization_instance + +Returns an instance of the QR factorization object with the correct type +cheaply. +""" +function qr_instance(A::Matrix{T}) where {T} + LinearAlgebra.QRCompactWYQ(zeros(T,0,0),zeros(T,0,0)) +end + +# Could be optimized but this should work for any real case. +function qr_instance(jac_prototype::SparseMatrixCSC) + qr(sparse(rand(1,1)), check = false) +end + +""" + qr_instance(a::Number) -> a + +Returns the number. +""" +qr_instance(a::Number) = a + +""" + qr_instance(a::Any) -> qr(a, check=false) + +Returns the number. +""" +qr_instance(a::Any) = qr(a, check = false) + +""" + svd_instance(A) -> qr_factorization_instance + +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)) +end + +""" + svd_instance(a::Number) -> a + +Returns the number. +""" +svd_instance(a::Number) = a + +""" + svd_instance(a::Any) -> qr(a, check=false) + +Returns the number. +""" +svd_instance(a::Any) = svd(a, check = false) + """ safevec(v) From 0894dba8b7b2d707cc5bc340b9b66fe9656e8ec9 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 24 Mar 2023 17:06:56 -0400 Subject: [PATCH 010/124] no check on QR SVD --- Project.toml | 2 +- src/ArrayInterface.jl | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 8252f3a42..537a38b53 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.3.0" +version = "7.3.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 0043c2e34..c959d7830 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -494,7 +494,7 @@ end # Could be optimized but this should work for any real case. function qr_instance(jac_prototype::SparseMatrixCSC) - qr(sparse(rand(1,1)), check = false) + qr(sparse(rand(1,1))) end """ @@ -505,11 +505,11 @@ Returns the number. qr_instance(a::Number) = a """ - qr_instance(a::Any) -> qr(a, check=false) + qr_instance(a::Any) -> qr(a) Returns the number. """ -qr_instance(a::Any) = qr(a, check = false) +qr_instance(a::Any) = qr(a)# check = false) """ svd_instance(A) -> qr_factorization_instance @@ -529,11 +529,11 @@ Returns the number. svd_instance(a::Number) = a """ - svd_instance(a::Any) -> qr(a, check=false) + svd_instance(a::Any) -> svd(a) Returns the number. """ -svd_instance(a::Any) = svd(a, check = false) +svd_instance(a::Any) = svd(a) #check = false) """ safevec(v) From af3c6ee3f597d8e25e62eaad1a7ec62fffae855e Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sat, 25 Mar 2023 08:55:43 -0400 Subject: [PATCH 011/124] Expand the docs explanations --- docs/make.jl | 6 +++++ docs/src/conversions.md | 15 +++++++++++ docs/src/index.md | 57 +-------------------------------------- docs/src/indexing.md | 49 +++++++++++++++++++++++++++++++++ docs/src/linearalgebra.md | 41 ++++++++++++++++++++++++++++ docs/src/sparsearrays.md | 39 +++++++++++++++++++++++++++ docs/src/tuples.md | 8 ++++++ docs/src/wrapping.md | 16 +++++++++++ 8 files changed, 175 insertions(+), 56 deletions(-) create mode 100644 docs/src/conversions.md create mode 100644 docs/src/indexing.md create mode 100644 docs/src/linearalgebra.md create mode 100644 docs/src/sparsearrays.md create mode 100644 docs/src/tuples.md create mode 100644 docs/src/wrapping.md diff --git a/docs/make.jl b/docs/make.jl index a4569a116..573fe9fc1 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,6 +6,12 @@ makedocs(; sitename="ArrayInterface.jl", pages=[ "ArrayInterface.jl: An Extended Array Interface for Julia Generic Programming" => "index.md", + "indexing.md", + "conversions.md", + "linearalgebra.md", + "sparsearrays.md", + "tuples.md", + "wrapping.md", ] ) diff --git a/docs/src/conversions.md b/docs/src/conversions.md new file mode 100644 index 000000000..51f9b1a37 --- /dev/null +++ b/docs/src/conversions.md @@ -0,0 +1,15 @@ +# Julia's Extended Array Conversions Interface + +The following ArrayInterface functions extend Julia's Array interface for how arrays +can be converted to different forms. + +## + +## Conversion Functions + +```@docs +ArrayInterface.aos_to_soa +ArrayInterface.promote_eltype +ArrayInterface.restructure +ArrayInterface.safevec +``` \ No newline at end of file diff --git a/docs/src/index.md b/docs/src/index.md index ae1e84ab2..305c06dd8 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -20,59 +20,4 @@ ArrayInterface.jl uses extension packages in order to add support for popular li If one is looking for an interface which includes functionality for statically-computed values, see [StaticArrayInterface.jl](https://github.com/JuliaArrays/StaticArrayInterface.jl). This was separated from ArrayInterface.jl because it includes a lot of functionality that does not give substantive improvements -to the interface, and is likely to be deprecated in the near future as the compiler matures to automate a lot of its optimizations. - -## API - -### Traits - -```@docs -ArrayInterface.can_avx -ArrayInterface.can_change_size -ArrayInterface.can_setindex -ArrayInterface.device -ArrayInterface.defines_strides -ArrayInterface.ensures_all_unique -ArrayInterface.ensures_sorted -ArrayInterface.fast_matrix_colors -ArrayInterface.fast_scalar_indexing -ArrayInterface.indices_do_not_alias -ArrayInterface.instances_do_not_alias -ArrayInterface.is_forwarding_wrapper -ArrayInterface.ismutable -ArrayInterface.isstructured -ArrayInterface.has_sparsestruct -ArrayInterface.ndims_index -ArrayInterface.ndims_shape -``` - -### Functions - -```@docs -ArrayInterface.allowed_getindex -ArrayInterface.allowed_setindex! -ArrayInterface.aos_to_soa -ArrayInterface.buffer -ArrayInterface.findstructralnz -ArrayInterface.flatten_tuples -ArrayInterface.lu_instance -ArrayInterface.qr_instance -ArrayInterface.svd_instance -ArrayInterface.map_tuple_type -ArrayInterface.matrix_colors -ArrayInterface.issingular -ArrayInterface.parent_type -ArrayInterface.promote_eltype -ArrayInterface.restructure -ArrayInterface.safevec -ArrayInterface.zeromatrix -ArrayInterface.undefmatrix -``` - -### Types - -```@docs -ArrayInterface.ArrayIndex -ArrayInterface.GetIndex -ArrayInterface.SetIndex! -``` +to the interface, and is likely to be deprecated in the near future as the compiler matures to automate a lot of its optimizations. \ No newline at end of file diff --git a/docs/src/indexing.md b/docs/src/indexing.md new file mode 100644 index 000000000..ed1282e74 --- /dev/null +++ b/docs/src/indexing.md @@ -0,0 +1,49 @@ +# Julia's Extended Array Indexing Interface + +The following ArrayInterface functions extend Julia's Base LinearAlgebra interface +to improve the ability to write code for generic array types. + +## Indexing Traits + +The following traits allow for one to accurately determine the type of indexing allowed +on arrays in order to write optimal code for generic array types. + +```@docs +ArrayInterface.can_avx +ArrayInterface.can_change_size +ArrayInterface.can_setindex +ArrayInterface.fast_scalar_indexing +ArrayInterface.ismutable +ArrayInterface.ndims_index +ArrayInterface.ndims_shape +ArrayInterface.defines_strides +ArrayInterface.ensures_all_unique +ArrayInterface.ensures_sorted +ArrayInterface.indices_do_not_alias +ArrayInterface.instances_do_not_alias +ArrayInterface.device +``` + +## Allowed Indexing Functions + +These are generic functions for forced "allowed indexing". For example, with CUDA.jl's +CuArrays a mode can be enabled such that `allowscalar(false)` forces errors to be thrown +if a GPU array is scalar indexed. Instead of using the CUDA-specific `CUDA.@allowscalar` +on an operation, these functions allow for a general generic "allowed indexing" for all +array types. + +```@docs +ArrayInterface.allowed_getindex +ArrayInterface.allowed_setindex! +``` + +## Indexing Type Buffers + +The following indexing types allow for generically controlling bounds checking +and index translations. + +```@docs +ArrayInterface.ArrayIndex +ArrayInterface.GetIndex +ArrayInterface.SetIndex! +``` \ No newline at end of file diff --git a/docs/src/linearalgebra.md b/docs/src/linearalgebra.md new file mode 100644 index 000000000..def06b415 --- /dev/null +++ b/docs/src/linearalgebra.md @@ -0,0 +1,41 @@ +# Julia's Extended Linear Algebra Interface + +The following ArrayInterface functions extend Julia's Base LinearAlgebra interface +to improve the ability to do generic linear algebra. + +## Generic Matrix Constructors + +These functions allow for the construction of matrices from array information in a generic +way. It handles cases like how if `x` is a vector on the GPU, its associated matrix type +should also be GPU-based, and thus appropriately placed with zeros/undef values. + +```@docs +ArrayInterface.zeromatrix +ArrayInterface.undefmatrix +``` + +## Generic Matrix Functions + +These query allow for easily learning properties of a general matrix. + +```@docs +ArrayInterface.issingular +``` + +## Factorization Instance Functions + +These functions allow for generating the instance of a factorization's result without +running the full factorization. This thus allows for building types to hold the factorization +without having to perform expensive extra computations. + +```@docs +ArrayInterface.lu_instance +ArrayInterface.qr_instance +ArrayInterface.svd_instance +``` + +## Addtional Linear Algebra Interface Tools + +If dealing with general linear algebra, consider: + +- [LinearSolve.jl](https://github.com/SciML/LinearSolve.jl): An extended linear solving library with support for generic arrays. \ No newline at end of file diff --git a/docs/src/sparsearrays.md b/docs/src/sparsearrays.md new file mode 100644 index 000000000..97fc9ba00 --- /dev/null +++ b/docs/src/sparsearrays.md @@ -0,0 +1,39 @@ +# Julia's Extended Sparse Array Interface + +The following ArrayInterface functions extend Julia's Base LinearAlgebra interface +to improve the ability to do sparse linear algebra. + +## Sparse Indexing + +These routines allow for improving sparse iteration and indexing. + +```@docs +ArrayInterface.isstructured +ArrayInterface.findstructralnz +ArrayInterface.has_sparsestruct +``` + +## Matrix Coloring + +Many routines require calculating the coloring of a matrix, such as for sparse +differentation. The `matrix_colors` function is the high level function which +returns a color vector `Vector{Int}` with the column colors. This function +is overloaded for many special matrix types with analytical solutions for the +matrix colors. + +```@docs +ArrayInterface.fast_matrix_colors +ArrayInterface.matrix_colors +``` + +### General Matrix Colors + +For the general dispatch of `matrix_colors`, see [SparseDiffTools.jl](https://github.com/JuliaDiff/SparseDiffTools.jl) +for a full graph-based coloring algorithm which extends ArrayInterface. + +## Addtional Sparse Array Interface Tools + +If dealing with general sparse arrays, consider: + +- [SparseDiffTools.jl](https://github.com/JuliaDiff/SparseDiffTools.jl): A general set of tools for extending calculus libraries for sparse optimizations. +- [LinearSolve.jl](https://github.com/SciML/LinearSolve.jl): An extended linear solving library with support for generic sparse arrays. \ No newline at end of file diff --git a/docs/src/tuples.md b/docs/src/tuples.md new file mode 100644 index 000000000..4ae265578 --- /dev/null +++ b/docs/src/tuples.md @@ -0,0 +1,8 @@ +# Julia's Extended Tuple Interface + +The following ArrayInterface functions extend Julia's tuple interface. + +```@docs +ArrayInterface.flatten_tuples +ArrayInterface.map_tuple_type +``` \ No newline at end of file diff --git a/docs/src/wrapping.md b/docs/src/wrapping.md new file mode 100644 index 000000000..6d0ead1e1 --- /dev/null +++ b/docs/src/wrapping.md @@ -0,0 +1,16 @@ +# Julia's Array Wrapping Interface + +The following functions make it easier to handle array wrappers, such as `Adjoint`, which +can obscure an underlying array's properties under a layer of indirection. + +```@docs +ArrayInterface.is_forwarding_wrapper +ArrayInterface.buffer +ArrayInterface.parent_type +``` + +## Additional Array Wrapping Libraries + +If dealing with array wrappers, additionally consider: + +- [Adapt.jl](https://github.com/JuliaGPU/Adapt.jl): conversions for handling device (GPU) wrappers. \ No newline at end of file From ba77e1ef81879c743838a85d46867546a7bf97e9 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sat, 25 Mar 2023 09:07:00 -0400 Subject: [PATCH 012/124] Add Cholesky Instance --- src/ArrayInterface.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index c959d7830..43b77b0ce 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -440,6 +440,33 @@ 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] +""" +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 = LinearAlgebra.RowMaximum()) where {T} + return cholesky(similar(A, 0, 0), pivot, check = false) +end +function cholesky_instance(A::SparseMatrixCSC) + cholesky(sparse(similar(A, 1, 1)), check = false) +end + +""" +cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) -> a + +Returns the number. +""" +cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) = a + +""" +cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) + +Returns the number. +""" +cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) = cholesky(a, pivot, check = false) + """ lu_instance(A) -> lu_factorization_instance From de0eef5e2bef8a9b898c861a2d05c52beaa5a830 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sat, 25 Mar 2023 09:20:48 -0400 Subject: [PATCH 013/124] add the other linear solving instances --- docs/src/linearalgebra.md | 3 ++ src/ArrayInterface.jl | 67 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/docs/src/linearalgebra.md b/docs/src/linearalgebra.md index def06b415..e82ddd8c9 100644 --- a/docs/src/linearalgebra.md +++ b/docs/src/linearalgebra.md @@ -29,6 +29,9 @@ running the full factorization. This thus allows for building types to hold the without having to perform expensive extra computations. ```@docs +ArrayInterface.bunchkaufman_instance +ArrayInterface.cholesky_instance +ArrayInterface.ldlt_instance ArrayInterface.lu_instance ArrayInterface.qr_instance ArrayInterface.svd_instance diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 43b77b0ce..00dd753bc 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -440,6 +440,33 @@ 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 Cholesky 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 + +""" +bunchkaufman_instance(a::Number) -> a + +Returns the number. +""" +bunchkaufman_instance(a::Number) = a + +""" +bunchkaufman_instance(a::Any) -> cholesky(a, check=false) + +Returns the number. +""" +bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false) + """ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance @@ -463,10 +490,39 @@ cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) = a """ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) -Returns the number. +Slow fallback which gets the instance via factorization. Should get +specialized for new matrix types. """ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) = cholesky(a, pivot, check = false) +""" +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} + return ldlt(SymTridiagonal(similar(A, 0, 0)), check = false) +end +function ldlt_instance(A::SparseMatrixCSC) + ldlt(sparse(similar(A, 1, 1)), check = false) +end + +""" +ldlt_instance(a::Number) -> a + +Returns the number. +""" +ldlt_instance(a::Number) = a + +""" +ldlt_instance(a::Any) -> ldlt(a, check=false) + +Slow fallback which gets the instance via factorization. Should get +specialized for new matrix types. +""" +ldlt_instance(a::Any) = ldlt(a) + """ lu_instance(A) -> lu_factorization_instance @@ -505,7 +561,8 @@ lu_instance(a::Number) = a """ lu_instance(a::Any) -> lu(a, check=false) -Returns the number. +Slow fallback which gets the instance via factorization. Should get +specialized for new matrix types. """ lu_instance(a::Any) = lu(a, check = false) @@ -534,7 +591,8 @@ qr_instance(a::Number) = a """ qr_instance(a::Any) -> qr(a) -Returns the number. +Slow fallback which gets the instance via factorization. Should get +specialized for new matrix types. """ qr_instance(a::Any) = qr(a)# check = false) @@ -558,7 +616,8 @@ svd_instance(a::Number) = a """ svd_instance(a::Any) -> svd(a) -Returns the number. +Slow fallback which gets the instance via factorization. Should get +specialized for new matrix types. """ svd_instance(a::Any) = svd(a) #check = false) From e1870b7be71785dfc39cc81b33c043f7a8f8d081 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 25 Mar 2023 11:22:20 -0400 Subject: [PATCH 014/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 537a38b53..12888d453 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.3.1" +version = "7.4.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From bd87ae44a3e45bc2c984b42cd0ffa9c51337732b Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 26 Mar 2023 01:57:45 -0400 Subject: [PATCH 015/124] Fix Cholesky Instance with pivot on SparseMatrixCSC to match the interface --- src/ArrayInterface.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 00dd753bc..d762762d5 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -443,7 +443,7 @@ _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 Cholesky factorization object with the correct type +Returns an instance of the Bunch-Kaufman factorization object with the correct type cheaply. """ function bunchkaufman_instance(A::Matrix{T}) where T @@ -476,7 +476,7 @@ cheaply. function cholesky_instance(A::Matrix{T}, pivot = LinearAlgebra.RowMaximum()) where {T} return cholesky(similar(A, 0, 0), pivot, check = false) end -function cholesky_instance(A::SparseMatrixCSC) +function cholesky_instance(A::SparseMatrixCSC, pivot = LinearAlgebra.RowMaximum()) cholesky(sparse(similar(A, 1, 1)), check = false) end From 9c94c10939693bf14e3f91457ebd0d5d1ae78e4d Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 26 Mar 2023 02:16:51 -0400 Subject: [PATCH 016/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 12888d453..fae7d8730 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.0" +version = "7.4.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From f0dc9f1b74653761c2e6ceb8e4d0f100fccf73bb Mon Sep 17 00:00:00 2001 From: Gaurav Arya Date: Tue, 28 Mar 2023 11:55:54 -0400 Subject: [PATCH 017/124] Remove static array restructure method with incorrect type behaviour --- ext/ArrayInterfaceStaticArraysCoreExt.jl | 3 --- test/staticarrayscore.jl | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/ArrayInterfaceStaticArraysCoreExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl index bf5a11006..5c555f638 100644 --- a/ext/ArrayInterfaceStaticArraysCoreExt.jl +++ b/ext/ArrayInterfaceStaticArraysCoreExt.jl @@ -30,9 +30,6 @@ function ArrayInterface.lu_instance(_A::StaticArraysCore.StaticMatrix{N,N}) wher lu(one(_A)) end -function ArrayInterface.restructure(x::StaticArraysCore.SArray{S,T,N}, y::StaticArraysCore.SArray) where {S,T,N} - StaticArraysCore.SArray{S,T,N}(y) -end ArrayInterface.restructure(x::StaticArraysCore.SArray{S}, y) where {S} = StaticArraysCore.SArray{S}(y) end diff --git a/test/staticarrayscore.jl b/test/staticarrayscore.jl index c6c5df361..420a05c74 100644 --- a/test/staticarrayscore.jl +++ b/test/staticarrayscore.jl @@ -22,7 +22,7 @@ y = @SVector rand(4) yr = ArrayInterface.restructure(x, y) @test yr isa SMatrix{2, 2} @test Base.size(yr) == (2,2) -@test vec(yr) == vec(Float32.(y)) +@test vec(yr) == vec(y) z = rand(4) zr = ArrayInterface.restructure(x, z) @test zr isa SMatrix{2, 2} From ba02e0c5765e2aa921dd1a17833c3de2df1bb376 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 28 Mar 2023 13:38:57 -0400 Subject: [PATCH 018/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index fae7d8730..e1edf2ad9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.1" +version = "7.4.2" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From f2e5d5a735db8d8af33f9f9a81ae13ce166e8bbc Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Fri, 31 Mar 2023 06:13:28 -0400 Subject: [PATCH 019/124] Fix BigFloat QR instance and test better Found in https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/4527032588/jobs/8065045759#step:6:517 that there's a special case to consider here. Now it's better tested. --- src/ArrayInterface.jl | 4 ++++ test/core.jl | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index d762762d5..7b31aea67 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -576,6 +576,10 @@ function qr_instance(A::Matrix{T}) where {T} LinearAlgebra.QRCompactWYQ(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))) diff --git a/test/core.jl b/test/core.jl index 85b1576b7..5e9920f88 100644 --- a/test/core.jl +++ b/test/core.jl @@ -259,3 +259,13 @@ end @test !ArrayInterface.ensures_sorted([]) @test ArrayInterface.ensures_sorted(1:10) end + +@testset "linearalgebra instances" being + for A in [rand(2,2), rand(Float32,2,2), rand(BigFloat,2,2)] + @test ArrayInterface.bunchkaufman_instance(A) isa typeof(bunchkaufman(A' * A)) + @test ArrayInterface.cholesky_instance(A) isa typeof(cholesky(A' * A)) + @test ArrayInterface.ldlt_instance(A) isa typeof(ldlt(SymTridiagonal(A' * A))) + @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) + @test ArrayInterface.qr_instance(A) isa typeof(qr(A)) + end +end \ No newline at end of file From f65ab8d3d79616a6203e9fa54cfbb772c883a21d Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Fri, 31 Mar 2023 06:16:56 -0400 Subject: [PATCH 020/124] one more --- test/core.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/core.jl b/test/core.jl index 5e9920f88..9cd8f98cf 100644 --- a/test/core.jl +++ b/test/core.jl @@ -267,5 +267,6 @@ end @test ArrayInterface.ldlt_instance(A) isa typeof(ldlt(SymTridiagonal(A' * A))) @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) @test ArrayInterface.qr_instance(A) isa typeof(qr(A)) + @test ArrayInterface.svd_instance(A) isa typeof(svd(A)) end end \ No newline at end of file From c7dacc90fd288a132f2007b43ac3acd2eb91ed36 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Fri, 31 Mar 2023 06:41:14 -0400 Subject: [PATCH 021/124] fix typo --- test/core.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core.jl b/test/core.jl index 9cd8f98cf..ac22209eb 100644 --- a/test/core.jl +++ b/test/core.jl @@ -260,7 +260,7 @@ end @test ArrayInterface.ensures_sorted(1:10) end -@testset "linearalgebra instances" being +@testset "linearalgebra instances" begin for A in [rand(2,2), rand(Float32,2,2), rand(BigFloat,2,2)] @test ArrayInterface.bunchkaufman_instance(A) isa typeof(bunchkaufman(A' * A)) @test ArrayInterface.cholesky_instance(A) isa typeof(cholesky(A' * A)) From cc01b00ab3941b622d106e75657c793af068e06d Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Fri, 31 Mar 2023 08:57:39 -0400 Subject: [PATCH 022/124] bigfloat factorizations may not exist --- test/core.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/core.jl b/test/core.jl index ac22209eb..389505801 100644 --- a/test/core.jl +++ b/test/core.jl @@ -262,11 +262,15 @@ end @testset "linearalgebra instances" begin for A in [rand(2,2), rand(Float32,2,2), rand(BigFloat,2,2)] - @test ArrayInterface.bunchkaufman_instance(A) isa typeof(bunchkaufman(A' * A)) - @test ArrayInterface.cholesky_instance(A) isa typeof(cholesky(A' * A)) - @test ArrayInterface.ldlt_instance(A) isa typeof(ldlt(SymTridiagonal(A' * A))) + @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) @test ArrayInterface.qr_instance(A) isa typeof(qr(A)) - @test ArrayInterface.svd_instance(A) isa typeof(svd(A)) + + if !(eltype(A) isa BigFloat) + @test ArrayInterface.bunchkaufman_instance(A) isa typeof(bunchkaufman(A' * A)) + @test ArrayInterface.cholesky_instance(A) isa typeof(cholesky(A' * A)) + @test ArrayInterface.ldlt_instance(A) isa typeof(ldlt(SymTridiagonal(A' * A))) + @test ArrayInterface.svd_instance(A) isa typeof(svd(A)) + end end end \ No newline at end of file From a26b85aeff4968a3711b9e3ffcf202bfd358f16a Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Fri, 31 Mar 2023 09:16:48 -0400 Subject: [PATCH 023/124] wrong type check --- test/core.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core.jl b/test/core.jl index 389505801..ee7608584 100644 --- a/test/core.jl +++ b/test/core.jl @@ -266,7 +266,7 @@ end @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) @test ArrayInterface.qr_instance(A) isa typeof(qr(A)) - if !(eltype(A) isa BigFloat) + if !(eltype(A) <: BigFloat) @test ArrayInterface.bunchkaufman_instance(A) isa typeof(bunchkaufman(A' * A)) @test ArrayInterface.cholesky_instance(A) isa typeof(cholesky(A' * A)) @test ArrayInterface.ldlt_instance(A) isa typeof(ldlt(SymTridiagonal(A' * A))) From 393341586c26cf714b94c1fff4dbc08c793cfeb3 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 31 Mar 2023 09:32:33 -0400 Subject: [PATCH 024/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e1edf2ad9..e2cf2c4ca 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.2" +version = "7.4.3" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 42d5018f0c01e8d286036db1e3c09a7b0c208b3d Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 25 Apr 2023 07:39:42 +0200 Subject: [PATCH 025/124] Remove SnoopPrecompile dep It's doesn't seem to be used --- Project.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Project.toml b/Project.toml index e2cf2c4ca..0041ab03c 100644 --- a/Project.toml +++ b/Project.toml @@ -6,13 +6,11 @@ version = "7.4.3" Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Requires = "ae029012-a4dd-5104-9daa-d747884805df" -SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [compat] Adapt = "3" -SnoopPrecompile = "1" Requires = "1" julia = "1.6" From c3fada672e41ee1506e5e0ece1444edaf3917aa8 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 14 May 2023 13:37:57 -0400 Subject: [PATCH 026/124] update for new QR instance --- src/ArrayInterface.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 7b31aea67..f716b50bc 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -573,7 +573,11 @@ Returns an instance of the QR factorization object with the correct type cheaply. """ function qr_instance(A::Matrix{T}) where {T} - LinearAlgebra.QRCompactWYQ(zeros(T,0,0),zeros(T,0,0)) + if VERSION >= v"1.9" + LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) + else + LinearAlgebra.QRCompactWYQ(zeros(T,0,0),zeros(T,0,0)) + end end function qr_instance(A::Matrix{BigFloat}) From fbe6b8e4e0bac97e29588eb61d6250888523dfdc Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 14 May 2023 14:45:02 -0400 Subject: [PATCH 027/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0041ab03c..0a61be7d9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.3" +version = "7.4.4" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From a49c4b582001873f2a7b8bbeb4b7ccc23ce181e8 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Tue, 16 May 2023 16:55:48 -0400 Subject: [PATCH 028/124] More qr_instance fixes --- src/ArrayInterface.jl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index f716b50bc..7ca934f58 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -573,11 +573,7 @@ Returns an instance of the QR factorization object with the correct type cheaply. """ function qr_instance(A::Matrix{T}) where {T} - if VERSION >= v"1.9" - LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) - else - LinearAlgebra.QRCompactWYQ(zeros(T,0,0),zeros(T,0,0)) - end + LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) end function qr_instance(A::Matrix{BigFloat}) From 454be6840098613f65dc76f2e3a0da80da4cd0df Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 16 May 2023 17:26:48 -0400 Subject: [PATCH 029/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0a61be7d9..ae562c406 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.4" +version = "7.4.5" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From 2a9cedfb303acc7c27f2e54b84fcccae5443b127 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 May 2023 07:06:23 -0700 Subject: [PATCH 030/124] LDLt has no check LDLt has no check --- src/ArrayInterface.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 7ca934f58..39251c347 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -502,10 +502,10 @@ 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)), check = false) + return ldlt(SymTridiagonal(similar(A, 0, 0))) end function ldlt_instance(A::SparseMatrixCSC) - ldlt(sparse(similar(A, 1, 1)), check = false) + ldlt(sparse(similar(A, 1, 1))) end """ From 6effc7d8e77a2652e8e71e3f84e7524a5fa89878 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 May 2023 07:06:39 -0700 Subject: [PATCH 031/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ae562c406..01d350b7d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.5" +version = "7.4.6" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From a1e154f1fc802e0a50f01bb1370637b9bbea4eac Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 May 2023 10:47:29 -0700 Subject: [PATCH 032/124] Only sparse ldlt has check Now it makes sense... --- src/ArrayInterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 39251c347..6cec03a82 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -505,7 +505,7 @@ 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))) + ldlt(sparse(similar(A, 1, 1)), check=false) end """ From ca43b2e7a1fd93e9dd569c38a21397ef4d7b1d3b Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 May 2023 16:18:28 -0700 Subject: [PATCH 033/124] Fix cholesky_instance for symmetric sparse --- Project.toml | 2 +- src/ArrayInterface.jl | 2 +- test/core.jl | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 01d350b7d..28e903bea 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.6" +version = "7.4.7" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 6cec03a82..2f78138ac 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -476,7 +476,7 @@ cheaply. function cholesky_instance(A::Matrix{T}, pivot = LinearAlgebra.RowMaximum()) where {T} return cholesky(similar(A, 0, 0), pivot, check = false) end -function cholesky_instance(A::SparseMatrixCSC, pivot = LinearAlgebra.RowMaximum()) +function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = LinearAlgebra.RowMaximum()) cholesky(sparse(similar(A, 1, 1)), check = false) end diff --git a/test/core.jl b/test/core.jl index ee7608584..3c7feee72 100644 --- a/test/core.jl +++ b/test/core.jl @@ -267,10 +267,17 @@ end @test ArrayInterface.qr_instance(A) isa typeof(qr(A)) if !(eltype(A) <: BigFloat) - @test ArrayInterface.bunchkaufman_instance(A) isa typeof(bunchkaufman(A' * A)) - @test ArrayInterface.cholesky_instance(A) isa typeof(cholesky(A' * A)) - @test ArrayInterface.ldlt_instance(A) isa typeof(ldlt(SymTridiagonal(A' * A))) + @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)) end end + + for A in [sparse([1.0 2.0; 3.0 4.0])] + @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) + @test ArrayInterface.qr_instance(A) isa typeof(qr(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))) + end end \ No newline at end of file From a98c23582ebd42a0f8351a1aa2efb0ea2d7bf859 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 May 2023 16:22:23 -0700 Subject: [PATCH 034/124] remove test from v1.6 --- test/core.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/core.jl b/test/core.jl index 3c7feee72..bd0cd6cf3 100644 --- a/test/core.jl +++ b/test/core.jl @@ -277,7 +277,9 @@ end for A in [sparse([1.0 2.0; 3.0 4.0])] @test ArrayInterface.lu_instance(A) isa typeof(lu(A)) @test ArrayInterface.qr_instance(A) isa typeof(qr(A)) - @test ArrayInterface.cholesky_instance(A' * A) isa typeof(cholesky(A' * A)) + if VERSION >= v"1.9-" + @test ArrayInterface.cholesky_instance(A' * A) isa typeof(cholesky(A' * A)) + end @test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A))) end end \ No newline at end of file From 72f4524eb6e7198a917f8b0e36d3d6d1e544e3fc Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 May 2023 17:15:23 -0700 Subject: [PATCH 035/124] fix default on cholesky pivot --- src/ArrayInterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 2f78138ac..d6872cf26 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -473,7 +473,7 @@ 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 = LinearAlgebra.RowMaximum()) where {T} +function cholesky_instance(A::Matrix{T}, pivot = LinearAlgebra.NoPivot()) where {T} return cholesky(similar(A, 0, 0), pivot, check = false) end function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = LinearAlgebra.RowMaximum()) From 796eb67aec9c783492d683a909f9f841b87a1c8c Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 May 2023 18:33:01 -0700 Subject: [PATCH 036/124] improve pivot --- Project.toml | 2 +- src/ArrayInterface.jl | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 28e903bea..d91b1cbd8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.7" +version = "7.4.8" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index d6872cf26..ed616a87f 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -467,16 +467,23 @@ Returns the number. """ bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false) +@static if VERSION < v"1.7beta" + const DEFAULT_CHOLESKY_PIVOT = Val(false) +else + const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot() +end + """ 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 = LinearAlgebra.NoPivot()) 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 = LinearAlgebra.RowMaximum()) + +function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT) cholesky(sparse(similar(A, 1, 1)), check = false) end @@ -485,7 +492,7 @@ cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) -> a Returns the number. """ -cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) = a +cholesky_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a """ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false) @@ -493,7 +500,7 @@ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, che Slow fallback which gets the instance via factorization. Should get specialized for new matrix types. """ -cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) = cholesky(a, pivot, check = false) +cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false) """ ldlt_instance(A) -> ldlt_factorization_instance From 3adafe91bc1d62069548a8fd2bf33a7fd152b855 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sun, 18 Jun 2023 11:07:54 -0400 Subject: [PATCH 037/124] 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 ed616a87f..04caa7a12 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 038/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index d91b1cbd8..1fc489bc9 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 039/124] 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 8ebbcfdd9..cee8d255c 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 04caa7a12..e51698927 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 040/124] 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 e51698927..b104f403c 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 041/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1fc489bc9..4d7a075de 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 042/124] 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 4d7a075de..5c84a8b24 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 b104f403c..521522dc9 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 043/124] 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 521522dc9..cb1c91bbc 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 044/124] 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 d2b8c0fab..adc1628ef 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 647941115..0c20c43eb 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 4d0004e83..28b9ce2fa 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 cee8d255c..30af0d8b5 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 045/124] 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 5c84a8b24..32c6f9bef 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 358434f15..a3b8ca671 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 a6142efd0..94626aac3 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 046/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 32c6f9bef..478aea9c6 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 047/124] 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 cb1c91bbc..5297a87ea 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 bd0cd6cf3..bf9b0712e 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 048/124] bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 478aea9c6..bc02b5c1a 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 049/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index bc02b5c1a..32c6f9bef 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 050/124] Update Project.toml --- Project.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Project.toml b/Project.toml index 32c6f9bef..181046cfd 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 051/124] 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 5297a87ea..b364c5de8 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 052/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 181046cfd..7dbf6a028 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 053/124] 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 7dbf6a028..58b2fd1c3 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 b364c5de8..7c5ab168f 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 bf9b0712e..5208393fa 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 054/124] 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 30af0d8b5..d0835864a 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 58b2fd1c3..104b251ee 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 055/124] 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 0c20c43eb..922d4adfb 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 7c5ab168f..75a49f013 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 056/124] 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 75a49f013..be612970c 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 057/124] 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 be612970c..3804c5c78 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 058/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 104b251ee..960f42cf0 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 059/124] 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 960f42cf0..15bdd344d 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 060/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 15bdd344d..00467e229 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 061/124] 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 d0835864a..189aacd51 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 062/124] 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 adc1628ef..d26b9dd03 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 922d4adfb..34b8e1bca 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 189aacd51..d9333ffbf 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 063/124] 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 5c555f638..c7b142799 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 064/124] 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 00467e229..5f3aba737 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 420a05c74..cbbba184b 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 065/124] 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 5f3aba737..b5ba13fb5 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 000000000..f8c8e4bc7 --- /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 000000000..92b88461a --- /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 ec3493fd8..bedb7693f 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 066/124] add tests --- test/ad.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/ad.jl b/test/ad.jl index 92b88461a..4754b8b80 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 067/124] 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 f8c8e4bc7..13bfd23ff 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 4754b8b80..7c29c8dd5 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 068/124] Update ArrayInterfaceReverseDiffExt.jl --- ext/ArrayInterfaceReverseDiffExt.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/ArrayInterfaceReverseDiffExt.jl b/ext/ArrayInterfaceReverseDiffExt.jl index 13bfd23ff..f8c8e4bc7 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 069/124] 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 b5ba13fb5..48f462d4d 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 f8c8e4bc7..c303398bf 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 070/124] 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 48f462d4d..12ad530bf 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 a3b8ca671..fcd0fb7b0 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 f66362130..e4e7bbae1 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 f5d2a9507..ae4477d3e 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 40d0fc1ac..79bbf6063 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 c303398bf..ed544e488 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 c7b142799..acf06adfd 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 4bb10c39c..d2d4e2ce3 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 3804c5c78..0ce3faa68 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 071/124] 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 12ad530bf..a751d7d44 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 000000000..0a91bbb37 --- /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 000000000..df47b2ffe --- /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 bedb7693f..7999dbec7 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 072/124] 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 a751d7d44..6ac7ff255 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 000000000..01fb23953 --- /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 073/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6ac7ff255..e66aaa6d6 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 074/124] 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 e66aaa6d6..753967ddb 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 075/124] 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 e66aaa6d6..5a2baf3d7 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 076/124] 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 e66aaa6d6..e7f776baf 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 077/124] 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 e66aaa6d6..cbecab458 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 078/124] 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 e66aaa6d6..aa9d01db1 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 079/124] 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 e66aaa6d6..fe05eb5e8 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 080/124] 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 e66aaa6d6..94bd3ddd9 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 081/124] 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 e66aaa6d6..f226bb08e 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 082/124] 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 e66aaa6d6..30e4de546 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 083/124] 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 0ce3faa68..2766c44ed 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 084/124] chore: typo --- src/ArrayInterface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index 2766c44ed..31d9156d1 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 085/124] 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 812ea0143..dc2db46be 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 086/124] 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 31d9156d1..2b80b6113 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 087/124] 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 2b80b6113..ed1ea127f 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 5208393fa..003f7b5db 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 088/124] 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 ed1ea127f..ddf661f66 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 089/124] Fix tests --- test/blockbandedmatrices.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/blockbandedmatrices.jl b/test/blockbandedmatrices.jl index 9f29716d0..2a34a852d 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 090/124] Update Project.toml --- Project.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 812ea0143..a26a4435f 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 091/124] 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 2a34a852d..5f1588687 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 092/124] 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 51f9b1a37..46d7fecd8 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 093/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3a445d27a..80bf493f8 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 094/124] 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 80bf493f8..4075635e8 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 095/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4075635e8..eb0c12e52 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 096/124] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 812b7753d..9d20d7bc8 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 097/124] 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 eb0c12e52..1a1926741 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 000000000..61fff69dc --- /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 ddf661f66..b9e56d01b 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 098/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1a1926741..ee1afdfce 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 099/124] 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 ee1afdfce..8065d1562 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 acf06adfd..000000000 --- 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 000000000..80e8e4a75 --- /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 7999dbec7..8a5d7b363 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 100/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 8065d1562..47f9c0bed 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 101/124] 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 47f9c0bed..bd870bcf7 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 102/124] 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 47f9c0bed..f729089c3 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 80e8e4a75..774ecd8e8 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 103/124] delete optimization --- ext/ArrayInterfaceStaticArraysCoreExt.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ext/ArrayInterfaceStaticArraysCoreExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl index 774ecd8e8..7b33dc802 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 104/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index f729089c3..c70312fbd 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 105/124] 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 46d7fecd8..129e3746d 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 106/124] 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 d2d4e2ce3..6d26f4109 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 7c29c8dd5..c1a207b7c 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 107/124] Namespace --- ext/ArrayInterfaceTrackerExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ArrayInterfaceTrackerExt.jl b/ext/ArrayInterfaceTrackerExt.jl index 6d26f4109..5723d9f1f 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 108/124] 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 ed544e488..37176824e 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 c1a207b7c..bc3c3dd80 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 109/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c70312fbd..dcd5306cf 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 110/124] 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 dcd5306cf..52cce9725 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 111/124] 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 dcd5306cf..52cce9725 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 112/124] 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 52cce9725..c1b74442a 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 000000000..6cf4c406f --- /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 df47b2ffe..759a55bee 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 113/124] Update Project.toml --- Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Project.toml b/Project.toml index a9804a7b2..c1b74442a 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 114/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c1b74442a..3dfc4a97d 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 115/124] 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 37176824e..3a000def3 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 116/124] test: singleton dims AoS --- test/ad.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/ad.jl b/test/ad.jl index bc3c3dd80..3c61873e6 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 117/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3dfc4a97d..df828b51f 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 118/124] 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 d26b9dd03..d72858504 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 34b8e1bca..1af21937e 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 d9333ffbf..cb9fe51a0 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 119/124] 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 df828b51f..ab82ddfac 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 120/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ab82ddfac..2d09c1c7b 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 121/124] 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 fcd0fb7b0..5eaeb0cdf 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 122/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2d09c1c7b..6537a4b7c 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 123/124] 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 61fff69dc..9f0e06b43 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 124/124] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6537a4b7c..c4a079e5b 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"