@@ -6,7 +6,8 @@ import ArrayInterfaceCore: allowed_getindex, allowed_setindex!, aos_to_soa, buff
66 issingular, isstructured, matrix_colors, restructure, lu_instance,
77 safevec, zeromatrix, ColoringAlgorithm, fast_scalar_indexing, parameterless_type,
88 ndims_index, ndims_shape, is_splat_index, is_forwarding_wrapper, IndicesInfo,
9- map_tuple_type, flatten_tuples, GetIndex, SetIndex!
9+ map_tuple_type, flatten_tuples, GetIndex, SetIndex!, defines_strides,
10+ stride_preserving_index
1011
1112# ArrayIndex subtypes and methods
1213import ArrayInterfaceCore: ArrayIndex, MatrixIndex, VectorIndex, BidiagonalIndex, TridiagonalIndex
@@ -16,7 +17,7 @@ import ArrayInterfaceCore: ismutable, can_change_size, can_setindex
1617import ArrayInterfaceCore: MatAdjTrans, VecAdjTrans, UpTri, LoTri
1718# device pieces
1819import ArrayInterfaceCore: AbstractDevice, AbstractCPU, CPUPointer, CPUTuple, CheckParent,
19- CPUIndex, GPU, can_avx
20+ CPUIndex, GPU, can_avx, device
2021
2122import ArrayInterfaceCore: known_first, known_step, known_last
2223
@@ -109,32 +110,6 @@ has_parent(::Type{T}) where {T} = _has_parent(parent_type(T), T)
109110_has_parent (:: Type{T} , :: Type{T} ) where {T} = False ()
110111_has_parent (:: Type{T1} , :: Type{T2} ) where {T1,T2} = True ()
111112
112- """
113- device(::Type{T}) -> AbstractDevice
114-
115- Indicates the most efficient way to access elements from the collection in low-level code.
116- For `GPUArrays`, will return `ArrayInterface.GPU()`.
117- For `AbstractArray` supporting a `pointer` method, returns `ArrayInterface.CPUPointer()`.
118- For other `AbstractArray`s and `Tuple`s, returns `ArrayInterface.CPUIndex()`.
119- Otherwise, returns `nothing`.
120- """
121- device (A) = device (typeof (A))
122- device (:: Type ) = nothing
123- device (:: Type{<:Tuple} ) = CPUTuple ()
124- device (:: Type{T} ) where {T<: Array } = CPUPointer ()
125- device (:: Type{T} ) where {T<: AbstractArray } = _device (has_parent (T), T)
126- function _device (:: True , :: Type{T} ) where {T}
127- if defines_strides (T)
128- return device (parent_type (T))
129- else
130- return _not_pointer (device (parent_type (T)))
131- end
132- end
133- _not_pointer (:: CPUPointer ) = CPUIndex ()
134- _not_pointer (x) = x
135- _device (:: False , :: Type{T} ) where {T<: DenseArray } = CPUPointer ()
136- _device (:: False , :: Type{T} ) where {T} = CPUIndex ()
137-
138113"""
139114 is_lazy_conjugate(::AbstractArray) -> Bool
140115
0 commit comments