Replies: 4 comments 5 replies
-
Interesting idea! Do you have a sketch of how the implementation of these context managers might look? |
Beta Was this translation helpful? Give feedback.
-
No, sorry, I was thinking about it only as a user. "I want it to work this
way, so they probably would know an approach."
I'm from mech and ML eng so you probably know better.
…On Mon, Sep 9, 2024 at 6:01 PM Jake Vanderplas ***@***.***> wrote:
Fortunately I don't think the compiler would have to be involved here, any
context manager API would be entirely implemented in Python, as a wrapper
that would output a standard scan call. Did you have ideas on how that
could be implemented?
—
Reply to this email directly, view it on GitHub
<#23487 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZZOTDZAVCEPWNL2A6EZKWLZVXH7PAVCNFSM6AAAAABNZZ6VOCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANJZGM4DANQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Well, to be fair I don't know, but I know that be a nice syntax to work
with.
Maybe convert it to an array of lambda operations under the hood? If that's
possible at all.
Cheers.
…On Mon, 9 Sept 2024, 18:33 Jake Vanderplas, ***@***.***> wrote:
OK - in that case, could you say more about what exactly you have in mind?
It's not clear to me how the context manager you wrote might map to a scan
operation.
—
Reply to this email directly, view it on GitHub
<#23487 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZZOTD5Q75HOZGZLTN4ZE3TZVXLYLAVCNFSM6AAAAABNZZ6VOCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANJZGQYTENA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hello, I actually (think) I have an idea on how this can be implemented.
During JIT parsing, jax does store the parse results somewhere, right? The intended output is:
Equals to this:
Now I do see that So, you'd essentially say "we want code which runs with this context manager to be treated as if it was in a separate function, which we can optimize for Same for (Get it? I can clarify.) |
Beta Was this translation helpful? Give feedback.
-
Sup Jax,
I was writing a function to segregate values based on predicate, like this:
Which has three defs in a row, which looks like abomination, and...
What if we make scan and maybe even cond something like this:
Additionally to having jax.lax.scan maybe there would be a
wscan
which is identical, except it can be used in such awith
statement?Same goes for cond() which could be somehow reused to work?
Think of how much easier it would be to read and write:
We won't have to write terse code with
def
s, then make explicit calls to them, which would cleanup code well.I propose this as a highly useful feature, everyone would benefit if jax team implements it.
Beta Was this translation helpful? Give feedback.
All reactions