Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit b702219

Browse files
Change to ArrayInterfaceCore
1 parent bcca812 commit b702219

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = "1.21.0"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
8-
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
8+
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
99
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
1010
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1111
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
@@ -19,7 +19,7 @@ VertexSafeGraphs = "19fa3120-7c27-5ec5-8db8-b0b0aa330d6f"
1919

2020
[compat]
2121
Adapt = "1, 2.0, 3.0"
22-
ArrayInterface = "2.8, 3.0, 4, 5"
22+
ArrayInterfaceCore = "0.1.1"
2323
Compat = "2.2, 3"
2424
DataStructures = "0.17, 0.18"
2525
FiniteDiff = "2.8.1"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ gmres!(res,J,v)
112112

113113
### Matrix Coloring
114114

115-
This library extends the common `ArrayInterface.matrix_colors` function to allow
115+
This library extends the common `ArrayInterfaceCore.matrix_colors` function to allow
116116
for coloring sparse matrices using graphical techniques.
117117

118118
Matrix coloring allows you to reduce the number of times finite differencing
@@ -163,7 +163,7 @@ forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
163163

164164
Notice that if a sparsity pattern is not supplied then the built Jacobian will
165165
be the compressed Jacobian: `sparsity` must be a sparse matrix or a structured matrix
166-
(`Tridiagonal`, `Banded`, etc. conforming to the ArrayInterface.jl specs) with the
166+
(`Tridiagonal`, `Banded`, etc. conforming to the ArrayInterfaceCore.jl specs) with the
167167
appropriate sparsity pattern to allow for decompression.
168168

169169
This call will allocate the cache variables each time. To avoid allocating the

src/SparseDiffTools.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ using VertexSafeGraphs
1010
using Adapt
1111

1212
using LinearAlgebra
13-
using SparseArrays, ArrayInterface
13+
using SparseArrays, ArrayInterfaceCore
1414

1515
import StaticArrays
1616

1717
using ForwardDiff: Dual, jacobian, partials, DEFAULT_CHUNK_THRESHOLD
1818
using DataStructures: DisjointSets, find_root!, union!
1919

20-
using ArrayInterface: matrix_colors
20+
using ArrayInterfaceCore: matrix_colors
2121

2222
export contract_color,
2323
greedy_d1,

