diff --git a/ext/OffsetArraysAdaptExt.jl b/ext/OffsetArraysAdaptExt.jl index 55969fd..40a30ab 100644 --- a/ext/OffsetArraysAdaptExt.jl +++ b/ext/OffsetArraysAdaptExt.jl @@ -12,6 +12,8 @@ Adapt.adapt_structure(to, O::OffsetArray) = OffsetArrays.parent_call(x -> Adapt. # To support Adapt 3.0 which doesn't have parent_type defined Adapt.parent_type(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA Adapt.unwrap_type(W::Type{<:OffsetArray}) = unwrap_type(parent_type(W)) + + Base.Broadcast.BroadcastStyle(W::Type{<:OffsetArray}) = Base.Broadcast.BroadcastStyle(unwrap_type(W)) end end diff --git a/src/OffsetArrays.jl b/src/OffsetArrays.jl index 9aa9f58..55b4c23 100644 --- a/src/OffsetArrays.jl +++ b/src/OffsetArrays.jl @@ -280,12 +280,6 @@ parenttype(A::OffsetArray) = parenttype(typeof(A)) Base.parent(A::OffsetArray) = A.parent -# TODO: Ideally we would delegate to the parent's broadcasting implementation, but that -# is currently broken in sufficiently many implementation, namely RecursiveArrayTools, DistributedArrays -# and StaticArrays, that it will take concentrated effort to get this working across the ecosystem. -# The goal would be to have `OffsetArray(CuArray) .+ 1 == OffsetArray{CuArray}`. -# Base.Broadcast.BroadcastStyle(::Type{<:OffsetArray{<:Any, <:Any, AA}}) where AA = Base.Broadcast.BroadcastStyle(AA) - @inline Base.size(A::OffsetArray) = size(parent(A)) # specializing length isn't necessary, as length(A) = prod(size(A)), # but specializing length enables constant-propagation for statically sized arrays