-
Notifications
You must be signed in to change notification settings - Fork 29
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
Implement lazy addition #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,6 +197,22 @@ function materialize!(M::MatMulVecAdd) | |
default_blasmul!(α, A, B, iszero(β) ? false : β, C) | ||
end | ||
|
||
for MulAdd_ in [MatMulMatAdd, MatMulVecAdd] | ||
# `MulAdd{<:BroadcastLayout{typeof(+)}}` cannot "win" against | ||
# `MatMulMatAdd` and `MatMulVecAdd` hence `@eval`: | ||
@eval function materialize!(M::$MulAdd_{<:BroadcastLayout{typeof(+)}}) | ||
α, A, B, β, C = M.α, M.A, M.B, M.β, M.C | ||
if C ≡ B | ||
B = copy(B) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that you are testing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure. I think I added that line just for completeness, I don't think we necessary need it.
Yes, but when I wrote that line I didn't know about
Possibly. I believe broadcasting has an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah, yes. So throwing error is incompatible with standard broadcasting behavior... I missed that point. I wonder what was the reasoning for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can change this here and elsewhere to use |
||
end | ||
lmul!(β, C) | ||
for A in A.broadcasted.args | ||
C .= α .* Mul(A, B) .+ C | ||
end | ||
C | ||
end | ||
end | ||
|
||
# make copy to make sure always works | ||
@inline function _gemv!(tA, α, A, x, β, y) | ||
if x ≡ y | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
is anAbstractMarix
so maybeAddArray
is better as it would be consistent withMulArray
? (Though I prefer seeingAdd
in my code thanAddArray
orAddMatrix
.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is a tough one. What we could do is the following:
where the
AddStyle
means it's not type piracy.But I'm not convinced
Add
should exist at all: what aboutMinus
? IsAdd(A,B)
that much better than,broadcasted(+, A, B)
, which also forces it to not materialize?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe just use
BroadcastArray
like in this PR at the moment?ref: #8 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it's fine for now.