Skip to content

Commit

Permalink
Fix broadcasting bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Sep 22, 2020
1 parent 89e1d2e commit d2cce7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PaddedMatrices"
uuid = "aaaacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <elrodc@gmail.com>"]
version = "0.1.11"
version = "0.1.12"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
1 change: 1 addition & 0 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ end
# end
# ref
# end
ls.isbroadcast[] = true;
resize!(ls.loop_order, LoopVectorization.num_loops(ls)) # num_loops may be greater than N, eg Product
# ls.vector_width[] = VectorizationBase.pick_vector_width(T)
# return ls
Expand Down
26 changes: 17 additions & 9 deletions src/initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ function partially_sized(sv, pad::Bool, ::Type{T}) where {T}
N = length(sv)
L = 1
Lpos = 1
lastsize_known::Bool = false
q = Expr(:block, Expr(:meta,:inline))
for n 1:N
xv[n] = L
if L == -1
xn = Symbol(:stride_,n)
calcstride = Expr(:call, :vmul, Expr(:ref,:s,n-1), Symbol(:stride_, n-1))
calcstride = if lastsize_known
Expr(:call, :vmul, sv[n-1], Symbol(:stride_, n-1))
else
Expr(:call, :vmul, Symbol(:size_,n-1), Symbol(:stride_, n-1))
end
if pad & (n == 2)
calcstride = Expr(:call, :calc_padding, calcstride, T)
end
Expand All @@ -63,20 +68,23 @@ function partially_sized(sv, pad::Bool, ::Type{T}) where {T}
push!(xt.args, xn)
end
svₙ = sv[n]
if svₙ == -1
if L > 0
push!(q.args, Expr(:(=), Symbol(:stride_, n), L))
end
L = -1
push!(st.args, Expr(:ref, :s, n))
else
lastsize_known = svₙ != -1
if lastsize_known
if pad & (n == 1)
svₙ = calc_padding(svₙ, T)
end
Lpos *= svₙ
if L != -1
L *= svₙ
end
else
if L > 0
push!(q.args, Expr(:(=), Symbol(:stride_, n), L))
end
L = -1
sizesym = Symbol(:size_, n)
push!(q.args, Expr(:(=), sizesym, Expr(:ref, :s, n)))
push!(st.args, sizesym)
end
end
Lexpr = if L == -1
Expand Down Expand Up @@ -123,8 +131,8 @@ function tointvecdt(ssv)
end
@generated function StrideArray{T}(::UndefInitializer, s::Tuple, ::Val{pad}) where {T,pad}
sv = tointvecdt(s.parameters)
N = length(sv)
S = Tuple{sv...}
N = length(sv)
any(s -> s == -1, sv) || return Expr(:block, Expr(:meta,:inline), :(StrideArray{$S,$T}(undef)))
q, st, xt, xv, L = partially_sized(sv, pad, T)
SN = length(st.args); XN = length(xt.args)
Expand Down

2 comments on commit d2cce7b

@chriselrod
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/21919

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.12 -m "<description of version>" d2cce7b2a6425510484b673391b096d14fc0d272
git push origin v0.1.12

Please sign in to comment.