Skip to content
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

RFC: Customizable lazy broadcasting with options for pure-Julia fusion and eager evaluation #25377

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c0db74c
Reduce build-time calls to broadcasting machinery
timholy Jan 3, 2018
0c6617a
Allow test/core.jl to be run from REPL
timholy Jan 4, 2018
98fe8ab
Turn range&number arithmetic operations into broadcast methods
timholy Jan 3, 2018
aeba265
Make lazy dot fusion
vtjnash Sep 27, 2017
98f6bdc
Speed up range tests and fix printing at REPL
timholy Jan 3, 2018
0698edc
Integrate lazy broadcast representation into new broadcast machinery
timholy Jan 3, 2018
4c02b07
Temporarily disable failing tests
timholy Jan 7, 2018
e4d1962
Centralize broadcast support for structured matrices
timholy Jan 7, 2018
944e069
Docs: Slightly gentler introduction and overview of broadcast machinery
mbauman Jan 9, 2018
69eca0b
is_broadcast_incremental docstring: add implications about broadcast …
mbauman Jan 9, 2018
3cf994b
Update doctests for TupleLLEnd
mbauman Jan 10, 2018
de9e321
Fix and test nested scalar broadcasts
mbauman Jan 11, 2018
61bb21f
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Jan 13, 2018
8dcd8c1
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Jan 19, 2018
a14ed08
fixup merge
mbauman Jan 19, 2018
1774bdf
Allow construction of instantiated Broadcasted{Nothing} objects
mbauman Jan 20, 2018
7381ea4
Replace BitArray piecemeal broadcast...
mbauman Jan 20, 2018
25598ea
Fix `literal_pow` broadcast issue. (#25665)
ajkeller34 Jan 21, 2018
99507a2
WIP: broadcast style system for structured matrices
mbauman Jan 22, 2018
2e371e4
Structured broadcasts: Support Bidiagonal broadcasts and perform runt…
mbauman Jan 24, 2018
3e42812
fully detangle sparse and structured broadcast and tests
mbauman Jan 24, 2018
0115326
NFC: Style changes; use explicit returns, some line length considerat…
mbauman Jan 25, 2018
1de78ac
fixup comment
mbauman Jan 25, 2018
8e41f2f
Try implementing incremental broadcast in terms of `make`
mbauman Jan 26, 2018
adaf337
Rename execute to materialize; fixup .= with different size destination
mbauman Jan 27, 2018
cf0f8ce
Fix Sparse inference; improve allocations
mbauman Jan 29, 2018
4f8233f
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Jan 29, 2018
5749afc
fixup merge
mbauman Jan 29, 2018
f90f5fe
fix typejoin promotion and `y .= f.()` syntax
mbauman Jan 30, 2018
28d5421
Transform TupleLL to Tuple; capture Type arguments in a closure (#25844)
mbauman Apr 4, 2018
cfa9caa
Merge branch 'master' into teh-jn/lazydotfuse
mbauman Apr 10, 2018
8147932
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Apr 10, 2018
90ad8eb
Removing broadcasting from the new optimizer
mbauman Apr 12, 2018
03287c1
Remove Structured broadcast deferral to DefaultArrayStyle
mbauman Apr 12, 2018
f71db14
work around SparseArrays inference failure in broadcast!
mbauman Apr 12, 2018
e3eede4
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Apr 12, 2018
0edbd99
Decouple Broadcasting API from inference
mbauman Apr 13, 2018
71b830f
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Apr 13, 2018
b248953
Improve sparse allocation situation
mbauman Apr 13, 2018
964039a
Remove broadcast_skip_axes_initialization
mbauman Apr 18, 2018
37220d5
Improved accounting of the allocations when broadcasting over tranpos…
mbauman Apr 19, 2018
79ce497
Expose simpler axes/getindex methods for Broadcasted objects
mbauman Apr 19, 2018
a6cc656
Documentation update
mbauman Apr 19, 2018
98b5e84
Squash the most egregious perf bugs
mbauman Apr 19, 2018
2e9c0f2
More incremental perf improvements
mbauman Apr 19, 2018
3870fdf
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Apr 19, 2018
c1f2eba
fixup! More incremental perf improvements
mbauman Apr 19, 2018
9afdbbe
WIP: maybe don't use indexers?
mbauman Apr 20, 2018
81bd635
Try removing the indexing helper from Broadcasted
mbauman Apr 20, 2018
82d0a3b
WIP: move indexers into an argument wrapper
mbauman Apr 22, 2018
fb8234a
Completely move indexing helpers into wrappers
mbauman Apr 22, 2018
aba2da7
Don't recursively initialize the Broadcasted objects
mbauman Apr 22, 2018
5f99c2e
Inline copy(::Broadcasted) to avoid allocated the Broadcasted object
mbauman Apr 22, 2018
52a3202
Hack around losing Type{T} information in the final tuple...
mbauman Apr 22, 2018
a8a2608
Avoid re-using the same variable name
mbauman Apr 23, 2018
db690e0
Mitagate some of the performance issues with non-type-stable...
mbauman Apr 23, 2018
a2b9015
broadcast.jl cleanup:
mbauman Apr 23, 2018
c8bb374
Rename Broadcast.*_indices to *_axes as appropriate
mbauman Apr 23, 2018
110a0a5
Merge remote-tracking branch 'origin/master' into teh-jn/lazydotfuse
mbauman Apr 23, 2018
6fdb86e
Remove spurious NEWS item from merge mistake
mbauman Apr 23, 2018
df51b31
Fix broadcast_similar docstring
mbauman Apr 23, 2018
a1d4e7e
Fix #22255 by inlining the necessary methods
mbauman Apr 23, 2018
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
19 changes: 14 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,6 @@ This section lists changes that do not have deprecation warnings.
Its return value has been removed. Use the `process_running` function
to determine if a process has already exited.

* Broadcasting has been redesigned with an extensible public interface. The new API is
documented at https://docs.julialang.org/en/latest/manual/interfaces/#Interfaces-1.
`AbstractArray` types that specialized broadcasting using the old internal API will
need to switch to the new API. ([#20740])

* The logging system has been redesigned - `info` and `warn` are deprecated
and replaced with the logging macros `@info`, `@warn`, `@debug` and
`@error`. The `logging` function is also deprecated and replaced with
Expand All @@ -418,6 +413,20 @@ This section lists changes that do not have deprecation warnings.
* `findn(x::AbstractArray)` has been deprecated in favor of `findall(!iszero, x)`, which
now returns cartesian indices for multidimensional arrays (see below, [#25532]).

* Broadcasting operations are no longer fused into a single operation by Julia's parser.
Instead, a lazy `Broadcasted` wrapper is created, and the parser will call
`copy(bc::Broadcasted)` or `copyto!(dest, bc::Broadcasted)`
to evaluate the wrapper. Consequently, package authors generally need to specialize
`copy` and `copyto!` methods rather than `broadcast` and `broadcast!`.
See the [Interfaces chapter](https://docs.julialang.org/en/latest/manual/interfaces/#Interfaces-1)
for more information.

* `find` now returns the same type of indices as `keys`/`pairs` for `AbstractArray`,
`AbstractDict`, `AbstractString`, `Tuple` and `NamedTuple` objects ([#24774]).
In particular, this means that it returns `CartesianIndex` objects for matrices
and higher-dimensional arrays instead of linear indices as was previously the case.
Use `Int[LinearIndices(size(a))[i] for i in find(f, a)]` to compute linear indices.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks redundant with the next news item (and partly contradicts it).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for the reminder. This was a merge mistake.


* `find` has been renamed to `findall`. `findall`, `findfirst`, `findlast`, `findnext`
now take and/or return the same type of indices as `keys`/`pairs` for `AbstractArray`,
`AbstractDict`, `AbstractString`, `Tuple` and `NamedTuple` objects ([#24774], [#25545]).
Expand Down
40 changes: 0 additions & 40 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1097,19 +1097,6 @@ function (-)(B::BitArray)
end
broadcast(::typeof(sign), B::BitArray) = copy(B)

function broadcast(::typeof(~), B::BitArray)
C = similar(B)
Bc = B.chunks
if !isempty(Bc)
Cc = C.chunks
for i = 1:length(Bc)
Cc[i] = ~Bc[i]
end
Cc[end] &= _msk_end(B)
end
return C
end

"""
flipbits!(B::BitArray{N}) -> BitArray{N}

Expand Down Expand Up @@ -1166,33 +1153,6 @@ end
(/)(B::BitArray, x::Number) = (/)(Array(B), x)
(/)(x::Number, B::BitArray) = (/)(x, Array(B))

# broadcast specializations for &, |, and xor/⊻
broadcast(::typeof(&), B::BitArray, x::Bool) = x ? copy(B) : falses(size(B))
broadcast(::typeof(&), x::Bool, B::BitArray) = broadcast(&, B, x)
broadcast(::typeof(|), B::BitArray, x::Bool) = x ? trues(size(B)) : copy(B)
broadcast(::typeof(|), x::Bool, B::BitArray) = broadcast(|, B, x)
broadcast(::typeof(xor), B::BitArray, x::Bool) = x ? .~B : copy(B)
broadcast(::typeof(xor), x::Bool, B::BitArray) = broadcast(xor, B, x)
for f in (:&, :|, :xor)
@eval begin
function broadcast(::typeof($f), A::BitArray, B::BitArray)
F = BitArray(undef, promote_shape(size(A),size(B))...)
Fc = F.chunks
Ac = A.chunks
Bc = B.chunks
(isempty(Ac) || isempty(Bc)) && return F
for i = 1:length(Fc)
Fc[i] = ($f)(Ac[i], Bc[i])
end
Fc[end] &= _msk_end(F)
return F
end
broadcast(::typeof($f), A::DenseArray{Bool}, B::BitArray) = broadcast($f, BitArray(A), B)
broadcast(::typeof($f), B::BitArray, A::DenseArray{Bool}) = broadcast($f, B, BitArray(A))
end
end


## promotion to complex ##

# TODO?
Expand Down
Loading