Skip to content

Commit 640185a

Browse files
committed
fix broadcast misorder
1 parent 8200885 commit 640185a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/operations/broadcasts.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ modifying(::typeof(emul)) = emul!
9191
if right isa Broadcast.Broadcasted
9292
right = copy(right)
9393
end
94+
if left isa AbstractVector && right isa GBMatrixOrTranspose &&
95+
!(size(left, 1) == size(right, 1) && size(left, 2) == size(right, 2))
96+
return *(Diagonal(left), right, (any, f))
97+
end
98+
if left isa GBMatrixOrTranspose && right isa Transpose{<:Any, <:AbstractVector} &&
99+
!(size(left, 1) == size(right, 1) && size(left, 2) == size(right, 2))
100+
return *(left, Diagonal(right), (any, f))
101+
end
94102
if left isa StridedArray
95103
left = pack(left; fill = right isa GBArrayOrTranspose ? getfill(right) : nothing)
96104
end
@@ -103,14 +111,7 @@ modifying(::typeof(emul)) = emul!
103111
# for many operations. But for non-builtins we'd need an API of sorts.
104112
# To get around this for now we will require that Vectors be on the left
105113
# and transposed vectors be on the right.
106-
if left isa AbstractVector && right isa GBMatrixOrTranspose &&
107-
!(size(left, 1) == size(right, 1) && size(left, 2) == size(right, 2))
108-
return *(Diagonal(left), right, (any, f))
109-
end
110-
if left isa GBMatrixOrTranspose && right isa Transpose{<:Any, <:AbstractVector} &&
111-
!(size(left, 1) == size(right, 1) && size(left, 2) == size(right, 2))
112-
return *(left, Diagonal(right), (any, f))
113-
end
114+
114115
if left isa GBArrayOrTranspose && right isa GBArrayOrTranspose
115116
add = defaultadd(f)
116117
return add(left, right, f)

0 commit comments

Comments
 (0)