-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Should A .= B
evaluate to the RHS of the .=
?
#25954
Comments
So you want to fuse the loops in What do you do if an L-value appears multiple time, e.g. |
It should be consistent with regular assignment, i.e. lower to the RHS. |
Note that doing this as a lowering transform is not without precedent. |
Yup, it's not so much about supporting fusion through multiple |
Triage was unanimous. Let's do this. |
Triage accepts. |
I'm not sure what the proposed semantics are. Suppose you do result = (floatarray .= 2 .* intarray) What is "the RHS" in this case? The RHS expression Returning the LHS, on the other hand, would be straightforward. At minimum, we could document this property of |
Is there a way in which we can expand |
Very good point. Apparently we have the technology in lowering to wrap expressions in "unnecessary" heads, and then they can get elided if they're never used. That's still a little unsatisfactory, since it'd mean that we'd run the broadcasted function(s) through the arguments twice — once in the fused assignment and once in allocation of the RHS. The goal here would be to try to lower to something that would detect if it's needed. |
Would it be so terrible to just have |
Yes, it's inconsistent with every other appearance of |
The lowering passes (julia-syntax.scm) have a feature where you can wrap an expression in |
|
|
I am not a computer scientist, so excuse my ignorance. What happens to codes that follow this pattern:
Will Thanks |
No, this will be nearly unobservable in most everyone's code. This is only considering what the entire expression The |
I've been using something like |
Could we see some more examples where this change matters? Stevegj's example: RHS lowering: What should this mean? What code should get run? Do we store a temporary or compute twice?
LHS lowering: two loops, perform compute once, no temp copy, RHS lowering: What should this mean? What code should get run? Do we run all computations in the (ultimately) RHS multiple times? Do we store them in a temporary? Is there any example where trying for RHS lowering is better than returning Long-term, fusing into multi-output broadcasts might be cool; in this case we'd best have something now that returns the same result as the eventual solution (since multi-output broadcast that can store temporaries on the way has no syntax now). To give an example where we currently have a difference:
Otoh
|
I'm getting false positives in #24368 with code like this: $ ./julia --depwarn=error -q
julia> module TestFoo
x .= y
nothing
end
ERROR: syntax: Deprecated syntax `using the value of `.=``. Edit: whoops, I meant to post this in the PR that fixed this issue. |
…gnment * master: Make stdlib tests runnable standalone. (#26242) fix unary-related parsing regressions caused by #26154 (#26239) Formatting changes to new SSA IR devdocs [ci skip] use medium code model on PPC `retry` should support the check function proposed in the docstring. (#26138) mention axes in docs instead of size (#26233) exclude more CI files from source distro (#25906) Describe three-valued logic in docstrings deprecate using the value of `.=`. fixes #25954 (#26088) backport change to make CodegenPrepare work with isNoopAddrSpaceCast optimize the python version of abs2 in the microbenchmarks (#26223) Add notes for package maintainers (#25912) typo Fix broken links to functions in the manual (#26171) [NewOptimizer] Track inlining info Begin work on new optimizer framework add patch to make GC address spaces work on PPC also backport sover patch to LLVM 4.0
I keep encountering cases where this change makes it impossible to chain in-place operations. e.g. I just ran into a case where I wanted |
Or you can use |
@mbauman, in this case I actually had |
I have to say I'm fairly convinced by @stevengj's examples. Is there some way we can return the LHS and still avoid the spooky type annotation action at a distance? |
How about we return the rhs broadcasted to the shape of the LHS?
…On Mar 7, 2018 13:41, "Stefan Karpinski" ***@***.***> wrote:
I have to say I'm fairly convinced by @stevengj
<https://github.com/stevengj>'s examples. Is there some way we can return
the LHS and still avoid the spooky type annotation action at a distance?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#25954 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABO1l0RlDV8KZa7r72dXyMsYcL1QAQmJks5tcFQigaJpZM4R-ksT>
.
|
Returning the rhs in any form loses the advantage of working in-place with the lhs, which is the whole point of |
And now we can't use |
* origin/master: A few more #26670 fixes (#26773) Revert "deprecate using the value of `.=`. fixes #25954" (#26754) change dim arguments for `diff` and `unique` to keyword args (#26776) reorder pmap arguments to allow do-block syntax (#26783) correct deprecated parametric method syntax (#26789) [NewOptimizer] handle new IR nodes correctly in binary format [NewOptimizer] support line number emission from new IR format fix #26453, require obviously-concrete lower bound for a var to be diagonal (#26567) fix #26743, spurious `return` path in try-finally in tail position (#26753) Also lift SelectInst addrspaces
Currently,
A .= B
lowers to effectivelybroadcast!(identity, A, B)
. That typically returns the mutated object —A
. But this isn't enforced… or even documented.If we want to support chained
.=
expressions, it seems like we really need this to always evaluate to the RHS through a lowering transformation.The text was updated successfully, but these errors were encountered: