-
It sucks to know this after investing so much time in Flax hoping to start a new project. I just wish it was possible to use |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @yang-song I'm sorry to hear that! Do you have a code example? I'm curious how you were planning to use the module in |
Beta Was this translation helpful? Give feedback.
-
We will add full fledged For your particular case though I would advice not to use cond at all.
Alternatively, you could use a boolean first_row, first_col and use |
Beta Was this translation helpful? Give feedback.
We will add full fledged
cond
support that would allow module-in-cond.For your particular case though I would advice not to use cond at all.
Cond has a high overhead on accelerators in particular GPU this is also why it hasn't been implemented yet. It is rarely a good idea to use it inside a model. The condition needs to be evaluated on host and the next op can only be scheduled afterward causing the GPU to idle in the meantime.
jnp.where
will get you better performance here. It will execute both branches and pick the correct one avoiding a sync between GPU and host while also allowing for more optimization in XLA.Alternatively, you could use a boolean first_row, first_col and use
jit(s…