Skip to content

Commit 637a2f2

Browse files
committed
Remove inline annations from broadcast kernels
1 parent c649ebb commit 637a2f2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

base/broadcast.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,8 @@ julia> string.(("one","two","three","four"), ": ", 1:4)
842842
broadcast(f::Tf, As...) where {Tf} = materialize(broadcasted(f, As...))
843843

844844
# special cases defined for performance
845-
@inline broadcast(f, x::Number...) = f(x...)
846-
@inline broadcast(f, t::NTuple{N,Any}, ts::Vararg{NTuple{N,Any}}) where {N} = map(f, t, ts...)
845+
broadcast(f, x::Number...) = f(x...)
846+
broadcast(f, t::NTuple{N,Any}, ts::Vararg{NTuple{N,Any}}) where {N} = map(f, t, ts...)
847847

848848
"""
849849
broadcast!(f, dest, As...)
@@ -901,28 +901,28 @@ end
901901
902902
Take a lazy `Broadcasted` object and compute the result
903903
"""
904-
@inline materialize(bc::Broadcasted) = copy(instantiate(bc))
904+
materialize(bc::Broadcasted) = copy(instantiate(bc))
905905
materialize(x) = x
906906

907-
@inline function materialize!(dest, x)
907+
function materialize!(dest, x)
908908
return materialize!(dest, instantiate(Broadcasted(identity, (x,), axes(dest))))
909909
end
910910

911-
@inline function materialize!(dest, bc::Broadcasted{Style}) where {Style}
911+
function materialize!(dest, bc::Broadcasted{Style}) where {Style}
912912
return materialize!(combine_styles(dest, bc), dest, bc)
913913
end
914-
@inline function materialize!(::BroadcastStyle, dest, bc::Broadcasted{Style}) where {Style}
914+
function materialize!(::BroadcastStyle, dest, bc::Broadcasted{Style}) where {Style}
915915
return copyto!(dest, instantiate(Broadcasted{Style}(bc.f, bc.args, axes(dest))))
916916
end
917917

918918
## general `copy` methods
919-
@inline copy(bc::Broadcasted{<:AbstractArrayStyle{0}}) = bc[CartesianIndex()]
919+
copy(bc::Broadcasted{<:AbstractArrayStyle{0}}) = bc[CartesianIndex()]
920920
copy(bc::Broadcasted{<:Union{Nothing,Unknown}}) =
921921
throw(ArgumentError("broadcasting requires an assigned BroadcastStyle"))
922922

923923
const NonleafHandlingStyles = Union{DefaultArrayStyle,ArrayConflict}
924924

925-
@inline function copy(bc::Broadcasted{Style}) where {Style}
925+
function copy(bc::Broadcasted{Style}) where {Style}
926926
ElType = combine_eltypes(bc.f, bc.args)
927927
if Base.isconcretetype(ElType)
928928
# We can trust it and defer to the simpler `copyto!`
@@ -954,10 +954,10 @@ end
954954
## general `copyto!` methods
955955
# The most general method falls back to a method that replaces Style->Nothing
956956
# This permits specialization on typeof(dest) without introducing ambiguities
957-
@inline copyto!(dest::AbstractArray, bc::Broadcasted) = copyto!(dest, convert(Broadcasted{Nothing}, bc))
957+
copyto!(dest::AbstractArray, bc::Broadcasted) = copyto!(dest, convert(Broadcasted{Nothing}, bc))
958958

959959
# Performance optimization for the common identity scalar case: dest .= val
960-
@inline function copyto!(dest::AbstractArray, bc::Broadcasted{<:AbstractArrayStyle{0}})
960+
function copyto!(dest::AbstractArray, bc::Broadcasted{<:AbstractArrayStyle{0}})
961961
# Typically, we must independently execute bc for every storage location in `dest`, but:
962962
# IF we're in the common no-op identity case with no nested args (like `dest .= val`),
963963
if bc.f === identity && bc.args isa Tuple{Any} && isflat(bc)
@@ -989,7 +989,7 @@ preprocess_args(dest, args::Tuple{Any}) = (preprocess(dest, args[1]),)
989989
preprocess_args(dest, args::Tuple{}) = ()
990990