src/coloring/high_level.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
abstract type SparseDiffToolsColoringAlgorithm <: ArrayInterface.ColoringAlgorithm end
1+
abstract type SparseDiffToolsColoringAlgorithm <: ArrayInterfaceCore.ColoringAlgorithm end
22
struct GreedyD1Color <: SparseDiffToolsColoringAlgorithm end
33
struct BacktrackingColor <: SparseDiffToolsColoringAlgorithm end
44
struct ContractionColor <: SparseDiffToolsColoringAlgorithm end
@@ -16,7 +16,7 @@ The coloring defaults to a greedy distance-1 coloring.
1616
Note that if A isa SparseMatrixCSC, the sparsity pattern is defined by structural nonzeroes,
1717
ie includes explicitly stored zeros.
1818
"""
19-
function ArrayInterface.matrix_colors(A::AbstractMatrix, alg::SparseDiffToolsColoringAlgorithm = GreedyD1Color(); partition_by_rows::Bool = false)
19+
function ArrayInterfaceCore.matrix_colors(A::AbstractMatrix, alg::SparseDiffToolsColoringAlgorithm = GreedyD1Color(); partition_by_rows::Bool = false)
2020
_A = A isa SparseMatrixCSC ? A : sparse(A) # Avoid the copy
2121
A_graph = matrix2graph(_A, partition_by_rows)
2222
return color_graph(A_graph, alg)

src/differentiation/compute_jacobian_ad.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ function ForwardColorJacCache(f::F,x,_chunksize = nothing;
4343
else
4444
p = adapt.(parameterless_type(x),generate_chunked_partials(x,colorvec,chunksize))
4545
_t = Dual{T,eltype(x),getsize(chunksize)}.(vec(x),ForwardDiff.Partials.(first(p)))
46-
t = ArrayInterface.restructure(x,_t)
46+
t = ArrayInterfaceCore.restructure(x,_t)
4747
end
4848

4949

5050
if dx isa Nothing
5151
fx = similar(t)
5252
_dx = similar(x)
5353
else
54-
tup = ArrayInterface.allowed_getindex(ArrayInterface.allowed_getindex(p,1),1) .* false
54+
tup = ArrayInterfaceCore.allowed_getindex(ArrayInterfaceCore.allowed_getindex(p,1),1) .* false
5555
_pi = adapt(parameterless_type(dx),[tup for i in 1:length(dx)])
5656
fx = reshape(Dual{T,eltype(dx),length(tup)}.(vec(dx),ForwardDiff.Partials.(_pi)),size(dx)...)
5757
_dx = dx
@@ -134,7 +134,7 @@ end
134134

135135
function forwarddiff_color_jacobian(f::F,x::AbstractArray{<:Number},jac_cache::ForwardColorJacCache,jac_prototype=nothing) where F
136136

137-
if jac_prototype isa Nothing ? ArrayInterface.ismutable(x) : ArrayInterface.ismutable(jac_prototype)
137+
if jac_prototype isa Nothing ? ArrayInterfaceCore.ismutable(x) : ArrayInterfaceCore.ismutable(jac_prototype)
138138
# Whenever J is mutable, we mutate it to avoid allocations
139139
dx = jac_cache.dx
140140
vecx = vec(x)
@@ -164,7 +164,7 @@ function forwarddiff_color_jacobian(J::AbstractMatrix{<:Number},f::F,x::Abstract
164164
nrows,ncols = size(J)
165165

166166
if !(sparsity isa Nothing)
167-
rows_index, cols_index = ArrayInterface.findstructralnz(sparsity)
167+
rows_index, cols_index = ArrayInterfaceCore.findstructralnz(sparsity)
168168
rows_index = [rows_index[i] for i in 1:length(rows_index)]
169169
cols_index = [cols_index[i] for i in 1:length(cols_index)]
170170
end
@@ -232,7 +232,7 @@ function forwarddiff_color_jacobian_immutable(f,x::AbstractArray{<:Number},jac_c
232232
nrows,ncols = size(J)
233233

234234
if !(sparsity isa Nothing)
235-
rows_index, cols_index = ArrayInterface.findstructralnz(sparsity)
235+
rows_index, cols_index = ArrayInterfaceCore.findstructralnz(sparsity)
236236
rows_index = [rows_index[i] for i in 1:length(rows_index)]
237237
cols_index = [cols_index[i] for i in 1:length(cols_index)]
238238
end
@@ -277,7 +277,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
277277
x::AbstractArray{<:Number};
278278
dx = similar(x,size(J,1)),
279279
colorvec = 1:length(x),
280-
sparsity = ArrayInterface.has_sparsestruct(J) ? J : nothing)
280+
sparsity = ArrayInterfaceCore.has_sparsestruct(J) ? J : nothing)
281281
forwarddiff_color_jacobian!(J,f,x,ForwardColorJacCache(f,x,dx=dx,colorvec=colorvec,sparsity=sparsity))
282282
end
283283

@@ -305,7 +305,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
305305
end
306306

307307
if FiniteDiff._use_findstructralnz(sparsity)
308-
rows_index, cols_index = ArrayInterface.findstructralnz(sparsity)
308+
rows_index, cols_index = ArrayInterfaceCore.findstructralnz(sparsity)
309309
else
310310
rows_index = 1:size(J,1)
311311
cols_index = 1:size(J,2)
@@ -344,7 +344,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
344344
dx .= partials.(fx, j)
345345
end
346346

347-
if ArrayInterface.fast_scalar_indexing(dx)
347+
if ArrayInterfaceCore.fast_scalar_indexing(dx)
348348
#dx is implicitly used in vecdx
349349
if sparseCSC_common_sparsity
350350
FiniteDiff._colorediteration!(J,vecdx,colorvec,color_i,ncols)

test/test_gpu_ad.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using SparseDiffTools, CUDA, Test, LinearAlgebra
2-
using ArrayInterface: allowed_getindex, allowed_setindex!
2+
using ArrayInterfaceCore: allowed_getindex, allowed_setindex!
33
using SparseArrays
44

55
function f(dx,x)

0 commit comments

Comments
 (0)