Skip to content

[WIP] Small fixes to broadcast #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ DArrayStyle(::Val{N}) where N = DArrayStyle{Broadcast.DefaultArrayStyle{N}}()
BroadcastStyle(::Type{<:DArray{<:Any, N, A}}) where {N, A} = DArrayStyle(BroadcastStyle(A), Val(N))

# promotion rules
# TODO: test this
function BroadcastStyle(::DArrayStyle{AStyle}, ::DArrayStyle{BStyle}) where {AStyle, BStyle}
DArrayStyle{BroadcastStyle(AStyle, BStyle)}()
DArrayStyle(BroadcastStyle(AStyle, BStyle))
end

function Broadcast.broadcasted(::DArrayStyle{Style}, f, args...) where Style
inner = Broadcast.broadcasted(Style(), f, args...)
if inner isa Broadcasted
return Broadcasted{DArrayStyle{Style}}(inner.f, inner.args, inner.axes)
else # eagerly evaluated
return inner
end
end

# # deal with one layer deep lazy arrays
Expand Down Expand Up @@ -75,6 +85,10 @@ end
return dest
end

# Test
# a = Array
# a .= DArray(x,y)

@inline function Base.copy(bc::Broadcasted{<:DArrayStyle})
dbc = bcdistribute(bc)
# TODO: teach DArray about axes since this is wrong for OffsetArrays
Expand Down