991991
# Specialize this method if all you want to do is specialize on typeof(dest)
992-
@inline function copyto!(dest::AbstractArray, bc::Broadcasted{Nothing})
992+
function copyto!(dest::AbstractArray, bc::Broadcasted{Nothing})
993993
axes(dest) == axes(bc) || throwdm(axes(dest), axes(bc))
994994
# Performance optimization: broadcast!(identity, dest, A) is equivalent to copyto!(dest, A) if indices match
995995
if bc.f === identity && bc.args isa Tuple{AbstractArray} # only a single input argument to broadcast!
@@ -1009,7 +1009,7 @@ end
10091009

10101010
# Performance optimization: for BitArray outputs, we cache the result
10111011
# in a "small" Vector{Bool}, and then copy in chunks into the output
1012-
@inline function copyto!(dest::BitArray, bc::Broadcasted{Nothing})
1012+
function copyto!(dest::BitArray, bc::Broadcasted{Nothing})
10131013
axes(dest) == axes(bc) || throwdm(axes(dest), axes(bc))
10141014
ischunkedbroadcast(dest, bc) && return chunkedcopyto!(dest, bc)
10151015
length(dest) < 256 && return invoke(copyto!, Tuple{AbstractArray, Broadcasted{Nothing}}, dest, bc)
@@ -1065,7 +1065,7 @@ liftchunks(args::Tuple{<:Bool,Vararg{Any}}) = (ifelse(args[1], typemax(UInt64),
10651065
ithchunk(i) = ()
10661066
Base.@propagate_inbounds ithchunk(i, c::Vector{UInt64}, args...) = (c[i], ithchunk(i, args...)...)
10671067
Base.@propagate_inbounds ithchunk(i, b::UInt64, args...) = (b, ithchunk(i, args...)...)
1068-
@inline function chunkedcopyto!(dest::BitArray, bc::Broadcasted)
1068+
function chunkedcopyto!(dest::BitArray, bc::Broadcasted)
10691069
isempty(dest) && return dest
10701070
f = flatten(liftfuncs(bc))
10711071
args = liftchunks(f.args)
@@ -1112,7 +1112,7 @@ end
11121112

11131113
## Tuple methods
11141114

1115-
@inline function copy(bc::Broadcasted{Style{Tuple}})
1115+
function copy(bc::Broadcasted{Style{Tuple}})
11161116
dim = axes(bc)
11171117
length(dim) == 1 || throw(DimensionMismatch("tuple only supports one dimension"))
11181118
N = length(dim[1])
@@ -1196,15 +1196,15 @@ struct BitMaskedBitArray{N,M}
11961196
mask::BitArray{M}
11971197
BitMaskedBitArray{N,M}(parent, mask) where {N,M} = new(parent, mask)
11981198
end
1199-
@inline function BitMaskedBitArray(parent::BitArray{N}, mask::BitArray{M}) where {N,M}
1199+
function BitMaskedBitArray(parent::BitArray{N}, mask::BitArray{M}) where {N,M}
12001200
@boundscheck checkbounds(parent, mask)
12011201
BitMaskedBitArray{N,M}(parent, mask)
12021202
end
12031203
Base.@propagate_inbounds dotview(B::BitArray, i::BitArray) = BitMaskedBitArray(B, i)
12041204
Base.show(io::IO, B::BitMaskedBitArray) = foreach(arg->show(io, arg), (typeof(B), (B.parent, B.mask)))
12051205
# Override materialize! to prevent the BitMaskedBitArray from escaping to an overrideable method
1206-
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any,<:Any,typeof(identity),Tuple{Bool}}) = fill!(B, bc.args[1])
1207-
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any}) = materialize!(SubArray(B.parent, to_indices(B.parent, (B.mask,))), bc)
1206+
materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any,<:Any,typeof(identity),Tuple{Bool}}) = fill!(B, bc.args[1])
1207+
materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any}) = materialize!(SubArray(B.parent, to_indices(B.parent, (B.mask,))), bc)
12081208
function Base.fill!(B::BitMaskedBitArray, b::Bool)
12091209
Bc = B.parent.chunks
12101210
Ic = B.mask.chunks

0 commit comments

Comments
 (0)