@@ -164,7 +164,8 @@ function contiguous_axis(::Type{T}) where {T<:PermutedDimsArray}
164164 end
165165end
166166function contiguous_axis (:: Type{<:Base.ReshapedArray{T, N, A, Tuple{}}} ) where {T, N, A}
167- if isone (- contiguous_axis (A))
167+ c = contiguous_axis (A)
168+ if c != = nothing && isone (- c)
168169 return StaticInt (- 1 )
169170 elseif dynamic (is_column_major (A) & is_dense (A))
170171 return StaticInt (1 )
@@ -455,9 +456,17 @@ _dense_dims(::Type{S}, ::Nothing, ::Val{R}) where {R,N,NP,T,A<:AbstractArray{T,N
455456 end
456457end
457458
458- function dense_dims (:: Type {Base. ReshapedArray{T, N, P, Tuple{Vararg{Base. SignedMultiplicativeInverse{Int},M}}}}) where {T,N,P,M}
459- return _reshaped_dense_dims (dense_dims (P), is_column_major (P), Val {N} (), Val {M} ())
459+ function dense_dims (T:: Type{<:Base.ReshapedArray} )
460+ d = dense_dims (parent_type (T))
461+ if d === nothing
462+ return nothing
463+ elseif all (d)
464+ return n_of_x (StaticInt (ndims (T)), True ())
465+ else
466+ return n_of_x (StaticInt (ndims (T)), False ())
467+ end
460468end
469+
461470is_dense (A) = is_dense (typeof (A))
462471is_dense (:: Type{A} ) where {A} = _is_dense (dense_dims (A))
463472_is_dense (:: Tuple{False,Vararg} ) = False ()
@@ -466,19 +475,6 @@ _is_dense(t::Tuple{True}) = True()
466475_is_dense (t:: Tuple{} ) = True ()
467476_is_dense (:: Nothing ) = False ()
468477
469-
470- _reshaped_dense_dims (_, __, ___, ____) = nothing
471- function _reshaped_dense_dims (dense:: Tuple , :: True , :: Val{N} , :: Val{0} ) where {N}
472- if all (dense)
473- return _all_dense (Val {N} ())
474- else
475- return nothing
476- end
477- end
478- function _reshaped_dense_dims (dense:: Tuple{Static.False} , :: True , :: Val{N} , :: Val{0} ) where {N}
479- return return ntuple (_ -> False (), Val {N} ())
480- end
481-
482478"""
483479 known_strides(::Type{T}) -> Tuple
484480 known_strides(::Type{T}, dim) -> Union{Int,Nothing}
0 commit comments