-
Notifications
You must be signed in to change notification settings - Fork 193
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
Introduce while loops #122
Comments
I am a fan of futhark so I think adding their style of looping is definitely an interesting idea. In terms of adding Understanding that the |
@seanmor5 that's a good question. I went back to Furhark code and I realized the support two looping constructs: for and while:
If we want to support both loops, then it means this is not quite the same as
So I would rather proceed with |
After thinking more about this, I suggest for us to start with |
I would like to add a higher-level looping construct to
defn
. In Elixir, we can usefor+:reduce
but I am afraid it will be too verbose and foreign for new users. Let's imagine we want to translate this python code:With for+:reduce, we would write it as:
I propose we introduce a loop construct, inspired by futhark that looks like this:
Rewriting the above to this loop construct, we have:
There is one downside with this approach: the only form of loops we have in XLA are while loops which are sequential. Other languages, such as taichi, can optimize them to run in parallel. For this reason, we may want to introduce higher level constructs for manipulating tensors. In particular, I believe we should introduce functions such as
map
,map_with_index
,reduce
andreduce_with_index
. I have some thoughts in how we can implement said functions so they also work with batching out of the box, but I am waiting for some feedback on this issue before moving forward.The text was updated successfully, but these errors were encountered: