Conservative array casting in conditional#2892
Conversation
|
Ah, this change has more impact than I thought. Whereas before the following: would raise an error, because we were trying to cast a string to an array, it now succeeds because Not sure if there are other opinions on this, but I'm leaning towards this change being fine? |
I think it's fine since this is just how regular python would work too? a.k. strings being used as some sort of condition |
Turns out program capture already behaves this way too, so this is actually unifying the behaviour 👍 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2892 +/- ##
==========================================
- Coverage 97.01% 97.00% -0.02%
==========================================
Files 167 167
Lines 18830 18872 +42
Branches 1770 1773 +3
==========================================
+ Hits 18268 18306 +38
- Misses 417 420 +3
- Partials 145 146 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
In the context of JAX tracing, casting values to arrays automatically converts them to tracers, which means this value, and everything it interacts with, is now considered a dynamic program value. Being more conservative in this casting process, thus ensuring that static values remain static for longer, can be beneficial, e.g. for trace-time optimizations. This is especially true given that this is generally a one-way process, i.e. it is much easier to make a static value dynamic, than a dynamic value static.