Skip to content

Commit e72cfc8

Browse files
committed
Set generic fallback size and strides to equal base methods.
1 parent efe40e1 commit e72cfc8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/stridelayout.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ julia> ArrayInterface.size(A)
224224
(Static{3}(), Static{4}())
225225
```
226226
"""
227-
size(::Any) = nothing
227+
size(A) = Base.size(A)
228228
"""
229229
strides(A)
230230
@@ -237,7 +237,7 @@ julia> ArrayInterface.strides(A)
237237
(Static{1}(), 3)
238238
```
239239
"""
240-
strides(::Any) = nothing
240+
strides(A) = Base.strides(A)
241241
"""
242242
offsets(A)
243243
@@ -246,7 +246,6 @@ it should return them as `Static` numbers.
246246
For example, if `A isa Base.Matrix`, `offsets(A) === (Static(1), Static(1))`.
247247
"""
248248
offsets(::Any) = (Static{1}(),) # Assume arbitrary Julia data structures use 1-based indexing by default.
249-
@inline size(A::AbstractArray{<:Any,N}) where {N} = Base.size(A)
250249
@inline strides(A::Vector{<:Any}) = (Static(1),)
251250
@inline strides(A::Array{<:Any,N}) where {N} = (Static(1), Base.tail(Base.strides(A))...)
252251
@inline strides(A::AbstractArray{<:Any,N}) where {N} = Base.strides(A)
@@ -274,6 +273,7 @@ end
274273
@inline strides(B::PermutedDimsArray{T,N,I1,I2,A}) where {T,N,I1,I2,A<:AbstractArray{T,N}} = permute(strides(parent(B)), Val{I1}())
275274
@inline stride(A::AbstractArray, ::Static{N}) where {N} = strides(A)[N]
276275
@inline stride(A::AbstractArray, ::Val{N}) where {N} = strides(A)[N]
276+
stride(A, i) = Base.stride(A, i)
277277

278278
size(B::S) where {N,NP,T,A<:AbstractArray{T,NP},I,S <: SubArray{T,N,A,I}} = _size(size(parent(B)), B.indices, map(static_length, B.indices))
279279
strides(B::S) where {N,NP,T,A<:AbstractArray{T,NP},I,S <: SubArray{T,N,A,I}} = _strides(strides(parent(B)), B.indices)

0 commit comments

Comments
 (0)