Best practices for nested loop #11837
Unanswered
rkruegs123
asked this question in
Q&A
Replies: 1 comment
-
Lots of questions here; some general answers:
Hope that helps |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a typical JAX issue. I want to implement behavior like the following:
The value of
n
is variable, so I have to usefori
orscan
. Clearly, the inner loop is an issue as it depends oni
.I understand there are several options for implementing this, e.g. masking. However, I was wondering if there are any best practices for implementing this behavior. For example, maybe gradients are known to propagate better using one method vs. another. Or, if there are reports of relatively poor gradient quality using masking, I would consider making
n
a static argument and recompiling every time.I should add that I can't vectorize the inner loop as later values depend on previously computed values. However, this does raise a sub-question I have about
fori
. My understanding is that the following form is allowed:If I am correct, why is this jittable but the nested for loops are not? Is their dependence on
i
not the same?Any and all feedback would be much appreciated. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions